@@ -21,13 +21,13 @@ public async Task LoginTokenIsSavedToCache()
2121 client . Authorization . GetOrCreateApplicationAuthentication ( "id" , "secret" , Arg . Any < NewAuthorization > ( ) )
2222 . Returns ( new ApplicationAuthorization ( "123abc" ) ) ;
2323
24- var loginCache = Substitute . For < IKeychain > ( ) ;
24+ var keychain = Substitute . For < IKeychain > ( ) ;
2525 var tfa = Substitute . For < ITwoFactorChallengeHandler > ( ) ;
2626
27- var target = new LoginManager ( loginCache , tfa , "id" , "secret" ) ;
27+ var target = new LoginManager ( keychain , tfa , "id" , "secret" ) ;
2828 await target . Login ( host , client , "foo" , "bar" ) ;
2929
30- await loginCache . Received ( ) . Save ( "foo" , "123abc" , host ) ;
30+ await keychain . Received ( ) . Save ( "foo" , "123abc" , host ) ;
3131 }
3232
3333 [ Fact ]
@@ -39,10 +39,10 @@ public async Task LoggedInUserIsReturned()
3939 . Returns ( new ApplicationAuthorization ( "123abc" ) ) ;
4040 client . User . Current ( ) . Returns ( user ) ;
4141
42- var loginCache = Substitute . For < IKeychain > ( ) ;
42+ var keychain = Substitute . For < IKeychain > ( ) ;
4343 var tfa = Substitute . For < ITwoFactorChallengeHandler > ( ) ;
4444
45- var target = new LoginManager ( loginCache , tfa , "id" , "secret" ) ;
45+ var target = new LoginManager ( keychain , tfa , "id" , "secret" ) ;
4646 var result = await target . Login ( host , client , "foo" , "bar" ) ;
4747
4848 Assert . Same ( user , result ) ;
@@ -62,15 +62,15 @@ public async Task DeletesExistingAuthenticationIfNullTokenReturned()
6262 new ApplicationAuthorization ( "123abc" ) ) ;
6363 client . User . Current ( ) . Returns ( user ) ;
6464
65- var loginCache = Substitute . For < IKeychain > ( ) ;
65+ var keychain = Substitute . For < IKeychain > ( ) ;
6666 var tfa = Substitute . For < ITwoFactorChallengeHandler > ( ) ;
6767
68- var target = new LoginManager ( loginCache , tfa , "id" , "secret" ) ;
68+ var target = new LoginManager ( keychain , tfa , "id" , "secret" ) ;
6969 var result = await target . Login ( host , client , "foo" , "bar" ) ;
7070
7171 await client . Authorization . Received ( 2 ) . GetOrCreateApplicationAuthentication ( "id" , "secret" , Arg . Any < NewAuthorization > ( ) ) ;
7272 await client . Authorization . Received ( 1 ) . Delete ( 0 ) ;
73- await loginCache . Received ( ) . Save ( "foo" , "123abc" , host ) ;
73+ await keychain . Received ( ) . Save ( "foo" , "123abc" , host ) ;
7474 }
7575
7676 [ Fact ]
@@ -84,11 +84,11 @@ public async Task TwoFactorExceptionIsPassedToHandler()
8484 client . Authorization . GetOrCreateApplicationAuthentication ( "id" , "secret" , Arg . Any < NewAuthorization > ( ) , "123456" )
8585 . Returns ( new ApplicationAuthorization ( "123abc" ) ) ;
8686
87- var loginCache = Substitute . For < IKeychain > ( ) ;
87+ var keychain = Substitute . For < IKeychain > ( ) ;
8888 var tfa = Substitute . For < ITwoFactorChallengeHandler > ( ) ;
8989 tfa . HandleTwoFactorException ( exception ) . Returns ( new TwoFactorChallengeResult ( "123456" ) ) ;
9090
91- var target = new LoginManager ( loginCache , tfa , "id" , "secret" ) ;
91+ var target = new LoginManager ( keychain , tfa , "id" , "secret" ) ;
9292 await target . Login ( host , client , "foo" , "bar" ) ;
9393
9494 await client . Authorization . Received ( ) . GetOrCreateApplicationAuthentication (
@@ -111,13 +111,13 @@ public async Task Failed2FACodeResultsInRetry()
111111 client . Authorization . GetOrCreateApplicationAuthentication ( "id" , "secret" , Arg . Any < NewAuthorization > ( ) , "123456" )
112112 . Returns ( new ApplicationAuthorization ( "123abc" ) ) ;
113113
114- var loginCache = Substitute . For < IKeychain > ( ) ;
114+ var keychain = Substitute . For < IKeychain > ( ) ;
115115 var tfa = Substitute . For < ITwoFactorChallengeHandler > ( ) ;
116116 tfa . HandleTwoFactorException ( exception ) . Returns (
117117 new TwoFactorChallengeResult ( "111111" ) ,
118118 new TwoFactorChallengeResult ( "123456" ) ) ;
119119
120- var target = new LoginManager ( loginCache , tfa , "id" , "secret" ) ;
120+ var target = new LoginManager ( keychain , tfa , "id" , "secret" ) ;
121121 await target . Login ( host , client , "foo" , "bar" ) ;
122122
123123 await client . Authorization . Received ( 1 ) . GetOrCreateApplicationAuthentication (
@@ -146,13 +146,13 @@ public async Task HandlerNotifiedOfExceptionIn2FAChallengeResponse()
146146 client . Authorization . GetOrCreateApplicationAuthentication ( "id" , "secret" , Arg . Any < NewAuthorization > ( ) , "111111" )
147147 . Returns < ApplicationAuthorization > ( _ => { throw loginAttemptsException ; } ) ;
148148
149- var loginCache = Substitute . For < IKeychain > ( ) ;
149+ var keychain = Substitute . For < IKeychain > ( ) ;
150150 var tfa = Substitute . For < ITwoFactorChallengeHandler > ( ) ;
151151 tfa . HandleTwoFactorException ( twoFaException ) . Returns (
152152 new TwoFactorChallengeResult ( "111111" ) ,
153153 new TwoFactorChallengeResult ( "123456" ) ) ;
154154
155- var target = new LoginManager ( loginCache , tfa , "id" , "secret" ) ;
155+ var target = new LoginManager ( keychain , tfa , "id" , "secret" ) ;
156156 Assert . ThrowsAsync < LoginAttemptsExceededException > ( async ( ) => await target . Login ( host , client , "foo" , "bar" ) ) ;
157157
158158 await client . Authorization . Received ( 1 ) . GetOrCreateApplicationAuthentication (
@@ -176,13 +176,13 @@ public async Task RequestResendCodeResultsInRetryingLogin()
176176 . Returns ( new ApplicationAuthorization ( "456def" ) ) ;
177177 client . User . Current ( ) . Returns ( user ) ;
178178
179- var loginCache = Substitute . For < IKeychain > ( ) ;
179+ var keychain = Substitute . For < IKeychain > ( ) ;
180180 var tfa = Substitute . For < ITwoFactorChallengeHandler > ( ) ;
181181 tfa . HandleTwoFactorException ( exception ) . Returns (
182182 TwoFactorChallengeResult . RequestResendCode ,
183183 new TwoFactorChallengeResult ( "123456" ) ) ;
184184
185- var target = new LoginManager ( loginCache , tfa , "id" , "secret" ) ;
185+ var target = new LoginManager ( keychain , tfa , "id" , "secret" ) ;
186186 await target . Login ( host , client , "foo" , "bar" ) ;
187187
188188 await client . Authorization . Received ( 2 ) . GetOrCreateApplicationAuthentication ( "id" , "secret" , Arg . Any < NewAuthorization > ( ) ) ;
@@ -201,13 +201,13 @@ public async Task UsesUsernameAndPasswordInsteadOfAuthorizationTokenWhenEnterpri
201201 } ) ;
202202 client . User . Current ( ) . Returns ( user ) ;
203203
204- var loginCache = Substitute . For < IKeychain > ( ) ;
204+ var keychain = Substitute . For < IKeychain > ( ) ;
205205 var tfa = Substitute . For < ITwoFactorChallengeHandler > ( ) ;
206206
207- var target = new LoginManager ( loginCache , tfa , "id" , "secret" ) ;
207+ var target = new LoginManager ( keychain , tfa , "id" , "secret" ) ;
208208 await target . Login ( enterprise , client , "foo" , "bar" ) ;
209209
210- await loginCache . Received ( ) . Save ( "foo" , "bar" , enterprise ) ;
210+ await keychain . Received ( ) . Save ( "foo" , "bar" , enterprise ) ;
211211 }
212212
213213 [ Fact ]
@@ -219,13 +219,13 @@ public async Task ErasesLoginWhenUnauthorized()
219219 client . Authorization . GetOrCreateApplicationAuthentication ( "id" , "secret" , Arg . Any < NewAuthorization > ( ) )
220220 . Returns < ApplicationAuthorization > ( _ => { throw new AuthorizationException ( ) ; } ) ;
221221
222- var loginCache = Substitute . For < IKeychain > ( ) ;
222+ var keychain = Substitute . For < IKeychain > ( ) ;
223223 var tfa = Substitute . For < ITwoFactorChallengeHandler > ( ) ;
224224
225- var target = new LoginManager ( loginCache , tfa , "id" , "secret" ) ;
225+ var target = new LoginManager ( keychain , tfa , "id" , "secret" ) ;
226226 await Assert . ThrowsAsync < AuthorizationException > ( async ( ) => await target . Login ( enterprise , client , "foo" , "bar" ) ) ;
227227
228- await loginCache . Received ( ) . Delete ( enterprise ) ;
228+ await keychain . Received ( ) . Delete ( enterprise ) ;
229229 }
230230
231231 [ Fact ]
@@ -237,13 +237,13 @@ public async Task ErasesLoginWhenNonOctokitExceptionThrown()
237237 client . Authorization . GetOrCreateApplicationAuthentication ( "id" , "secret" , Arg . Any < NewAuthorization > ( ) )
238238 . Returns < ApplicationAuthorization > ( _ => { throw new InvalidOperationException ( ) ; } ) ;
239239
240- var loginCache = Substitute . For < IKeychain > ( ) ;
240+ var keychain = Substitute . For < IKeychain > ( ) ;
241241 var tfa = Substitute . For < ITwoFactorChallengeHandler > ( ) ;
242242
243- var target = new LoginManager ( loginCache , tfa , "id" , "secret" ) ;
243+ var target = new LoginManager ( keychain , tfa , "id" , "secret" ) ;
244244 await Assert . ThrowsAsync < InvalidOperationException > ( async ( ) => await target . Login ( host , client , "foo" , "bar" ) ) ;
245245
246- await loginCache . Received ( ) . Delete ( host ) ;
246+ await keychain . Received ( ) . Delete ( host ) ;
247247 }
248248
249249 [ Fact ]
@@ -259,14 +259,14 @@ public async Task ErasesLoginWhenNonOctokitExceptionThrownIn2FA()
259259 . Returns < ApplicationAuthorization > ( _ => { throw new InvalidOperationException ( ) ; } ) ;
260260 client . User . Current ( ) . Returns ( user ) ;
261261
262- var loginCache = Substitute . For < IKeychain > ( ) ;
262+ var keychain = Substitute . For < IKeychain > ( ) ;
263263 var tfa = Substitute . For < ITwoFactorChallengeHandler > ( ) ;
264264 tfa . HandleTwoFactorException ( exception ) . Returns ( new TwoFactorChallengeResult ( "123456" ) ) ;
265265
266- var target = new LoginManager ( loginCache , tfa , "id" , "secret" ) ;
266+ var target = new LoginManager ( keychain , tfa , "id" , "secret" ) ;
267267 await Assert . ThrowsAsync < InvalidOperationException > ( async ( ) => await target . Login ( host , client , "foo" , "bar" ) ) ;
268268
269- await loginCache . Received ( ) . Delete ( host ) ;
269+ await keychain . Received ( ) . Delete ( host ) ;
270270 }
271271 }
272272}
0 commit comments