Skip to content

Commit

Permalink
chore(webAPI): Added tests for optional EndUserId param on ServiceOwn…
Browse files Browse the repository at this point in the history
…er Get endpoints (#1240)

<!--- Provide a general summary of your changes in the Title above -->

## Description

<!--- Describe your changes in detail -->

## Related Issue(s)

- #515 

## Verification

- [x] **Your** code builds clean without any errors or warnings
- [x] Manual testing done (required)
- [ ] Relevant automated test added (if you find this hard, leave it and
we'll help out)

## Documentation

- [ ] Documentation is updated (either in `docs`-directory, Altinnpedia
or a separate linked PR in
[altinn-studio-docs.](https://github.com/Altinn/altinn-studio-docs), if
applicable)


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Added new test cases for dialog creation and retrieval, including
scenarios for valid and invalid `endUserId`.
- Enhanced dialog search functionality with filtering based on
`endUserId` and service resource.

- **Bug Fixes**
- Improved validation of response status and structure in dialog-related
tests.

- **Tests**
- Expanded test coverage for dialog creation, retrieval, patching, and
purging scenarios, ensuring comprehensive testing of dialog
functionalities.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Ole Jørgen Skogstad <skogstad@softis.net>
  • Loading branch information
knuhau and oskogstad authored Oct 7, 2024
1 parent 142e596 commit 4c43e2f
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 1 deletion.
2 changes: 2 additions & 0 deletions tests/k6/tests/serviceowner/all-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { default as dialogCreateInvalidActionCount } from './dialogCreateInvalid
import { default as dialogCreateInvalidProcess } from './dialogCreateInvalidProcess.js';
import { default as dialogCreatePatchDelete } from './dialogCreatePatchDelete.js';
import { default as dialogCreateUpdatePatchDeleteCorrespondenceResource } from './dialogCreateUpdatePatchDeleteCorrespondenceResource.js';
import { default as dialogDetails } from './dialogDetails.js';
import { default as dialogSearch } from './dialogSearch.js';
import { default as dialogUpdateActivity } from './dialogUpdateActivity.js';

Expand All @@ -21,6 +22,7 @@ export default function() {
dialogCreateInvalidProcess();
dialogCreatePatchDelete();
dialogCreateUpdatePatchDeleteCorrespondenceResource();
dialogDetails();
dialogSearch();
dialogUpdateActivity();
}
36 changes: 36 additions & 0 deletions tests/k6/tests/serviceowner/dialogDetails.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import {
describe,
expect,
expectStatusFor,
getSO,
postSO
} from '../../common/testimports.js'
import {default as dialogToInsert} from './testdata/01-create-dialog.js';
import { getDefaultEnduserSsn } from "../../common/token.js";

export default function () {

let dialogId = null;
let endUserId = "urn:altinn:person:identifier-no:" + getDefaultEnduserSsn();
let invalidEndUserId = "urn:altinn:person:identifier-no:08895699684";

describe('Perform dialog create', () => {
let r = postSO('dialogs', dialogToInsert());
expectStatusFor(r).to.equal(201);
expect(r, 'response').to.have.validJsonBody();

dialogId = r.json();
});

describe('Perform dialog get with endUserId', () => {
let r = getSO('dialogs/' + dialogId + '?endUserId=' + endUserId);
expectStatusFor(r).to.equal(200);
expect(r, 'response').to.have.validJsonBody();
expect(r.json(), 'dialog').to.have.property("id").to.equal(dialogId);
});

describe('Perform dialog get with invalid endUserId', () => {
let r = getSO('dialogs/' + dialogId + '?endUserId=' + invalidEndUserId);
expectStatusFor(r).to.equal(404);
});
}
20 changes: 19 additions & 1 deletion tests/k6/tests/serviceowner/dialogSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {

import { default as dialogToInsert } from './testdata/01-create-dialog.js';

import { getDefaultEnduserOrgNo } from "../../common/token.js";
import { getDefaultEnduserOrgNo, getDefaultEnduserSsn } from "../../common/token.js";

export default function () {

Expand All @@ -37,6 +37,7 @@ export default function () {
let senderNameToSearchFor = uuidv4()
let auxParty = "urn:altinn:organization:identifier-no:" + getDefaultEnduserOrgNo();
let auxResource = "urn:altinn:resource:ttd-dialogporten-automated-tests-2"; // This must exist in Resource Registry
let endUserId = "urn:altinn:person:identifier-no:" + getDefaultEnduserSsn();
let titleForDueAtItem = uuidv4();
let titleForExpiresAtItem = uuidv4();
let titleForVisibleFromItem = uuidv4();
Expand Down Expand Up @@ -191,6 +192,23 @@ export default function () {
expect(r.json(), 'response json').to.have.property("items").with.lengthOf(1);
expect(r.json().items[0], 'process').to.have.property("process").that.equals(processToSeachFor);
})

describe('List with enduserid', () => {
let r = getSO('dialogs/?CreatedAfter=' + createdAfter + '&EndUserId=' + endUserId + '&ServiceResource=' + auxResource);
expectStatusFor(r).to.equal(200);
expect(r, 'response').to.have.validJsonBody();
expect(r.json(), 'response json').to.have.property("items").with.lengthOf(1);
expect(r.json().items[0], 'party').to.have.property("serviceResource").that.equals(auxResource);
})

describe('List with invalid enduserid', () => {
let invalidEndUserId = "urn:altinn:person:identifier-no:08895699684";
let r = getSO('dialogs/?CreatedAfter=' + createdAfter + '&EndUserId=' + invalidEndUserId + '&ServiceResource=' + auxResource);
expectStatusFor(r).to.equal(200);
expect(r, 'response').to.have.validJsonBody();
expect(r.json(), 'response json').not.to.have.property("items");
})

describe("Cleanup", () => {
dialogIds.forEach((d) => {
let r = purgeSO("dialogs/" + d);
Expand Down

0 comments on commit 4c43e2f

Please sign in to comment.