-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: automaattitestin sisäänkirjautuminen (#100)
- Loading branch information
1 parent
c51b84d
commit 1834f8d
Showing
10 changed files
with
175 additions
and
60 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
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,60 @@ | ||
/* tslint:disable:no-console */ | ||
// This script examines stack outputs and parameter store parameters, and writes .env.local and .env.test files | ||
|
||
import { BaseConfig } from "../../common/BaseConfig"; | ||
import * as fs from "fs"; | ||
import { HassuSSMParameters, readParametersByPath, readParametersForEnv, Region } from "./setupEnvironment"; | ||
|
||
function writePyEnvFile(fileName: string, variables: { [p: string]: string }) { | ||
let envFile = "import os\n# This file is automatically generated\n"; | ||
for (const key in variables) { | ||
if (variables.hasOwnProperty(key) && variables[key]) { | ||
envFile += `${key} = "${variables[key]}"\n`; | ||
} | ||
} | ||
envFile += 'if os.getenv("DOCKER") == "false":\n' + " SERVER = NO_DOCKER_SERVER\n"; | ||
|
||
fs.writeFileSync(fileName, envFile); | ||
} | ||
|
||
async function main() { | ||
const variables = await readParametersForEnv<HassuSSMParameters>(BaseConfig.infraEnvironment, Region.EU_WEST_1); | ||
|
||
const robotVariables: any = {}; | ||
|
||
if (BaseConfig.isPermanentEnvironment()) { | ||
robotVariables.SERVER = | ||
"https://" + | ||
variables.basicAuthenticationUsername + | ||
":" + | ||
variables.basicAuthenticationPassword + | ||
"@" + | ||
variables.FrontendDomainName; | ||
robotVariables.NO_DOCKER_SERVER = robotVariables.SERVER; | ||
robotVariables.LOCAL_SERVER = "false"; | ||
} else { | ||
// For local testing | ||
robotVariables.SERVER = "http://host.docker.internal:3000"; | ||
robotVariables.NO_DOCKER_SERVER = "http://localhost:3000"; | ||
robotVariables.LOCAL_SERVER = "true"; | ||
} | ||
|
||
const testUsers = await readParametersByPath("/testusers/", Region.EU_WEST_1); | ||
for (const user in testUsers) { | ||
if (testUsers.hasOwnProperty(user)) { | ||
const [username, password, roles] = testUsers[user].split(" "); | ||
robotVariables[`${user}_USERNAME`] = username; | ||
robotVariables[`${user}_PASSWORD`] = password; | ||
robotVariables[`${user}_ROLES`] = roles || "Atunnukset,hassu_admin"; | ||
} | ||
} | ||
|
||
writePyEnvFile("robotenv.py", robotVariables); | ||
} | ||
|
||
main().catch((e) => { | ||
console.log(e); | ||
process.exit(1); | ||
}); | ||
// "Atunnukset", | ||
// "hassu_admin" |
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,29 @@ | ||
*** Settings *** | ||
Resource ../lib/setup.robot | ||
|
||
Suite Setup Avaa selain | ||
|
||
Test Teardown Run Keyword If Test Failed Capture Page Screenshot | ||
|
||
Suite Teardown Sulje selain | ||
|
||
*** Variables *** | ||
|
||
*** Test Cases *** | ||
Kirjaudu yllapitoon | ||
Kirjaudu yllapitoon kayttajana A1 | ||
|
||
*** Keywords *** | ||
Kirjaudu yllapitoon kayttajana ${username} | ||
IF "${LOCAL_SERVER}"=="true" | ||
${URL} Set Variable ${SERVER}/yllapito?x-hassudev-uid=${${username}_USERNAME}&x-hassudev-roles=${${username}_ROLES} | ||
Log "Avaa selain ${URL}" | ||
GoTo ${URL} | ||
ELSE | ||
${URL} Set Variable ${SERVER}/yllapito/kirjaudu | ||
GoTo ${URL} | ||
Input Text id=username text=${${username}_USERNAME} | ||
Input Text id=password text=${${username}_PASSWORD} | ||
Click Button css=.submit | ||
END | ||
Wait Until Element Is Visible xpath=//a[@href='/yllapito/perusta'] |
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,14 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
# Run an individual test suite if the TEST_SUITE environmental variable is set. | ||
if [ -z "$TEST_SUITE" ]; then | ||
TEST_SUITE="" | ||
fi | ||
|
||
export DOCKER=false | ||
CMD="robot --console verbose --outputdir ./test/.report ./test/suites/$TEST_SUITE" | ||
|
||
echo ${CMD} | ||
|
||
``${CMD}`` |