-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* updated tests * form data for another app
- Loading branch information
1 parent
fe4d456
commit dfa0ea4
Showing
22 changed files
with
370 additions
and
252 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import http from "k6/http"; | ||
import * as config from "../../config.js"; | ||
import * as header from "../../buildrequestheaders.js" | ||
|
||
//Api call to App Api:Texts to get app texts based on language | ||
export function getAppTexts(altinnStudioRuntimeCookie, appOwner, appName, language){ | ||
var endpoint = config.appApiBaseUrl(appOwner, appName) + config.appResources["texts"] + language, | ||
var params = header.buildHearderWithRuntime(altinnStudioRuntimeCookie, "app"); | ||
return http.get(endpoint, params); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0"?> | ||
<Skjema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" skjemanummer="1472" spesifikasjonsnummer="9812" blankettnummer="AFP-01" tittel="Arbeidsgiverskjema AFP" gruppeid="8818"> | ||
<OpplysningerOmArbeidstakeren-grp-8819 gruppeid="8819"> | ||
<Skjemainstans-grp-8854 gruppeid="8854"> | ||
<Journalnummer-datadef-33316 orid="33316">98274</Journalnummer-datadef-33316> | ||
</Skjemainstans-grp-8854> | ||
</OpplysningerOmArbeidstakeren-grp-8819> | ||
</Skjema> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
/* | ||
Create and archive instances of T3.0 apps with attachment component and simulate all the api calls from portal | ||
example: k6 run -i 20 --duration 1m /src/tests/app/portalsimulation.js -e env=test -e org=ttd -e level2app=apps-test -e subskey=*** -e sblaccesskey=*** -e username=*** -e userpwd=*** | ||
*/ | ||
|
||
import { check } from "k6"; | ||
import {addErrorCount, printResponseToConsole} from "../../errorcounter.js"; | ||
import * as appInstances from "../../api/app/instances.js" | ||
import * as appData from "../../api/app/data.js" | ||
import * as appProcess from "../../api/app/process.js" | ||
import * as platformInstances from "../../api/storage/instances.js" | ||
import * as platformApps from "../../api/storage/applications.js" | ||
import * as setUpData from "../../setup.js"; | ||
import * as appInstantiation from "../../api/app/instantiation.js" | ||
import * as appResources from "../../api/app/resources.js" | ||
|
||
const userName = __ENV.username; | ||
const userPassword = __ENV.userpwd; | ||
const appOwner = __ENV.org; | ||
const level2App = __ENV.level2app; | ||
|
||
let instanceFormDataXml = open("../../data/"+ level2App +".xml"); | ||
let pdfAttachment = open("../../data/test_file_pdf.pdf", "b"); | ||
|
||
export const options = { | ||
thresholds:{ | ||
"errors": ["count<1"] | ||
}, | ||
setupTimeout: '1m' | ||
}; | ||
|
||
//Function to setup data and return AltinnstudioRuntime Token | ||
export function setup(){ | ||
var aspxauthCookie = setUpData.authenticateUser(userName, userPassword); | ||
var altinnStudioRuntimeCookie = setUpData.getAltinnStudioRuntimeToken(aspxauthCookie); | ||
var data = setUpData.getUserData(altinnStudioRuntimeCookie, appOwner, level2App); | ||
data.RuntimeToken = altinnStudioRuntimeCookie; | ||
setUpData.clearCookies(); | ||
return data; | ||
}; | ||
|
||
//Tests for App API : Portal simulation | ||
export default function(data) { | ||
const runtimeToken = data["RuntimeToken"]; | ||
const partyId = data["partyId"]; | ||
var instanceId, dataId, res, success, attachmentDataType; | ||
|
||
//Batch api calls before creating an app instance | ||
res = appInstantiation.beforeInstanceCreation(runtimeToken, partyId, appOwner, level2App); | ||
for(var i = 0; i < res.length; i++){ | ||
success = check(res[i], { | ||
"Batch request before app Instantiation:": (r) => r.status === 200 | ||
}); | ||
addErrorCount(success); | ||
printResponseToConsole("Batch request before app Instantiation:", success, res[i]); | ||
}; | ||
|
||
attachmentDataType = platformApps.findAttachmentDataType(res[2].body); | ||
|
||
//Test to create an instance with App api and validate the response | ||
res = appInstances.postInstance(runtimeToken, partyId, appOwner, level2App); | ||
success = check(res, { | ||
"E2E App POST Create Instance status is 201:": (r) => r.status === 201 | ||
}); | ||
addErrorCount(success); | ||
printResponseToConsole("E2E App POST Create Instance:", success, res); | ||
|
||
try { | ||
dataId = appData.findDataId(res.body); | ||
instanceId = platformInstances.findInstanceId(res.body); | ||
} catch (error) { | ||
printResponseToConsole("Instance id and data id not retrieved:", false , null); | ||
}; | ||
|
||
//Test to get the current process of an app instance | ||
res = appProcess.getCurrentProcess(runtimeToken, partyId, instanceId, appOwner, level2App); | ||
success = check(res, { | ||
"Get Current process of instance:": (r) => r.status === 200 | ||
}); | ||
addErrorCount(success); | ||
printResponseToConsole("Get Current process of instance:", success, res); | ||
|
||
//Test to get the form data xml by id | ||
res = appData.getDataById(runtimeToken, partyId, instanceId, dataId, appOwner, level2App); | ||
success = check(res, { | ||
"Get form data XML by id:": (r) => r.status === 200 | ||
}); | ||
addErrorCount(success); | ||
printResponseToConsole("Get form data XML by id:", success, res); | ||
|
||
//Batch request to get the app resources | ||
res = appResources.batchGetAppResources(runtimeToken, appOwner, level2App); | ||
for(var i = 0; i < res.length; i++){ | ||
success = check(res[i], { | ||
"Batch request to get app resources:": (r) => r.status === 200 | ||
}); | ||
addErrorCount(success); | ||
printResponseToConsole("Batch request to get app resources:", success, res[i]); | ||
}; | ||
|
||
//Test to edit a form data in an instance with App APi and validate the response | ||
|
||
res = appData.putDataById(runtimeToken, partyId, instanceId, dataId, "default", instanceFormDataXml, appOwner, level2App); | ||
success = check(res, { | ||
"E2E PUT Edit Data by Id status is 201:": (r) => r.status === 201 | ||
}); | ||
addErrorCount(success); | ||
printResponseToConsole("E2E PUT Edit Data by Id:", success, res); | ||
|
||
//upload a valid attachment to an instance with App API | ||
res = appData.postData(runtimeToken, partyId, instanceId, attachmentDataType, pdfAttachment, appOwner, level2App); | ||
success = check(res, { | ||
"E2E POST Upload Data status is 201:": (r) => r.status === 201 | ||
}); | ||
addErrorCount(success); | ||
printResponseToConsole("E2E POST Upload Data:", success, res); | ||
|
||
//Test to get validate instance and verify that validation of instance is ok | ||
res = appInstances.getValidateInstance(runtimeToken, partyId, instanceId, appOwner, level2App); | ||
success = check(res, { | ||
"E2E App GET Validate Instance validation OK:": (r) => r.body && (JSON.parse(r.body)).length === 0 | ||
}); | ||
addErrorCount(success); | ||
printResponseToConsole("E2E App GET Validate Instance is not OK:", success, res); | ||
|
||
//Test to move the process of an app instance to the next process element and verify response code to be 200 | ||
res = appProcess.putNextProcess(runtimeToken, partyId, instanceId, "EndEvent_1", appOwner, level2App); | ||
success = check(res, { | ||
"E2E App PUT Move process to Next element status is 200:": (r) => r.status === 200 | ||
}); | ||
addErrorCount(success); | ||
printResponseToConsole("E2E App PUT Move process to Next element:", success, res); | ||
|
||
//Test to call get instance details and verify the presence of archived date | ||
res = appInstances.getInstanceById(runtimeToken, partyId, instanceId, appOwner, level2App); | ||
success = check(res, { | ||
"E2E App Instance is archived:": (r) => r.body.length > 0 && (JSON.parse(r.body)).status.archived != null | ||
}); | ||
addErrorCount(success); | ||
printResponseToConsole("E2E App Instance is not archived:", success, res); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.