@@ -82,7 +82,7 @@ vows.describe('TokenStrategy').addBatch({
8282 } ,
8383 } ,
8484
85- 'strategy handling a valid request with credentials in header using PLAINTEXT method ' : {
85+ 'strategy handling a valid request with credentials in header using PLAINTEXT signature ' : {
8686 topic : function ( ) {
8787 var strategy = new TokenStrategy (
8888 // consumer callback
@@ -548,7 +548,58 @@ vows.describe('TokenStrategy').addBatch({
548548 } ,
549549 } ,
550550
551- // TODO: Implement test case for invalid PLAINTEXT signature
551+ 'strategy handling a request with invalid PLAINTEXT signature' : {
552+ topic : function ( ) {
553+ var strategy = new TokenStrategy (
554+ // consumer callback
555+ function ( consumerKey , done ) {
556+ done ( null , { id : '1' } , 'ssh-secret' ) ;
557+ } ,
558+ // verify callback
559+ function ( accessToken , done ) {
560+ done ( null , { username : 'bob' } , 'not-mmyauoBm7rRv0kLsNKAicmtsxsxKWJDmoEo7obTqglkyGNHs8hn78pkTj70tXatl' ) ;
561+ }
562+ ) ;
563+ return strategy ;
564+ } ,
565+
566+ 'after augmenting with actions' : {
567+ topic : function ( strategy ) {
568+ var self = this ;
569+ var req = { } ;
570+ strategy . success = function ( user , info ) {
571+ self . callback ( new Error ( 'should not be called' ) ) ;
572+ }
573+ strategy . fail = function ( challenge , status ) {
574+ self . callback ( null , challenge , status ) ;
575+ }
576+ strategy . error = function ( err ) {
577+ self . callback ( new Error ( 'should not be called' ) ) ;
578+ }
579+
580+ req . url = '/api/userinfo' ;
581+ req . method = 'GET' ;
582+ req . headers = { } ;
583+ req . headers [ 'host' ] = '127.0.0.1:3000' ;
584+ req . headers [ 'authorization' ] = 'OAuth oauth_consumer_key="abc123",oauth_nonce="bSzaRm1X9uu6DwjAuAsOnn6cnxYoVibS",oauth_signature_method="PLAINTEXT",oauth_timestamp="1341195485",oauth_token="Xe4F8Cf5vw68BoZF",oauth_version="1.0",oauth_signature="ssh-secret%2526mmyauoBm7rRv0kLsNKAicmtsxsxKWJDmoEo7obTqglkyGNHs8hn78pkTj70tXatl"' ;
585+ req . query = url . parse ( req . url , true ) . query ;
586+ req . connection = { encrypted : false } ;
587+ process . nextTick ( function ( ) {
588+ strategy . authenticate ( req ) ;
589+ } ) ;
590+ } ,
591+
592+ 'should not generate an error' : function ( err , challenge , status ) {
593+ assert . isNull ( err ) ;
594+ } ,
595+ 'should respond with challenge' : function ( err , challenge , status ) {
596+ assert . equal ( challenge , 'OAuth realm="Users", oauth_problem="signature_invalid"' ) ;
597+ } ,
598+ 'should respond with default status' : function ( err , challenge , status ) {
599+ assert . isUndefined ( status ) ;
600+ } ,
601+ } ,
602+ } ,
552603
553604 'strategy handling a request with unknown signature method' : {
554605 topic : function ( ) {
0 commit comments