Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
standeren committed Nov 23, 2023
1 parent f69f1f5 commit 4d9b60f
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions backend/src/Designer/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public async Task<IActionResult> Login()

_logger.LogInformation("Updating app key for " + userName);
KeyValuePair<string, string> accessKeyValuePair = await _giteaApi.GetSessionAppKey() ?? default(KeyValuePair<string, string>);
List<Claim> claims = new ();
List<Claim> claims = new();
const string Issuer = "https://altinn.no";
if (!accessKeyValuePair.Equals(default(KeyValuePair<string, string>)))
{
Expand All @@ -165,10 +165,10 @@ public async Task<IActionResult> Login()
}

claims.Add(new Claim(AltinnCoreClaimTypes.Developer, userName, ClaimValueTypes.String, Issuer));
ClaimsIdentity identity = new ("TestUserLogin");
ClaimsIdentity identity = new("TestUserLogin");
identity.AddClaims(claims);

ClaimsPrincipal principal = new (identity);
ClaimsPrincipal principal = new(identity);

string timeoutString = DateTime.UtcNow.AddMinutes(_generalSettings.SessionDurationInMinutes - 5).ToString();
HttpContext.Response.Cookies.Append(
Expand Down Expand Up @@ -227,7 +227,7 @@ public IActionResult AppToken(AppKey appKey)
/// <returns>The debug info you want</returns>
public async Task<IActionResult> Debug()
{
StringBuilder stringBuilder = new ();
StringBuilder stringBuilder = new();
stringBuilder.AppendLine("Debug info");
stringBuilder.AppendLine("App token is: " + _sourceControl.GetAppToken());
stringBuilder.AppendLine("App token id is " + _sourceControl.GetAppTokenId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ private static QueueBuildRequest CreateBuildRequest(QueueBuildParameters queueBu
private async Task<Build> SendRequest(QueueBuildRequest queueBuildRequest)
{
string requestBody = JsonConvert.SerializeObject(queueBuildRequest);
using StringContent httpContent = new (requestBody, Encoding.UTF8, "application/json");
using StringContent httpContent = new(requestBody, Encoding.UTF8, "application/json");
string requestUri = "?api-version=5.1";
_logger.LogInformation("Doing a request toward: {HttpClientBaseAddress}{RequestUri}", _httpClient.BaseAddress, requestUri);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ private async Task<HttpResponseMessage> GetAuthorizedGiteaResponse(CancellationT

using var giteaGetLoginResponse = await giteaClient.GetAsync(giteaLoginUrl, cancellationToken);
string htmlContent = await giteaGetLoginResponse.Content.ReadAsStringAsync(cancellationToken);
List<KeyValuePair<string, string>> formValues = new ()
List<KeyValuePair<string, string>> formValues = new()
{
new KeyValuePair<string, string>("user_name", GiteaConstants.TestUser),
new KeyValuePair<string, string>("password", GiteaConstants.TestUserPassword),
new KeyValuePair<string, string>("_csrf", GetStringFromHtmlContent(htmlContent, "<input type=\"hidden\" name=\"_csrf\" value=\"", "\"")),
};

using FormUrlEncodedContent content = new (formValues);
using FormUrlEncodedContent content = new(formValues);

using var giteaPostLoginMessage = new HttpRequestMessage(HttpMethod.Post, giteaLoginUrl)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public UserControllerGiteaIntegrationTests(WebApplicationFactory<Program> factor
public async Task GetCurrentUser_ShouldReturnOk(string expectedUserName, string expectedEmail)
{
string requestUrl = "designer/api/user/current";
using HttpRequestMessage httpRequestMessage = new (HttpMethod.Get, requestUrl);
using HttpRequestMessage httpRequestMessage = new(HttpMethod.Get, requestUrl);

using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage);

Expand Down
4 changes: 2 additions & 2 deletions backend/tests/Designer.Tests/Utils/PrincipalUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ public static class PrincipalUtil

public static ClaimsPrincipal GetToken(string userName)
{
List<Claim> claims = new ();
List<Claim> claims = new();
const string Issuer = "https://altinn.no";

claims.Add(new Claim(AltinnCoreClaimTypes.Developer, userName, ClaimValueTypes.String, Issuer));
ClaimsIdentity identity = new ("TestUserLogin");
ClaimsIdentity identity = new("TestUserLogin");
identity.AddClaims(claims);

return new ClaimsPrincipal(identity);
Expand Down

0 comments on commit 4d9b60f

Please sign in to comment.