-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make Playwright throw exceptions for 500s and test
- Loading branch information
Showing
4 changed files
with
109 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
23 changes: 23 additions & 0 deletions
23
backend/Testing/Browser/Base/UnexpectedResponseException.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,23 @@ | ||
using System.Text.RegularExpressions; | ||
using Microsoft.Playwright; | ||
|
||
namespace Testing.Browser.Base; | ||
|
||
public partial class UnexpectedResponseException : SystemException | ||
{ | ||
public static string MaskUrl(string url) | ||
{ | ||
return JwtRegex().Replace(url, "*****"); | ||
} | ||
|
||
public UnexpectedResponseException(IResponse response) | ||
: this(response.StatusText, response.Status, response.Url) | ||
{ | ||
} | ||
|
||
public UnexpectedResponseException(string statusText, int statusCode, string url) | ||
: base($"Unexpected response: {statusText} ({statusCode}). URL: {MaskUrl(url)}.") { } | ||
|
||
[GeneratedRegex("[A-Za-z0-9-_]{10,}\\.[A-Za-z0-9-_]{20,}\\.[A-Za-z0-9-_]{10,}")] | ||
private static partial Regex JwtRegex(); | ||
} |
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