-
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 #201 from AdrianJSClark/200-always-use-cookies-fro…
…m-cookiecontainer Use Cookies Even Without "RestoreCookies"
- Loading branch information
Showing
2 changed files
with
38 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,4 +97,35 @@ public async Task GivenOptionsWithARestoreFuncTheFuncIsCalledToGetTheCookiesAsyn | |
Assert.That(cookies, Has.One.Property(nameof(Cookie.Name)).EqualTo("irsso_members")); | ||
Assert.That(cookies, Has.One.Property(nameof(Cookie.Name)).EqualTo("authtoken_members")); | ||
} | ||
|
||
[Test] | ||
public async Task GivenACookieContainerWithCookiesAndNoRestoreOrSaveFunctionsThenTheCookiesAreUsed() | ||
{ | ||
CookieContainer.Add(new Cookie("irsso_members", "one", "/", "members-ng.iracing.com")); | ||
CookieContainer.Add(new Cookie("authtoken_members", "two", "/", "members-ng.iracing.com")); | ||
|
||
var options = new iRacingDataClientOptions | ||
{ | ||
Username = "[email protected]", | ||
Password = "SuperSecretPassword", | ||
RestoreCookies = null, | ||
SaveCookies = null, | ||
}; | ||
|
||
using var sut = new DataClient(HttpClient, | ||
new TestLogger<DataClient>(), | ||
options, | ||
CookieContainer); | ||
|
||
await MessageHandler.QueueResponsesAsync(nameof(CapturedResponseValidationTests.GetLookupsSuccessfulAsync), false).ConfigureAwait(false); | ||
await sut.GetLookupsAsync(CancellationToken.None).ConfigureAwait(false); | ||
|
||
Assert.That(sut.IsLoggedIn, Is.True); | ||
|
||
var cookies = CookieContainer.GetAllCookies(); | ||
|
||
Assert.That(cookies, Has.Count.EqualTo(2)); | ||
Assert.That(cookies, Has.One.Property(nameof(Cookie.Name)).EqualTo("irsso_members")); | ||
Assert.That(cookies, Has.One.Property(nameof(Cookie.Name)).EqualTo("authtoken_members")); | ||
} | ||
} |
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