Skip to content

Commit

Permalink
Further improve test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
ivarne committed Nov 7, 2024
1 parent fa15452 commit d71c3d9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
2 changes: 0 additions & 2 deletions src/Altinn.App.Api/Controllers/InstancesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1249,8 +1249,6 @@ string action
_jsonSerializerOptionsWeb
);
}

return null;
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,33 @@ public async Task PostNewInstanceWithInstanceTemplate()
TestData.DeleteInstanceAndData(org, app, instance.Id);
}

[Fact]
public async Task PostNewInstanceWithMissingTemplate()
{
string org = "tdd";
string app = "contributer-restriction";
int instanceOwnerPartyId = 501337;
int userId = 1337;
HttpClient client = GetRootedClient(org, app, userId, null);

using var content = new ByteArrayContent(new byte[0])
{
Headers = { ContentType = new MediaTypeHeaderValue("application/json") }
};

var response = await client.PostAsync(
$"{org}/{app}/instances?instanceOwnerPartyId={instanceOwnerPartyId}",
content
);
response.Should().HaveStatusCode(HttpStatusCode.Created);
var responseContent = await response.Content.ReadAsStringAsync();
var instance = JsonSerializer.Deserialize<Instance>(responseContent, JsonSerializerOptions);
instance.Should().NotBeNull();
instance!.Id.Should().NotBeNullOrEmpty();

TestData.DeleteInstanceAndData(org, app, instance.Id);
}

[Fact]
public async Task InstationAllowedByOrg_Returns_Forbidden_For_User_SimplifiedEndpoint()
{
Expand Down

0 comments on commit d71c3d9

Please sign in to comment.