Skip to content

Commit 8e143e0

Browse files
committed
bb-test: rename test/mock helper methods
Rename some of the test/mock helper methods to be a little easier to grok/be shorter.
1 parent 81eccb9 commit 8e143e0

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

src/shared/Atlassian.Bitbucket.Tests/BitbucketHostProviderTest.cs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public async Task BitbucketHostProvider_GetCredentialAsync_Succeeds_ForValidStor
145145
var context = new TestCommandContext();
146146

147147
MockStoredAccount(context, input, password);
148-
MockRemoteBasicAuthAccountIsValid(bitbucketApi, input, password, twoFactor: false);
148+
MockRemoteBasicValid(bitbucketApi, input, password, twoFactor: false);
149149

150150
var provider = new BitbucketHostProvider(context, bitbucketAuthentication.Object, bitbucketApi.Object);
151151

@@ -163,7 +163,7 @@ public async Task BitbucketHostProvider_GetCredentialAsync_Succeeds_ForValidStor
163163
}
164164

165165
// Stored credentials so don't ask for more
166-
VerifyInteractiveBasicAuthFlowNeverRan(password, input, credential);
166+
VerifyInteractiveAuthNeverRan(password, input, credential);
167167

168168
// Valid Basic Auth credentials so don't run Oauth
169169
VerifyInteractiveOAuthFlowNeverRan(input, credential);
@@ -179,7 +179,7 @@ public async Task BitbucketHostProvider_GetCredentialAsync_Succeeds_ForValidStor
179179
var context = new TestCommandContext();
180180

181181
MockStoredAccount(context, input, token);
182-
MockRemoteOAuthAccountIsValid(bitbucketApi, input, token, false);
182+
MockRemoteAccessTokenValid(bitbucketApi, input, token, false);
183183

184184
var provider = new BitbucketHostProvider(context, bitbucketAuthentication.Object, bitbucketApi.Object);
185185

@@ -189,7 +189,7 @@ public async Task BitbucketHostProvider_GetCredentialAsync_Succeeds_ForValidStor
189189
VerifyValidateOAuthCredentialsRan();
190190

191191
// Stored credentials so don't ask for more
192-
VerifyInteractiveBasicAuthFlowNeverRan(token, input, credential);
192+
VerifyInteractiveAuthNeverRan(token, input, credential);
193193

194194
// Valid Basic Auth credentials so don't run Oauth
195195
VerifyInteractiveOAuthFlowNeverRan(input, credential);
@@ -206,14 +206,14 @@ public async Task BitbucketHostProvider_GetCredentialAsync_Succeeds_ForFreshVali
206206

207207
var context = new TestCommandContext();
208208

209-
MockUserEntersValidBasicCredentials(bitbucketAuthentication, input, password);
209+
MockPromptBasic(bitbucketAuthentication, input, password);
210210

211211
if (BITBUCKET_DOT_ORG_HOST.Equals(host))
212212
{
213-
MockRemoteOAuthAccountIsValid(bitbucketApi, input, password, true);
213+
MockRemoteAccessTokenValid(bitbucketApi, input, password, true);
214214
}
215215

216-
MockRemoteBasicAuthAccountIsValid(bitbucketApi, input, password, twoFactor: false);
216+
MockRemoteBasicValid(bitbucketApi, input, password, twoFactor: false);
217217

218218
var provider = new BitbucketHostProvider(context, bitbucketAuthentication.Object, bitbucketApi.Object);
219219

@@ -234,10 +234,10 @@ public async Task BitbucketHostProvider_GetCredentialAsync_Succeeds_ForFreshVali
234234
var context = new TestCommandContext();
235235

236236
// user is prompted for basic auth credentials
237-
MockUserEntersValidBasicCredentials(bitbucketAuthentication, input, password);
237+
MockPromptBasic(bitbucketAuthentication, input, password);
238238
// basic auth credentials are valid but 2FA is ON
239-
MockRemoteBasicAuthAccountIsValid(bitbucketApi, input, password, twoFactor: true);
240-
MockRemoteOAuthAccountIsValid(bitbucketApi, input, password, true);
239+
MockRemoteBasicValid(bitbucketApi, input, password, twoFactor: true);
240+
MockRemoteAccessTokenValid(bitbucketApi, input, password, true);
241241
MockRemoteValidRefreshToken();
242242

243243
var provider = new BitbucketHostProvider(context, bitbucketAuthentication.Object, bitbucketApi.Object);
@@ -265,8 +265,8 @@ public async Task BitbucketHostProvider_GetCredentialAsync_ForcedAuthMode_IsResp
265265
context.Environment.Variables.Add(BitbucketConstants.EnvironmentVariables.AuthenticationModes, preconfiguredAuthModes);
266266
}
267267

268-
MockUserEntersValidBasicCredentials(bitbucketAuthentication, input, password);
269-
MockRemoteBasicAuthAccountIsValid(bitbucketApi, input, password, twoFactor: true);
268+
MockPromptBasic(bitbucketAuthentication, input, password);
269+
MockRemoteBasicValid(bitbucketApi, input, password, twoFactor: true);
270270
bitbucketAuthentication.Setup(m => m.ShowOAuthRequiredPromptAsync()).ReturnsAsync(true);
271271

272272
var provider = new BitbucketHostProvider(context, bitbucketAuthentication.Object, bitbucketApi.Object);
@@ -283,7 +283,7 @@ public async Task BitbucketHostProvider_GetCredentialAsync_ForcedAuthMode_IsResp
283283

284284
if (preconfiguredAuthModes.Contains("oauth"))
285285
{
286-
VerifyInteractiveBasicAuthFlowNeverRan(password, input, credential);
286+
VerifyInteractiveAuthNeverRan(password, input, credential);
287287
VerifyInteractiveOAuthFlowRan(password, input, credential);
288288
}
289289
}
@@ -313,9 +313,9 @@ public async Task BitbucketHostProvider_GetCredentialAsync_AlwaysRefreshCredenti
313313
}
314314

315315
MockStoredAccount(context, input, password);
316-
MockUserEntersValidBasicCredentials(bitbucketAuthentication, input, password);
317-
MockRemoteOAuthAccountIsValid(bitbucketApi, input, password, true);
318-
MockRemoteBasicAuthAccountIsValid(bitbucketApi, input, password, twoFactor: false);
316+
MockPromptBasic(bitbucketAuthentication, input, password);
317+
MockRemoteAccessTokenValid(bitbucketApi, input, password, true);
318+
MockRemoteBasicValid(bitbucketApi, input, password, twoFactor: false);
319319

320320
var provider = new BitbucketHostProvider(context, bitbucketAuthentication.Object, bitbucketApi.Object);
321321

@@ -389,8 +389,8 @@ public async Task BitbucketHostProvider_GetCredentialAsync_ValidateTargetUriAsyn
389389
}
390390
else
391391
{
392-
MockUserEntersValidBasicCredentials(bitbucketAuthentication, input, password);
393-
MockRemoteBasicAuthAccountIsValid(bitbucketApi, input, password, twoFactor: true);
392+
MockPromptBasic(bitbucketAuthentication, input, password);
393+
MockRemoteBasicValid(bitbucketApi, input, password, twoFactor: true);
394394
MockRemoteValidRefreshToken();
395395
bitbucketAuthentication.Setup(m => m.ShowOAuthRequiredPromptAsync()).ReturnsAsync(true);
396396
bitbucketAuthentication.Setup(m => m.CreateOAuthCredentialsAsync(It.IsAny<Uri>())).ReturnsAsync(new OAuth2TokenResult(MOCK_ACCESS_TOKEN, "access_token"));
@@ -485,7 +485,7 @@ private void VerifyBasicAuthFlowNeverRan(string password, InputArguments input,
485485
}
486486
}
487487

488-
private void VerifyInteractiveBasicAuthFlowNeverRan(string password, InputArguments input, ICredential credential)
488+
private void VerifyInteractiveAuthNeverRan(string password, InputArguments input, ICredential credential)
489489
{
490490
var remoteUri = input.GetRemoteUri();
491491

@@ -579,14 +579,14 @@ private void MockRemoteValidRefreshToken()
579579
bitbucketAuthentication.Setup(m => m.RefreshOAuthCredentialsAsync(MOCK_REFRESH_TOKEN)).ReturnsAsync(new OAuth2TokenResult(MOCK_ACCESS_TOKEN, "access_token"));
580580
}
581581

582-
private static void MockUserEntersValidBasicCredentials(Mock<IBitbucketAuthentication> bitbucketAuthentication, InputArguments input, string password)
582+
private static void MockPromptBasic(Mock<IBitbucketAuthentication> bitbucketAuthentication, InputArguments input, string password)
583583
{
584584
var remoteUri = input.GetRemoteUri();
585585
bitbucketAuthentication.Setup(m => m.GetCredentialsAsync(remoteUri, input.UserName, It.IsAny<AuthenticationModes>()))
586586
.ReturnsAsync(new CredentialsPromptResult(AuthenticationModes.Basic, new TestCredential(input.Host, input.UserName, password)));
587587
}
588588

589-
private static void MockRemoteBasicAuthAccountIsValid(Mock<IBitbucketRestApi> bitbucketApi, InputArguments input, string password, bool twoFactor)
589+
private static void MockRemoteBasicValid(Mock<IBitbucketRestApi> bitbucketApi, InputArguments input, string password, bool twoFactor)
590590
{
591591
var userInfo = new UserInfo() { IsTwoFactorAuthenticationEnabled = twoFactor };
592592
// Basic
@@ -595,7 +595,7 @@ private static void MockRemoteBasicAuthAccountIsValid(Mock<IBitbucketRestApi> bi
595595

596596
}
597597

598-
private static void MockRemoteOAuthAccountIsValid(Mock<IBitbucketRestApi> bitbucketApi, InputArguments input, string password, bool twoFAEnabled)
598+
private static void MockRemoteAccessTokenValid(Mock<IBitbucketRestApi> bitbucketApi, InputArguments input, string password, bool twoFAEnabled)
599599
{
600600
var userInfo = new UserInfo() { IsTwoFactorAuthenticationEnabled = twoFAEnabled };
601601
// OAuth

0 commit comments

Comments
 (0)