-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set Playwright HttpCredentials.Origin to scope auth header correctly
- Loading branch information
Showing
11 changed files
with
62 additions
and
52 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,29 @@ | ||
using System; | ||
|
||
namespace Coypu | ||
{ | ||
internal class FullyQualifiedUrlBuilder : UrlBuilder | ||
{ | ||
public string GetFullyQualifiedUrl(string virtualPath, SessionConfiguration sessionConfiguration) | ||
{ | ||
var scheme = sessionConfiguration.SSL ? "https" : "http"; | ||
var userInfoPart = string.IsNullOrEmpty(sessionConfiguration.UserInfo) ? "" : sessionConfiguration.UserInfo + "@"; | ||
var baseUrl = sessionConfiguration.Port == 80 | ||
? $"{scheme}://{userInfoPart}{sessionConfiguration.AppHost}" | ||
: $"{scheme}://{userInfoPart}{sessionConfiguration.AppHost}:{sessionConfiguration.Port}"; | ||
|
||
return new Uri(new Uri(baseUrl), virtualPath).AbsoluteUri; | ||
} | ||
} | ||
} | ||
using System; | ||
|
||
namespace Coypu | ||
{ | ||
internal class FullyQualifiedUrlBuilder : UrlBuilder | ||
{ | ||
public string GetFullyQualifiedUrl(string virtualPath, SessionConfiguration sessionConfiguration) | ||
{ | ||
var scheme = sessionConfiguration.SSL ? "https" : "http"; | ||
string userInfoPart = GetUserInfoPart(sessionConfiguration); | ||
var baseUrl = sessionConfiguration.Port == 80 | ||
? $"{scheme}://{userInfoPart}{sessionConfiguration.AppHost}" | ||
: $"{scheme}://{userInfoPart}{sessionConfiguration.AppHost}:{sessionConfiguration.Port}"; | ||
|
||
return new Uri(new Uri(baseUrl), virtualPath).AbsoluteUri; | ||
} | ||
|
||
private static string GetUserInfoPart(SessionConfiguration sessionConfiguration) | ||
{ | ||
// PlaywrightDriver implements basic auth properly via the Authorization header | ||
if (sessionConfiguration.Driver == typeof(Drivers.Playwright.PlaywrightDriver) || | ||
string.IsNullOrEmpty(sessionConfiguration.UserInfo)) | ||
{ | ||
return string.Empty; | ||
} | ||
return sessionConfiguration.UserInfo + "@"; | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
namespace Coypu | ||
{ | ||
public interface UrlBuilder | ||
{ | ||
string GetFullyQualifiedUrl(string virtualPath, SessionConfiguration sessionConfiguration); | ||
} | ||
} | ||
namespace Coypu | ||
{ | ||
public interface UrlBuilder | ||
{ | ||
string GetFullyQualifiedUrl(string virtualPath, SessionConfiguration sessionConfiguration); | ||
} | ||
} |