Skip to content

Commit

Permalink
Merge branch 'main' into 07-01-subform-query-property-should-be-string
Browse files Browse the repository at this point in the history
  • Loading branch information
JamalAlabdullah authored Jan 10, 2025
2 parents 95e57f7 + d613b39 commit 11be8ba
Show file tree
Hide file tree
Showing 92 changed files with 3,302 additions and 1,384 deletions.
574 changes: 287 additions & 287 deletions .yarn/releases/yarn-4.5.3.cjs → .yarn/releases/yarn-4.6.0.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ enableTelemetry: false

nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-4.5.3.cjs
yarnPath: .yarn/releases/yarn-4.6.0.cjs
12 changes: 6 additions & 6 deletions backend/packagegroups/NuGet.props
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
<PackageReference Update="Microsoft.AspNetCore.SignalR.StackExchangeRedis" Version="9.0.0" />
<PackageReference Update="Microsoft.VisualStudio.Web.BrowserLink" Version="2.2.0" />
<PackageReference Update="Microsoft.AspNetCore.OpenApi" Version="9.0.0" />
<PackageReference Update="HtmlAgilityPack" Version="1.11.71" />
<PackageReference Update="HtmlAgilityPack" Version="1.11.72" />
<PackageReference Update="Microsoft.DiaSymReader.Native" Version="1.7.0" />
<PackageReference Update="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.2" />
<PackageReference Update="Microsoft.EntityFrameworkCore.Tools" Version="9.0.0" />
<PackageReference Update="Microsoft.FeatureManagement.AspNetCore" Version="3.5.0" />
<PackageReference Update="Scrutor" Version="4.2.2" />
<PackageReference Update="Microsoft.FeatureManagement.AspNetCore" Version="4.0.0" />
<PackageReference Update="Scrutor" Version="5.1.1" />
<PackageReference Update="Polly" Version="8.5.0" />
<PackageReference Update="Altinn.Authorization.ABAC" Version="0.0.8" />
<PackageReference Update="Altinn.ApiClients.Maskinporten" Version="9.2.0" />
Expand All @@ -60,17 +60,17 @@
<PackageReference Update="Moq" Version="4.18.4" />
<PackageReference Update="xunit" Version="2.9.2" />
<PackageReference Update="xunit.runner.visualstudio" Version="2.8.2" />
<PackageReference Update="coverlet.collector" Version="6.0.2" />
<PackageReference Update="coverlet.collector" Version="6.0.3" />
<PackageReference Update="Basic.Reference.Assemblies" Version="1.7.8" />
<PackageReference Update="Fare" Version="2.2.1" />
<PackageReference Update="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
<PackageReference Update="Microsoft.CodeAnalysis.CSharp" Version="4.12.0" />
<PackageReference Update="Microsoft.CodeAnalysis.Common" Version="4.12.0" />
<PackageReference Update="Testcontainers" Version="3.10.0" />
<PackageReference Update="Testcontainers" Version="4.1.0" />
<PackageReference Update="Testcontainers.PostgreSql" Version="3.10.0" />
<PackageReference Update="Microsoft.AspNetCore.SignalR.Client" Version="9.0.0" />
<PackageReference Update="Microsoft.Extensions.DependencyModel" Version="9.0.0" />
<PackageReference Update="WireMock.Net" Version="1.6.10" />
<PackageReference Update="WireMock.Net" Version="1.6.11" />
<PackageReference Update="DistributedLock.FileSystem" Version="1.0.3" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ public class AppDevelopmentErrorCodes
{
public const string NonUniqueLayoutSetIdError = "AD_01";
public const string NonUniqueTaskForLayoutSetError = "AD_02";
public const string EmptyLayoutSetIdError = "AD_03";
public const string InvalidLayoutSetIdError = "AD_03";
public const string ConflictingFileNameError = "AD_04";
public const string UploadedImageNotValid = nameof(UploadedImageNotValid);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public override void OnException(ExceptionContext context)
}
if (context.Exception is InvalidLayoutSetIdException)
{
context.Result = new ObjectResult(ProblemDetailsUtils.GenerateProblemDetails(context.Exception, AppDevelopmentErrorCodes.EmptyLayoutSetIdError, HttpStatusCode.BadRequest)) { StatusCode = (int)HttpStatusCode.BadRequest };
context.Result = new ObjectResult(ProblemDetailsUtils.GenerateProblemDetails(context.Exception, AppDevelopmentErrorCodes.InvalidLayoutSetIdError, HttpStatusCode.BadRequest)) { StatusCode = (int)HttpStatusCode.BadRequest };
}
if (context.Exception is ConflictingFileNameException)
{
Expand Down
2 changes: 1 addition & 1 deletion backend/src/Designer/Models/LayoutSets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Altinn.Studio.Designer.Models;
public class LayoutSets : Altinn.App.Core.Models.LayoutSets
{
[JsonPropertyName("$schema")]
public required string Schema { get; set; }
public string? Schema { get; set; }

[JsonPropertyName("sets")]
public new required List<LayoutSetConfig> Sets { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#nullable enable
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#nullable enable
using System.Collections.Generic;
using System.Text.Json.Serialization;
using Altinn.App.Core.Models.Validation;
Expand Down Expand Up @@ -75,7 +76,7 @@ public static ValidationIssueWithSource FromIssue(ValidationIssue issue, string
public required string Source { get; set; }

/// <summary>
/// Weather the issue is from a validator that correctly implements <see cref="IValidator.HasRelevantChanges"/>.
/// Weather the issue is from a validator that correctly implements IValidator.HasRelevantChanges from AppCoreLib/>.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
[JsonPropertyName("noIncrementalUpdates")]
Expand Down Expand Up @@ -104,7 +105,7 @@ public static ValidationIssueWithSource FromIssue(ValidationIssue issue, string
/// <summary>
/// API responses that returns validation issues grouped by source, typically return a list of these.
/// </summary>
/// <param name="Source">The <see cref="IValidator.ValidationSource"/> for the Validator that created theese issues</param>
/// <param name="Source">The source (of type IValidator.ValidationSource in AppCoreLib) for the Validator that created these issues</param>
/// <param name="Issues">List of issues</param>
public record ValidationSourcePair(
[property: JsonPropertyName("source")] string Source,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class AppDevelopmentService : IAppDevelopmentService
{
private readonly IAltinnGitRepositoryFactory _altinnGitRepositoryFactory;
private readonly ISchemaModelService _schemaModelService;
private readonly string _layoutSetNameRegEx = "[a-zA-Z0-9-]{2,28}";
private readonly string _layoutSetNameRegEx = @"^[a-zA-Z0-9_\-]{2,28}$";

/// <summary>
/// Constructor
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text.Json;
Expand Down Expand Up @@ -51,14 +52,15 @@ public async Task<List<Option>> GetOptionsList(string org, string repo, string d
cancellationToken.ThrowIfCancellationRequested();
var altinnAppGitRepository = _altinnGitRepositoryFactory.GetAltinnAppGitRepository(org, repo, developer);

string optionsListString = await altinnAppGitRepository.GetOptionsList(optionsListId, cancellationToken);
var optionsList = JsonSerializer.Deserialize<List<Option>>(optionsListString);
List<Option> optionsList;

string optionsListString = await altinnAppGitRepository.GetOptionsList(optionsListId, cancellationToken);
try
{
optionsList = JsonSerializer.Deserialize<List<Option>>(optionsListString);
optionsList.ForEach(ValidateOption);
}
catch (ValidationException)
catch (Exception ex) when (ex is ValidationException || ex is JsonException)
{
throw new InvalidOptionsFormatException($"One or more of the options have an invalid format in option list: {optionsListId}.");
}
Expand Down
12 changes: 5 additions & 7 deletions backend/src/Designer/Services/Implementation/PreviewService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,16 @@ namespace Altinn.Studio.Designer.Services.Implementation;
/// Constructor
/// </remarks>
/// <param name="altinnGitRepositoryFactory">IAltinnGitRepository</param>
/// <param name="dataService"></param>
public class PreviewService(IAltinnGitRepositoryFactory altinnGitRepositoryFactory) : IPreviewService
{
private readonly IAltinnGitRepositoryFactory _altinnGitRepositoryFactory = altinnGitRepositoryFactory;
public const string MockDataModelIdPrefix = "MockDataModel";
public const string MockDataTaskId = "test-datatask-id";

/// <inheritdoc />
public async Task<Instance> GetMockInstance(string org, string app, string developer, int? instanceOwnerPartyId, string layoutSetName, CancellationToken cancellationToken = default)
{
cancellationToken.ThrowIfCancellationRequested();
AltinnAppGitRepository altinnAppGitRepository = _altinnGitRepositoryFactory.GetAltinnAppGitRepository(org, app, developer);
AltinnAppGitRepository altinnAppGitRepository = altinnGitRepositoryFactory.GetAltinnAppGitRepository(org, app, developer);
Application applicationMetadata = await altinnAppGitRepository.GetApplicationMetadata(cancellationToken);
string task = await GetTaskForLayoutSetName(org, app, developer, layoutSetName, cancellationToken);
bool shouldProcessActAsReceipt = task == Constants.General.CustomReceiptId;
Expand Down Expand Up @@ -69,7 +67,7 @@ public async Task<Instance> GetMockInstance(string org, string app, string devel
public async Task<DataType> GetDataTypeForLayoutSetName(string org, string app, string developer, string layoutSetName, CancellationToken cancellationToken = default)
{
cancellationToken.ThrowIfCancellationRequested();
AltinnAppGitRepository altinnAppGitRepository = _altinnGitRepositoryFactory.GetAltinnAppGitRepository(org, app, developer);
AltinnAppGitRepository altinnAppGitRepository = altinnGitRepositoryFactory.GetAltinnAppGitRepository(org, app, developer);
string task = await GetTaskForLayoutSetName(org, app, developer, layoutSetName, cancellationToken);
Application applicationMetadata = await altinnAppGitRepository.GetApplicationMetadata(cancellationToken);
if (applicationMetadata.DataTypes is { Count: > 0 })
Expand All @@ -84,7 +82,7 @@ public async Task<DataType> GetDataTypeForLayoutSetName(string org, string app,
public async Task<List<string>> GetTasksForAllLayoutSets(string org, string app, string developer, CancellationToken cancellationToken = default)
{
cancellationToken.ThrowIfCancellationRequested();
AltinnAppGitRepository altinnAppGitRepository = _altinnGitRepositoryFactory.GetAltinnAppGitRepository(org, app, developer);
AltinnAppGitRepository altinnAppGitRepository = altinnGitRepositoryFactory.GetAltinnAppGitRepository(org, app, developer);
try
{
LayoutSets layoutSets = await altinnAppGitRepository.GetLayoutSetsFile(cancellationToken);
Expand Down Expand Up @@ -115,7 +113,7 @@ public async Task<List<string>> GetTasksForAllLayoutSets(string org, string app,
public async Task<string> GetTaskForLayoutSetName(string org, string app, string developer, string layoutSetName, CancellationToken cancellationToken = default)
{
cancellationToken.ThrowIfCancellationRequested();
AltinnAppGitRepository altinnAppGitRepository = _altinnGitRepositoryFactory.GetAltinnAppGitRepository(org, app, developer);
AltinnAppGitRepository altinnAppGitRepository = altinnGitRepositoryFactory.GetAltinnAppGitRepository(org, app, developer);
string task = "Task_1";
if (!string.IsNullOrEmpty(layoutSetName))
{
Expand All @@ -127,7 +125,7 @@ public async Task<string> GetTaskForLayoutSetName(string org, string app, string

private async Task<List<DataElement>> GetDataTypesForInstance(string org, string app, string developer, string layoutSetName, bool shouldProcessActAsReceipt)
{
AltinnAppGitRepository altinnAppGitRepository = _altinnGitRepositoryFactory.GetAltinnAppGitRepository(org, app, developer);
AltinnAppGitRepository altinnAppGitRepository = altinnGitRepositoryFactory.GetAltinnAppGitRepository(org, app, developer);
DataType dataType = await GetDataTypeForLayoutSetName(org, app, developer, layoutSetName);
string dataTypeForDataElement = shouldProcessActAsReceipt ? await GetDataTypeForCustomReceipt(altinnAppGitRepository) : dataType?.Id;
ApplicationMetadata applicationMetadata = await altinnAppGitRepository.GetApplicationMetadata();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,26 @@ public async Task UpdateLayoutSet_NewLayoutSetNameIsEmpty_ReturnsBadRequest(stri
response.StatusCode.Should().Be(HttpStatusCode.BadRequest);
}

[Theory]
[InlineData("ttd", "app-with-layoutsets", "testUser", "layoutSet1")]
public async Task UpdateLayoutSet_NewLayoutSetNameDoesNotMatchRegex_ReturnsBadRequest(string org, string app, string developer,
string oldLayoutSetName)
{
string targetRepository = TestDataHelper.GenerateTestRepoName();
await CopyRepositoryForTest(org, app, developer, targetRepository);
string newLayoutSetName = ".abc";

string url = $"{VersionPrefix(org, targetRepository)}/layout-set/{oldLayoutSetName}";

using var httpRequestMessage = new HttpRequestMessage(HttpMethod.Put, url)
{
Content = new StringContent($"\"{newLayoutSetName}\"", Encoding.UTF8, MediaTypeNames.Application.Json)
};

using var response = await HttpClient.SendAsync(httpRequestMessage);
response.StatusCode.Should().Be(HttpStatusCode.BadRequest);
}

[Theory]
[InlineData("ttd", "app-without-layoutsets", "testUser", null)]
public async Task UpdateLayoutSetName_AppWithoutLayoutSets_ReturnsNotFound(string org, string app, string developer,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Net.Http;
using System.Text.Json;
using System.Threading.Tasks;
using Altinn.Studio.Designer.Filters;
using Altinn.Studio.Designer.Models;
using Altinn.Studio.Designer.Models.Dto;
using Designer.Tests.Controllers.ApiTests;
using Designer.Tests.Utils;
using FluentAssertions;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
Expand Down Expand Up @@ -63,8 +65,24 @@ public async Task GetOptionLists_Returns200OK_WithOptionListsData()
{
// Arrange
const string repo = "app-with-options";
string apiUrl = $"/designer/api/ttd/{repo}/options/option-lists";
string targetRepository = TestDataHelper.GenerateTestRepoName();
await CopyRepositoryForTest("ttd", repo, "testUser", targetRepository);
string apiUrl = $"/designer/api/ttd/{targetRepository}/options/option-lists";
using HttpRequestMessage httpRequestMessage = new(HttpMethod.Get, apiUrl);
string optionListMissingValue = @"[{ ""label"": ""someLabel""}]";
string optionListMissingLabel = @"[{ ""value"": ""someValue""}]";
string optionListTrailingComma = @"[{ ""value"": ""someValue"", ""label"": ""someLabel"",}]";
string optionListLabelWithObject = @"[{ ""value"": ""someValue"", ""label"": {}}]";
string optionListLabelWithNumber = @"[{ ""value"": ""someValue"", ""label"": 12345}]";
string optionListLabelWithBool = @"[{ ""value"": ""someValue"", ""label"": true}]";
string repoPath = TestDataHelper.GetTestDataRepositoryDirectory("ttd", targetRepository, "testUser");
string filePath = Path.Combine(repoPath, "App/options");
await File.WriteAllTextAsync(Path.Combine(filePath, "optionListMissingValue.json"), optionListMissingValue);
await File.WriteAllTextAsync(Path.Combine(filePath, "optionListMissingLabel.json"), optionListMissingLabel);
await File.WriteAllTextAsync(Path.Combine(filePath, "optionListTrailingComma.json"), optionListTrailingComma);
await File.WriteAllTextAsync(Path.Combine(filePath, "optionListLabelWithObject.json"), optionListLabelWithObject);
await File.WriteAllTextAsync(Path.Combine(filePath, "optionListLabelWithNumber.json"), optionListLabelWithNumber);
await File.WriteAllTextAsync(Path.Combine(filePath, "optionListLabelWithBool.json"), optionListLabelWithBool);

// Act
using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage);
Expand All @@ -77,7 +95,13 @@ public async Task GetOptionLists_Returns200OK_WithOptionListsData()
{
new () { Title = "options-with-null-fields", Data = null, HasError = true },
new () { Title = "other-options", HasError = false },
new () { Title = "test-options", HasError = false }
new () { Title = "test-options", HasError = false },
new () { Title = "optionListMissingValue", Data = null, HasError = true },
new () { Title = "optionListMissingLabel", Data = null, HasError = true },
new () { Title = "optionListTrailingComma", Data = null, HasError = true },
new () { Title = "optionListLabelWithObject", Data = null, HasError = true },
new () { Title = "optionListLabelWithNumber", Data = null, HasError = true },
new () { Title = "optionListLabelWithBool", Data = null, HasError = true }
}, options => options.Excluding(x => x.Data));
}

Expand Down
4 changes: 2 additions & 2 deletions frontend/app-development/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"i18next": "23.16.8",
"react": "18.3.1",
"react-dom": "18.3.1",
"react-i18next": "15.2.0",
"react-router-dom": "6.28.0"
"react-i18next": "15.4.0",
"react-router-dom": "6.28.1"
},
"devDependencies": {
"cross-env": "7.0.3",
Expand Down
2 changes: 1 addition & 1 deletion frontend/app-preview/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"dependencies": {
"react": "18.3.1",
"react-dom": "18.3.1",
"react-router-dom": "6.28.0"
"react-router-dom": "6.28.1"
},
"devDependencies": {
"cross-env": "7.0.3",
Expand Down
2 changes: 1 addition & 1 deletion frontend/dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"dependencies": {
"react": "18.3.1",
"react-dom": "18.3.1",
"react-router-dom": "6.28.0"
"react-router-dom": "6.28.1"
},
"devDependencies": {
"cross-env": "7.0.3",
Expand Down
Loading

0 comments on commit 11be8ba

Please sign in to comment.