@@ -116,7 +116,7 @@ test('_auth auth', t => {
116
116
'_auth' : 'deadbeef' ,
117
117
'//my.custom.registry/here/:_auth' : 'c0ffee'
118
118
}
119
- t . deepEqual ( getAuth ( config . registry , config ) , {
119
+ t . like ( getAuth ( config . registry , config ) , {
120
120
alwaysAuth : false ,
121
121
_auth : 'c0ffee'
122
122
} , 'correct _auth picked out' )
@@ -130,6 +130,31 @@ test('_auth auth', t => {
130
130
. then ( res => t . equal ( res , 'success' , '_auth auth succeeded' ) )
131
131
} )
132
132
133
+ test ( '_auth username:pass auth' , t => {
134
+ const username = 'foo'
135
+ const password = 'bar'
136
+ const auth = Buffer . from ( `${ username } :${ password } ` , 'utf8' ) . toString ( 'base64' )
137
+ const config = {
138
+ 'registry' : 'https://my.custom.registry/here/' ,
139
+ '_auth' : 'foobarbaz' ,
140
+ '//my.custom.registry/here/:_auth' : auth
141
+ }
142
+ t . like ( getAuth ( config . registry , config ) , {
143
+ alwaysAuth : false ,
144
+ username,
145
+ password,
146
+ '_auth' : auth
147
+ } , 'correct _auth picked out' )
148
+
149
+ const opts = Object . assign ( { } , OPTS , config )
150
+ tnock ( t , opts . registry )
151
+ . matchHeader ( 'authorization' , `Basic ${ auth } ` )
152
+ . get ( '/hello' )
153
+ . reply ( 200 , '"success"' )
154
+ return fetch . json ( '/hello' , opts )
155
+ . then ( res => t . equal ( res , 'success' , '_auth auth succeeded' ) )
156
+ } )
157
+
133
158
test ( 'globally-configured auth' , t => {
134
159
const basicConfig = {
135
160
'registry' : 'https://different.registry/' ,
@@ -163,7 +188,7 @@ test('globally-configured auth', t => {
163
188
'_auth' : 'deadbeef' ,
164
189
'//my.custom.registry/here/:_auth' : 'c0ffee'
165
190
}
166
- t . deepEqual ( getAuth ( _authConfig . registry , _authConfig ) , {
191
+ t . like ( getAuth ( _authConfig . registry , _authConfig ) , {
167
192
alwaysAuth : false ,
168
193
_auth : 'deadbeef'
169
194
} , 'correct global _auth picked out' )
0 commit comments