Skip to content

Commit

Permalink
fix login
Browse files Browse the repository at this point in the history
  • Loading branch information
byCrookie committed Oct 28, 2023
1 parent f35c60d commit ed910a0
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public async Task LoginAsync_Invalid_ThrowException()

await action.Should().ThrowAsync<Exception>();

await _githubTokenStore.Received(0).SetAsync(token);
await _githubTokenStore.Received(1).SetAsync(token);
await _persistentCredentialStore.Received(0).StoreTokenAsync(Arg.Any<string>(), Arg.Any<CancellationToken>());

_logger.VerifyLogs(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public async Task LoginAsync_TokenNotValid_CallNext()

await _sut.LoginAsync(globalArgs, loginArgs, true, ct);

await _githubTokenStore.Received(0).SetAsync(Arg.Any<string>());
await _githubTokenStore.Received(1).SetAsync(token);
await _persistentCredentialStore.Received(0).StoreTokenAsync(Arg.Any<string>(), Arg.Any<CancellationToken>());

await _next.Received(1).LoginAsync(globalArgs, loginArgs, true, ct);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public async Task LoginAsync_Invalid_ThrowException()

await action.Should().ThrowAsync<Exception>();

await _githubTokenStore.Received(0).SetAsync(token);
await _githubTokenStore.Received(1).SetAsync(token);
await _persistentCredentialStore.Received(0).StoreTokenAsync(Arg.Any<string>(), Arg.Any<CancellationToken>());

_logger.VerifyLogs(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public async Task LoginAsync_Invalid_ThrowException()

await action.Should().ThrowAsync<Exception>();

await _githubTokenStore.Received(0).SetAsync(token);
await _githubTokenStore.Received(1).SetAsync(token);

_logger.VerifyLogs(
new LogEntry(LogLevel.Information, "Using token from environment variable"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,8 @@ private static bool IsReponsible(LoginArgs args)

try
{
var user = await _userService.WhoAmIAsync(ct);

await _githubTokenStore.SetAsync(oauthToken);
var user = await _userService.WhoAmIAsync(ct);

if (persist)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ private static bool IsReponsible(LoginArgs args)
return null;
}

var user = await _userService.WhoAmIAsync(ct);
await _githubTokenStore.SetAsync(t);
var user = await _userService.WhoAmIAsync(ct);
return user;
}
catch (Exception e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@ private static bool IsReponsible(LoginArgs args)

try
{
var user = await _userService.WhoAmIAsync(ct);

await _githubTokenStore.SetAsync(args.Token);
var user = await _userService.WhoAmIAsync(ct);

if (persist)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,8 @@ private bool IsReponsible()

try
{
var user = await _userService.WhoAmIAsync(ct);
await _githubTokenStore.SetAsync(token);
return user;
return await _userService.WhoAmIAsync(ct);
}
catch (Exception e)
{
Expand Down

0 comments on commit ed910a0

Please sign in to comment.