Skip to content

Conversation

@andreasisnes
Copy link
Collaborator

@andreasisnes andreasisnes commented Jan 7, 2026

API tests

  • add some controller tests for client delegation.

Test setup

  • One API server is created per fixture. Thus all tests in one class reuse the same server.
  • Use func EnsureSeedOnce in class test ctor to seed data once for all tests in that class.
  • The fixture Ensures that first database that is created gets migrated and is used a template database. All databases that are then created is from that template
  • Be careful to seed data in a specific test as these data will bleed into other tests in that class.
  • Appsettings or services can be adjusted in class ctor.
  • If you need different data for different tests or appsettings, make two classes.
  • Added basic static for test entities TestEntities.cs. For these to be seeded to db func TestDataSeeds.cs must be updated.
  • Added in memory implementation for token validation.

Verification

  • Your code builds clean without any errors or warnings
  • Manual testing done (required)
  • Relevant automated test added (if you find this hard, leave it and we'll help out)
  • All tests run green

Documentation

  • User documentation is updated with a separate linked PR in altinn-studio-docs. (if applicable)

@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 8, 2026

Quality Gate Passed Quality Gate passed for 'Authorization Altinn.Authorization.Api.Contracts'

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

@andreasisnes andreasisnes merged commit 619e798 into main Jan 8, 2026
10 of 12 checks passed
@andreasisnes andreasisnes deleted the issues/1885-tests branch January 8, 2026 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants