Skip to content

Commit

Permalink
chore: update test name, remove idle server mention
Browse files Browse the repository at this point in the history
  • Loading branch information
Dovchik committed Aug 27, 2024
1 parent daa3c22 commit 8e92813
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions tests/Sinch.Tests/Core/HttpTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public async Task AddOwnHeaders()
}

[Fact]
public async Task UnauthorizedIfExpiredHeaderIsNotPresent()
public async Task UnauthorizedAndNoSecondAuthCallIfExpiredHeaderIsNotPresent()
{
_tokenManagerMock.GetAuthToken(Arg.Any<bool>())
.Returns("first_token");
Expand All @@ -217,8 +217,9 @@ public async Task UnauthorizedIfExpiredHeaderIsNotPresent()
await op1.Should().ThrowAsync<SinchApiException>();
}

// This test is testing a positive scenario when server was running idle - without doing requests to sinch api -
// for a while, and token it was holding became expired. Also tests next request after, presumably, next idle,
// This test is testing a positive scenario when server was holding previously fetched token for a while,
// and it became expired.
// Also tests next request, simulating the hold of token for some time again,
// making sure the scenario have the same behaviour between two *independent* requests.
//
// send expired token -> sinch api
Expand All @@ -241,12 +242,12 @@ public async Task NewTokenIsFetchedBetweenTwoRequestsStartingFromExpired()
.WithHeaders("Authorization", "Bearer first_token")
.Respond(HttpStatusCode.Unauthorized, _expiredHeader, (HttpContent)null);

// internally auth returns new valid token, and request to same endpoint now good
// internally auth fetches a new valid token, and request to same endpoint now good
_httpMessageHandlerMock.Expect(HttpMethod.Get, uri.ToString())
.WithHeaders("Authorization", "Bearer second_token")
.Respond(HttpStatusCode.OK);

// simulating some idle here, the latest token is expired again for second request
// simulating the hold of token for some time here, the latest token is expired again for second request
_httpMessageHandlerMock.Expect(HttpMethod.Get, uri.ToString())
.WithHeaders("Authorization", "Bearer second_token")
.Respond(HttpStatusCode.Unauthorized, _expiredHeader, (HttpContent)null);
Expand Down

0 comments on commit 8e92813

Please sign in to comment.