-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #193 from AdrianJSClark/186-implementing-savecooki…
…es-and-restorecookies-does-not-prevent-unnecessary-logins Consider Client Logged In Cookies are Restored
- Loading branch information
Showing
9 changed files
with
161 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/Aydsko.iRacingData.IntegrationTests/Logins/LoginTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// © 2023 Adrian Clark | ||
// This file is licensed to you under the MIT license. | ||
|
||
using System.Net; | ||
using Aydsko.iRacingData.Exceptions; | ||
|
||
namespace Aydsko.iRacingData.IntegrationTests.Logins; | ||
|
||
internal sealed class LoginTests : BaseIntegrationFixture<DataClient> | ||
{ | ||
private CookieCollection? _cookiesToRestore; | ||
private CookieCollection? _cookiesFromSave; | ||
|
||
[OneTimeSetUp] | ||
public void OneTimeSetUp() | ||
{ | ||
var options = BaseSetUp(); | ||
options.RestoreCookies = () => _cookiesToRestore ?? []; | ||
options.SaveCookies = (cookies) => _cookiesFromSave = cookies; | ||
|
||
Client = new DataClient(HttpClient, new TestLogger<DataClient>(), options, CookieContainer); | ||
} | ||
|
||
[Test] | ||
public async Task TestFailedLoginFromBadCookieRestoreAsync() | ||
Check warning on line 25 in src/Aydsko.iRacingData.IntegrationTests/Logins/LoginTests.cs GitHub Actions / Build & Test / build
|
||
{ | ||
_cookiesToRestore = [new Cookie("test", "test", "/", ".iracing.com")]; | ||
_cookiesFromSave = [new Cookie("test", "test", "/", "localhost")]; | ||
|
||
Assert.Multiple(() => | ||
{ | ||
Assert.That(async () => await Client.GetClubHistoryLookupsAsync(2022, 1).ConfigureAwait(false), | ||
Throws.Exception.InstanceOf<iRacingUnauthorizedResponseException>()); | ||
|
||
Assert.That(_cookiesFromSave, Is.Empty); | ||
Assert.That(Client.IsLoggedIn, Is.False); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters