Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frontend-clients
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OZG-Cloud
app
frontend-clients
Commits
b4075e58
Commit
b4075e58
authored
1 year ago
by
OZGCloud
Browse files
Options
Downloads
Patches
Plain Diff
OZG-4653 OZG-4708 read all users from fixtures
parent
16daf10e
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
alfa-client/apps/alfa-e2e/Jenkinsfile
+70
-78
70 additions, 78 deletions
alfa-client/apps/alfa-e2e/Jenkinsfile
alfa-client/apps/alfa-e2e/Jenkinsfile-static
+54
-66
54 additions, 66 deletions
alfa-client/apps/alfa-e2e/Jenkinsfile-static
with
124 additions
and
144 deletions
alfa-client/apps/alfa-e2e/Jenkinsfile
+
70
−
78
View file @
b4075e58
...
...
@@ -219,7 +219,7 @@ pipeline {
forwardServices
(
generateNamespace
(
bezeichner
),
dbPort
)
runTests
(
bezeichner
,
'einheitlicher-ansprechpartner'
,
dbPort
,
env
.
STAGE_NAME
)
runTests
(
bezeichner
,
'einheitlicher-ansprechpartner'
,
'user-ea'
,
dbPort
,
env
.
STAGE_NAME
)
}
}
}
...
...
@@ -246,7 +246,7 @@ pipeline {
forwardServices
(
generateNamespace
(
bezeichner
),
dbPort
)
runTests
(
bezeichner
,
'main-tests'
,
dbPort
,
env
.
STAGE_NAME
)
runTests
(
bezeichner
,
'main-tests'
,
'user-main'
,
dbPort
,
env
.
STAGE_NAME
)
}
}
}
...
...
@@ -452,7 +452,7 @@ Void generateNamespaceYaml(String bezeichner, String valuesPathSuffix, String us
envValues
.
user_manager
.
put
(
"helm"
,
[
'version'
:
env
.
USER_MANAGER_HELM_CHART_VERSION
,
'repoUrl'
:
env
.
USER_MANAGER_HELM_REPO_URL
])
envValues
.
alfa
.
sso
.
put
(
"keycloak_groups"
,
generateKeycloakGroupsForHelmChart
())
envValues
.
alfa
.
sso
.
put
(
"keycloak_users"
,
generateKeycloakUserForHelmChart
(
userFolder
))
envValues
.
alfa
.
sso
.
put
(
"keycloak_users"
,
generateKeycloakUserForHelmChart
(
'alfa-client/apps/alfa-e2e/src/fixtures'
,
userFolder
))
writeYaml
file:
"gitops/dev/namespace/namespaces/by-${bezeichner}-dev.yaml"
,
data:
envValues
,
overwrite:
true
...
...
@@ -464,27 +464,24 @@ Void generateNamespaceYaml(String bezeichner, String valuesPathSuffix, String us
}
}
List
generateKeycloakUserForHelmChart
(
String
userFolder
)
{
def
userFiles
=
sh
(
script:
'ls alfa-client/apps/alfa-e2e/src/fixtures/'
+
userFolder
,
returnStdout:
true
);
List
generateKeycloakUserForHelmChart
(
String
fixturesPath
,
String
userFolder
)
{
def
helmUsers
=
[]
userFiles
.
split
(
"\\n"
).
each
{
userFile
->
def
userJson
=
readJSON
file:
"alfa-client/apps/alfa-e2e/src/fixtures/${userFolder}/${userFile}"
readUsersFixtures
(
fixturesPath
,
userFolder
).
each
{
username
,
userFixture
->
def
user
=
[
"name"
:
userJson
.
name
,
"password"
:
user
Json
.
password
,
"first_name"
:
user
Json
.
get
(
"firstName"
,
""
),
"last_name"
:
user
Json
.
get
(
"lastName"
,
""
),
"email"
:
user
Json
.
get
(
"email"
,
""
)
"name"
:
userFixture
.
name
,
"password"
:
user
Fixture
.
password
,
"first_name"
:
user
Fixture
.
get
(
"firstName"
,
""
),
"last_name"
:
user
Fixture
.
get
(
"lastName"
,
""
),
"email"
:
user
Fixture
.
get
(
"email"
,
""
)
]
if
(
user
Json
.
containsKey
(
"clientRoles"
))
{
user
.
put
(
"client_roles"
,
mapUserClientRoles
(
user
Json
.
clientRoles
))
if
(
user
Fixture
.
containsKey
(
"clientRoles"
))
{
user
.
put
(
"client_roles"
,
mapUserClientRoles
(
user
Fixture
.
clientRoles
))
}
if
(
user
Json
.
containsKey
(
"groups"
))
{
user
.
put
(
"groups"
,
user
Json
.
groups
)
if
(
user
Fixture
.
containsKey
(
"groups"
))
{
user
.
put
(
"groups"
,
user
Fixture
.
groups
)
}
helmUsers
.
add
(
user
)
...
...
@@ -618,8 +615,8 @@ Void publishE2ETestResult(String reportFolder, String reportName) {
)
}
String
runTests
(
String
bezeichner
,
String
reportFolder
,
Integer
dbPort
,
String
stageName
)
{
def
config
=
generateCypressConfig
(
bezeichner
,
reportFolder
,
dbPort
)
String
runTests
(
String
bezeichner
,
String
reportFolder
,
String
userFolder
,
Integer
dbPort
,
String
stageName
)
{
def
config
=
generateCypressConfig
(
bezeichner
,
reportFolder
,
userFolder
,
dbPort
)
try
{
dir
(
'alfa-client'
){
...
...
@@ -661,7 +658,7 @@ String cutBranchNameForKeycloakRealm(String branchName, String stageName) {
return
branchName
.
take
(
cutBranchNamePosition
)
}
String
generateCypressConfig
(
String
bezeichner
,
String
testFolder
,
Integer
dbPort
)
{
String
generateCypressConfig
(
String
bezeichner
,
String
testFolder
,
String
userFolder
,
Integer
dbPort
)
{
def
namespace
=
generateNamespace
(
bezeichner
)
def
configName
=
"cypress-ci-"
+
testFolder
+
".json"
...
...
@@ -676,7 +673,7 @@ String generateCypressConfig(String bezeichner, String testFolder, Integer dbPor
config
.
env
.
dbUrl
=
"mongodb://${decodeString(vorgangManagerDatabaseSecret.username)}:${parsablePassword}@localhost:${dbPort}/admin?ssl=false&directConnection=true"
as
String
config
.
env
.
keycloakUrl
=
"https://${env.SSO_URL}/"
as
String
config
.
env
.
keycloakRealm
=
namespace
as
String
config
.
env
+=
createUserIdsEnv
(
namespace
,
[
"sabine"
,
"dorothea"
,
"emil"
,
"peter"
]
)
config
.
env
+=
createUserIdsEnv
(
'src/fixtures'
,
userFolder
,
namespace
)
config
.
videosFolder
=
"./reports/${testFolder}/videos"
as
String
config
.
screenshotsFolder
=
"./reports/${testFolder}/screenshots"
as
String
config
.
reporterOptions
.
reportDir
=
"./reports/${testFolder}/mochawesome-report"
as
String
...
...
@@ -717,43 +714,38 @@ Map getUserManagerDatabaseSecret(String namespace) {
return
readJSON
(
text:
sh
(
script:
"kubectl get secret ozg-mongodb-admin-user-manager-user -n ${namespace} -o jsonpath={.data}"
,
returnStdout:
true
))
}
Map
createUserIdsEnv
(
realm
,
usernames
)
{
def
env
=
[:]
def
userIds
=
getUserIds
(
realm
,
usernames
)
echo
"userIds: ${userIds}"
for
(
username
in
usernames
)
{
if
(
userIds
[
username
])
{
env
[(
username
+
"Uuid"
)]
=
userIds
[
username
].
id
env
[(
username
+
"InternalId"
)]
=
userIds
[
username
].
ozgCloudUserId
}
else
{
echo
"user ${username} not found in Keycloak"
}
Map
createUserIdsEnv
(
String
fixturesPath
,
String
userFolder
,
realm
)
{
def
keycloakUsers
=
getKeycloakUsers
(
realm
)
def
usersFixtures
=
readUsersFixtures
(
fixturesPath
,
userFolder
)
return
usersFixtures
.
collectEntries
{
username
,
user
->
[(
username
+
"Uuid"
)
:
keycloakUsers
[
username
].
id
,
(
username
+
"InternalId"
):
keycloakUsers
[
username
].
attributes
.
ozgCloudUserId
[
0
]]
}
return
env
}
Map
getUser
Id
s
(
realm
,
usernames
)
{
Map
get
Keycloak
Users
(
realm
)
{
def
shScript
=
"""curl -H 'Content-Type: application/json' \
-H 'Authorization: bearer ${getKeycloakAccessToken(realm)}' \
'https://${env.SSO_URL}/admin/realms/${realm}/users'
"""
def
keycloakUsers
=
readJSON
text:
sh
(
script:
shScript
,
returnStdout:
true
)
def
users
=
readJSON
text:
sh
(
script:
shScript
,
returnStdout:
true
)
echo
"keycloak users: ${keycloakUsers}"
echo
"users: ${users}"
return
users
.
findAll
{
it
.
username
in
usernames
}
.
collectEntries
{
[
(
it
.
username
):
[
"id"
:
it
.
id
,
"ozgCloudUserId"
:
it
.
attributes
.
ozgCloudUserId
[
0
]
]
]
return
keycloakUsers
.
collectEntries
{
[
it
.
username
,
it
]
}
}
Map
readUsersFixtures
(
String
fixturesPath
,
String
userFolder
)
{
def
usersFixturesFiles
=
sh
(
script:
"ls ${fixturesPath}/${userFolder}"
,
returnStdout:
true
);
return
usersFixturesFiles
.
split
(
"\\n"
)
.
collect
{
userFixtureFile
->
def
userFixture
=
readJSON
file:
"${fixturesPath}/${userFolder}/${userFixtureFile}"
return
[
"name"
:
userFixture
.
name
,
"password"
:
userFixture
.
password
,
"first_name"
:
userFixture
.
get
(
"firstName"
,
""
),
"last_name"
:
userFixture
.
get
(
"lastName"
,
""
),
"email"
:
userFixture
.
get
(
"email"
,
""
)]
}.
collectEntries
{
[
it
.
name
,
it
]
}
}
String
getKeycloakAccessToken
(
String
realm
)
{
...
...
This diff is collapsed.
Click to expand it.
alfa-client/apps/alfa-e2e/Jenkinsfile-static
+
54
−
66
View file @
b4075e58
...
...
@@ -192,7 +192,7 @@ pipeline {
forwardServices(generateNamespace(bezeichner), dbPort)
runTests(bezeichner, 'einheitlicher-ansprechpartner', dbPort, env.STAGE_NAME)
runTests(bezeichner, 'einheitlicher-ansprechpartner',
'user-ea',
dbPort, env.STAGE_NAME)
}
}
}
...
...
@@ -222,7 +222,7 @@ pipeline {
forwardServices(generateNamespace(bezeichner), dbPort)
runTests(bezeichner, 'main-tests', dbPort, env.STAGE_NAME)
runTests(bezeichner, 'main-tests',
'user-main',
dbPort, env.STAGE_NAME)
}
}
}
...
...
@@ -327,8 +327,8 @@ Void publishE2ETestResult(String reportFolder, String reportName) {
)
}
String runTests(String bezeichner, String reportFolder, Integer dbPort, String stageName) {
def config = generateCypressConfig(bezeichner, reportFolder, dbPort)
String runTests(String bezeichner, String reportFolder,
String userFolder,
Integer dbPort, String stageName) {
def config = generateCypressConfig(bezeichner, reportFolder,
userFolder,
dbPort)
try {
dir("alfa-client") {
...
...
@@ -370,7 +370,7 @@ String cutBranchNameForKeycloakRealm(String branchName, String stageName) {
return branchName.take(cutBranchNamePosition)
}
String generateCypressConfig(String bezeichner, String testFolder, Integer dbPort) {
String generateCypressConfig(String bezeichner, String testFolder,
String userFolder,
Integer dbPort) {
def namespace = generateNamespace(bezeichner)
def configName = "cypress-ci-" + testFolder + ".json"
...
...
@@ -385,7 +385,7 @@ String generateCypressConfig(String bezeichner, String testFolder, Integer dbPor
config.env.dbUrl = "mongodb://${decodeString(vorgangManagerDatabaseSecret.username)}:${parsablePassword}@localhost:${dbPort}/admin?ssl=false&directConnection=true" as String
config.env.keycloakUrl = "https://${env.SSO_URL}/" as String
config.env.keycloakRealm = namespace as String
config.env += createUserIdsEnv(
namespace, ["sabine", "dorothea", "emil", "peter"]
)
config.env += createUserIdsEnv(
'src/fixtures', userFolder, namespace
)
config.videosFolder = "./reports/${testFolder}/videos" as String
config.screenshotsFolder = "./reports/${testFolder}/screenshots" as String
config.reporterOptions.reportDir = "./reports/${testFolder}/mochawesome-report" as String
...
...
@@ -426,43 +426,38 @@ String makePasswordUrlConform(String password) {
return sh(script: "printf %s ${password} | jq -sRr @uri", returnStdout: true);
}
Map createUserIdsEnv(realm, usernames) {
def env = [:]
def userIds = getUserIds(realm, usernames)
echo "userIds: ${userIds}"
for (username in usernames) {
if (userIds[username]) {
env[(username + "Uuid")] = userIds[username].id
env[(username + "InternalId")] = userIds[username].ozgCloudUserId
} else {
echo "user ${username} not found in Keycloak"
Map createUserIdsEnv(String fixturesPath, String userFolder, realm) {
def keycloakUsers = getKeycloakUsers(realm)
def usersFixtures = readUsersFixtures(fixturesPath, userFolder)
return usersFixtures.collectEntries { username, user ->
[(username + "Uuid") : keycloakUsers[username].id,
(username + "InternalId"): keycloakUsers[username].attributes.ozgCloudUserId[0]]
}
}
return env
}
Map getUser
Id
s(realm
, usernames
) {
Map get
Keycloak
Users(realm) {
def shScript = """curl -H 'Content-Type: application/json' \
-H 'Authorization: bearer ${getKeycloakAccessToken(realm)}' \
'https://${env.SSO_URL}/admin/realms/${realm}/users'
"""
def keycloakUsers = readJSON text: sh(script: shScript, returnStdout: true)
def users = readJSON text: sh(script: shScript, returnStdout: true)
echo "users: ${users}"
echo "keycloak users: ${keycloakUsers}"
return users
.findAll { it.username in usernames }
.collectEntries {
[
(it.username): [
"id" : it.id,
"ozgCloudUserId": it.attributes.ozgCloudUserId[0]
]
]
return keycloakUsers.collectEntries { [it.username, it] }
}
Map readUsersFixtures(String fixturesPath, String userFolder) {
def usersFixturesFiles = sh(script: "ls ${fixturesPath}/${userFolder}", returnStdout: true);
return usersFixturesFiles.split("\\n")
.collect { userFixtureFile ->
def userFixture = readJSON file: "${fixturesPath}/${userFolder}/${userFixtureFile}"
return ["name" : userFixture.name,
"password" : userFixture.password,
"first_name": userFixture.get("firstName", ""),
"last_name" : userFixture.get("lastName", ""),
"email" : userFixture.get("email", "")]
}.collectEntries { [it.name, it] }
}
String getKeycloakAccessToken(String realm) {
...
...
@@ -476,19 +471,15 @@ String getKeycloakAccessToken(String realm) {
Map getUserManagerApiUserCredentials(String namespace) {
def userManagerApiUserCredentials = readJSON(text: sh(script: "kubectl get secret usermanagerapiuser-credentials -n ${namespace} -o jsonpath={.data}", returnStdout: true))
return [
"user": decodeString(userManagerApiUserCredentials.name),
"password": decodeString(userManagerApiUserCredentials.password)
]
return ["user" : decodeString(userManagerApiUserCredentials.name),
"password": decodeString(userManagerApiUserCredentials.password)]
}
Void sendFailureMessage() {
def data = [
"msgtype": "m.text",
def data = ["msgtype" : "m.text",
"body" : "E2E-Tests: Failed stage: ${getFailedStage()} Build-ID: ${env.BUILD_NUMBER} Link: ${BLUE_OCEAN_URL}" as String,
"format" : "org.matrix.custom.html",
"formatted_body": "E2E-Tests: Failed stage: ${getFailedStage()} Build-ID: <a href='${BLUE_OCEAN_URL}'>${env.BUILD_NUMBER}</a>" as String
]
"formatted_body": "E2E-Tests: Failed stage: ${getFailedStage()} Build-ID: <a href='${BLUE_OCEAN_URL}'>${env.BUILD_NUMBER}</a>" as String]
sh "curl -XPOST -H 'authorization: Bearer ${getElementAccessToken()}' -d '${JsonOutput.toJson(data)}' https://matrix.ozg-sh.de/_matrix/client/v3/rooms/${getElementRoomId()}/send/m.room.message"
}
...
...
@@ -521,20 +512,17 @@ String getElementAccessToken() {
Map getElasticsearchEnv(String namespace) {
def elasticsearchSecret = getElasticsearchSecret(namespace)
return [
"user": decodeString(elasticsearchSecret.username),
return ["user" : decodeString(elasticsearchSecret.username),
"password": decodeString(elasticsearchSecret.password),
"index" : decodeString(elasticsearchSecret.index),
"url": "https://localhost:9200"
]
"url" : "https://localhost:9200"]
}
Void forwardServices(String namespace, Integer dbPort) {
try {
forwardDatenbank(namespace, dbPort)
forwardElasticSearch()
}
catch (Exception e) {
} catch (Exception e) {
echo "forwardServices Exception: ${e}"
error("Error forwarding service")
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment