File tree Expand file tree Collapse file tree 3 files changed +19
-1
lines changed
Expand file tree Collapse file tree 3 files changed +19
-1
lines changed Original file line number Diff line number Diff line change 1+ unreleased
2+ ==========
3+
4+ * Fix regression accepting a Koa context
5+
161.0.2 / 2015-06-12
27==================
38
Original file line number Diff line number Diff line change @@ -54,7 +54,6 @@ function auth(req) {
5454 var header = ( req . req || req ) . headers . authorization
5555
5656 // parse header
57- var header = req . headers . authorization
5857 var match = credentialsRegExp . exec ( header || '' )
5958
6059 if ( ! match ) {
Original file line number Diff line number Diff line change @@ -15,6 +15,20 @@ describe('auth(req)', function () {
1515 it ( 'should be required' , function ( ) {
1616 assert . throws ( auth , / a r g u m e n t r e q i s r e q u i r e d / )
1717 } )
18+
19+ it ( 'should accept a request' , function ( ) {
20+ var req = request ( 'basic Zm9vOmJhcg==' )
21+ var creds = auth ( req )
22+ assert . equal ( creds . name , 'foo' )
23+ assert . equal ( creds . pass , 'bar' )
24+ } )
25+
26+ it ( 'should accept a koa context' , function ( ) {
27+ var ctx = { req : request ( 'basic Zm9vOmJhcg==' ) }
28+ var creds = auth ( ctx )
29+ assert . equal ( creds . name , 'foo' )
30+ assert . equal ( creds . pass , 'bar' )
31+ } )
1832 } )
1933 } )
2034
You can’t perform that action at this time.
0 commit comments