Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix all warnings #449

Merged
merged 10 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .azure/modules/containerAppEnvironment/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ resource application_insights_action 'Microsoft.Insights/actionGroups@2023-01-01
]
}
}
resource exceptionOccuredAlertRule 'Microsoft.Insights/scheduledQueryRules@2023-12-01' =
resource exceptionOccuredAlertRule 'Microsoft.Insights/scheduledQueryRules@2023-03-15-preview' =
if (emailReceiver != null && emailReceiver != '') {
name: '${namePrefix}-500-exception-occured'
location: location
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ jobs:
hasMigrationChanges: ${{ needs.check-for-changes.outputs.hasMigrationChanges }}

release-to-git:
name: release to git
name: Release to git
runs-on: ubuntu-latest
needs: [check-for-changes, deploy-production]
if: ${{ needs.check-for-changes.outputs.hasBackendChanges == 'true' && !failure() && !cancelled()}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected override void ConfigureWebHost(
((IList<AuthenticationSchemeBuilder>)o.Schemes).Clear();
});
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(async options =>
.AddJwtBearer(options =>
{
options.RequireHttpsMetadata = false;
options.SaveToken = true;
Expand Down
30 changes: 17 additions & 13 deletions Test/Altinn.Broker.Tests/LegacyFileControllerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
using Altinn.Broker.Models;
using Altinn.Broker.Tests.Factories;
using Altinn.Broker.Tests.Helpers;

using Xunit;

namespace Altinn.Broker.Tests;
Expand Down Expand Up @@ -90,10 +89,11 @@ public async Task GetFiles_GetByMultipleRecipient_Success()

var textResponse = await getResponse.Content.ReadAsStringAsync();

var result = await getResponse.Content.ReadAsAsync<List<Guid>>();
var result = await getResponse.Content.ReadFromJsonAsync<List<Guid>>(_responseSerializerOptions);

// Assert
Assert.Equal(HttpStatusCode.OK, getResponse.StatusCode);
Assert.NotNull(result);
Assert.Contains(Guid.Parse(fileId), result);
}

Expand Down Expand Up @@ -154,10 +154,11 @@ public async Task GetFiles_GetByMultipleRecipient_Recipient1_Success()
+ $"&resourceId={file.ResourceId}"
+ $"&recipients={file.Recipients[0]}");

var result = await getResponse.Content.ReadAsAsync<List<Guid>>();
var result = await getResponse.Content.ReadFromJsonAsync<List<Guid>>(_responseSerializerOptions);

// Assert
Assert.Equal(System.Net.HttpStatusCode.OK, getResponse.StatusCode);
Assert.NotNull(result);
Assert.Contains(Guid.Parse(fileId), result);
}

Expand Down Expand Up @@ -188,10 +189,11 @@ public async Task GetFiles_GetByMultipleRecipient_Recipient2_Success()
+ $"&resourceId={file.ResourceId}"
+ $"&recipients={file.Recipients[1]}");

var result = await getResponse.Content.ReadAsAsync<List<Guid>>();
var result = await getResponse.Content.ReadFromJsonAsync<List<Guid>>(_responseSerializerOptions);

// Assert
Assert.Equal(HttpStatusCode.OK, getResponse.StatusCode);
Assert.NotNull(result);
Assert.Contains(Guid.Parse(fileId), result);
}

Expand Down Expand Up @@ -221,11 +223,11 @@ public async Task GetFiles_GetBySingleRecipient_Success()
+ $"&from={HttpUtility.UrlEncode(from.UtcDateTime.ToString("o"))}&to={HttpUtility.UrlEncode(to.UtcDateTime.ToString("o"))}"
+ $"&resourceId={file.ResourceId}"
+ $"&onBehalfOfConsumer={file.Recipients[0]}");
var result = await getResponse.Content.ReadAsAsync<List<Guid>>();
var result = await getResponse.Content.ReadFromJsonAsync<List<Guid>>(_responseSerializerOptions);

// Assert
Assert.Equal(HttpStatusCode.OK, getResponse.StatusCode);
Assert.Contains(Guid.Parse(fileId), result);
Assert.Contains(Guid.Parse(fileId), result!);
}

[Fact]
Expand Down Expand Up @@ -262,13 +264,13 @@ public async Task GetFiles_GetInitializedAndDownloadStarted_Success()
+ $"&resourceId={file.ResourceId}"
+ $"&onBehalfOfConsumer={file.Recipients[1]}");

var result_recip1 = await getResponse_rep1.Content.ReadAsAsync<List<Guid>>();
var result_recip2 = await getResponse_rep2.Content.ReadAsAsync<List<Guid>>();
var result_recip1 = await getResponse_rep1.Content.ReadFromJsonAsync<List<Guid>>(_responseSerializerOptions);
var result_recip2 = await getResponse_rep2.Content.ReadFromJsonAsync<List<Guid>>(_responseSerializerOptions);

// Assert
Assert.Equal(HttpStatusCode.OK, getResponse_rep1.StatusCode);
Assert.Contains(Guid.Parse(fileId), result_recip1);
Assert.Contains(Guid.Parse(fileId), result_recip2);
Assert.Contains(Guid.Parse(fileId), result_recip1!);
Assert.Contains(Guid.Parse(fileId), result_recip2!);
}

[Fact]
Expand All @@ -291,10 +293,11 @@ public async Task GetFileOverview_SentByA3Sender_Success()

// Act
var getResponse = await _legacyClient.GetAsync($"broker/api/legacy/v1/file/{fileId}?onBehalfOfConsumer={file.Recipients[0]}");
var fileData = await getResponse.Content.ReadAsAsync<LegacyFileOverviewExt>();
var fileData = await getResponse.Content.ReadFromJsonAsync<LegacyFileOverviewExt>(_responseSerializerOptions);

// Assert
Assert.Equal(System.Net.HttpStatusCode.OK, getResponse.StatusCode);
Assert.NotNull(fileData);
Assert.Equal(fileId, fileData.FileId.ToString());
}

Expand Down Expand Up @@ -339,10 +342,11 @@ public async Task GetFileOverview_2FilesInitiated_1Published_StandardRequestRetr
+ $"&resourceId={file.ResourceId}"
+ $"&onBehalfOfConsumer={file.Recipients[0]}");
string s = await getResponse.Content.ReadAsStringAsync();
List<Guid> fileData = await getResponse.Content.ReadAsAsync<List<Guid>>();
var fileData = await getResponse.Content.ReadFromJsonAsync<List<Guid>>(_responseSerializerOptions);

// Assert
Assert.Equal(System.Net.HttpStatusCode.OK, getResponse.StatusCode);
Assert.NotNull(fileData);
Assert.Contains(fileData, g => g == Guid.Parse(fileId1));
Assert.DoesNotContain(fileData, g => g == Guid.Parse(fileId2));
}
Expand Down Expand Up @@ -413,7 +417,7 @@ public async Task Download_ConfirmDownloaded_Success()
// Act
var getResponse = await _legacyClient.PostAsync($"broker/api/legacy/v1/file/{fileId}/confirmdownload?onBehalfOfConsumer={file.Recipients[0]}", null);
var statusResponse = await _legacyClient.GetAsync($"broker/api/legacy/v1/file/{fileId}?onBehalfOfConsumer={file.Recipients[0]}");
var result = await statusResponse.Content.ReadAsAsync<LegacyFileOverviewExt>();
var result = await statusResponse.Content.ReadFromJsonAsync<LegacyFileOverviewExt>(_responseSerializerOptions);

Assert.Equal(HttpStatusCode.OK, getResponse.StatusCode);
Assert.Equal(HttpStatusCode.OK, statusResponse.StatusCode);
Expand Down
2 changes: 1 addition & 1 deletion Test/Altinn.Broker.Tests/ServiceOwnerControllerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ public ServiceOwnerControllerTests(CustomWebApplicationFactory factory)
public async Task Get_ServiceOwner()
{
var response = await _serviceOwnerClient.GetFromJsonAsync<ServiceOwnerOverviewExt>($"broker/api/v1/serviceowner", _responseSerializerOptions);
Assert.Equal("Digitaliseringsdirektoratet Avd Oslo", response.Name);
Assert.Equal("Digitaliseringsdirektoratet Avd Oslo", response!.Name);
}
}
3 changes: 1 addition & 2 deletions src/Altinn.Broker.API/Altinn.Broker.API.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
<PackageReference Include="Azure.Extensions.AspNetCore.Configuration.Secrets" Version="1.3.1" />
<PackageReference Include="Hangfire.AspNetCore" Version="1.8.12" />
<PackageReference Include="Hangfire.MemoryStorage" Version="1.8.1.1" />
<PackageReference Include="Hangfire.PostgreSql" Version="1.20.8" />
<PackageReference Include="Microsoft.AspNet.WebApi.Core" Version="5.3.0" />
<PackageReference Include="Hangfire.PostgreSql" Version="1.20.8" />
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.22.0" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.22.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.5" />
Expand Down
Loading
Loading