From e0218a08c813644cf53073540b7ff76f544e5b32 Mon Sep 17 00:00:00 2001 From: Aleksandr Shmaraiev Date: Wed, 27 Dec 2023 14:26:23 +0200 Subject: [PATCH] Add new components to implement 'git-oauth-setup-flow' test --- .ci/openshift-ci/ca.crt | 19 ++++ .ci/openshift-ci/oauth-secret.yaml | 15 ++++ .ci/openshift-ci/pod-oauth-factory-test.yaml | 89 +++++++++++++++++++ .../test-gitlab-with-oauth-setup-flow.sh | 37 ++++++++ 4 files changed, 160 insertions(+) create mode 100644 .ci/openshift-ci/ca.crt create mode 100644 .ci/openshift-ci/oauth-secret.yaml create mode 100644 .ci/openshift-ci/pod-oauth-factory-test.yaml create mode 100644 .ci/openshift-ci/test-gitlab-with-oauth-setup-flow.sh diff --git a/.ci/openshift-ci/ca.crt b/.ci/openshift-ci/ca.crt new file mode 100644 index 0000000000..66dfa1513c --- /dev/null +++ b/.ci/openshift-ci/ca.crt @@ -0,0 +1,19 @@ +-----BEGIN CERTIFICATE----- +MIIDDDCCAfSgAwIBAgIBATANBgkqhkiG9w0BAQsFADAmMSQwIgYDVQQDDBtpbmdy +ZXNzLW9wZXJhdG9yQDE3MDI5MTczMzkwHhcNMjMxMjE4MTYzNTM4WhcNMjUxMjE3 +MTYzNTM5WjAmMSQwIgYDVQQDDBtpbmdyZXNzLW9wZXJhdG9yQDE3MDI5MTczMzkw +ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDDVfcIyqKLYcrmieDOCvAq +RKFR0PXqjl54DyfhkP7TC/rA4WMaJgYamYNNRcy4rOb+i3P1yepeVlXj+4gka41W +fh1QghqDGPpQTF7I8SDhnz3qdQymgSSkrxBWOGgJZRG3Gd50CNeh+ADdNlOxzZhJ +c1HI9/36Zp0M7RHLNwrYzKf/Scrcl3t/Ps4KHKsNtjNygnPSTjGwza5TTTAvGQ+h +3+c+bKJHZp6VFoEpubmBfCG8x+vJwBNI+YauXwti9EqFutnAbOiQ4aOvqQYINngV +OQTOg3xnifnooaR2iZPOtxPLUDMydHP9sDVNGLICpnKcFN6x5JKq1fAuwOAMRMQr +AgMBAAGjRTBDMA4GA1UdDwEB/wQEAwICpDASBgNVHRMBAf8ECDAGAQH/AgEAMB0G +A1UdDgQWBBRQfZkM6C20GT1YiTiS694vRPP2MDANBgkqhkiG9w0BAQsFAAOCAQEA +qd9ug2Bo2s3CG0qjNtk19WYYAuwkEMZU9L/FbSfmPkkOTbrZB71ofZbVan8Dx9/W +SfbkN1eJQNxd7QIDlExKEW2ufJIMCDe6haLHV8x+z3fISHg3wMUCPtadLG/exafy +agfj8PQgnJ1sbA/fKl0rqcVYuIihZ0DdMe28Yj92BFcs5+TXzVYzjyeIGonUZrCR +LtW2CxV7Ngue9pkWGsqQSlRwzp3knYfZxeQLneZcGlsSV4r9LOKIAA/MhBGgpwVc +zrh7L93jajHD1AD0sRdUQp4VVhysXVmMMSAjaLkqHsvSyJp7yKJOmrts6a274qbU +J1E6cXqtfF0NwRo2D9BouQ== +-----END CERTIFICATE----- diff --git a/.ci/openshift-ci/oauth-secret.yaml b/.ci/openshift-ci/oauth-secret.yaml new file mode 100644 index 0000000000..f00f9c6cdf --- /dev/null +++ b/.ci/openshift-ci/oauth-secret.yaml @@ -0,0 +1,15 @@ +kind: Secret +apiVersion: v1 +metadata: + name: gitlab-oauth-secret + namespace: eclipse-che + labels: + app.kubernetes.io/part-of: che.eclipse.org + app.kubernetes.io/component: oauth-scm-configuration + annotations: + che.eclipse.org/oauth-scm-server: gitlab + che.eclipse.org/scm-server-endpoint: git-provider-url +type: Opaque +data: + id: encoded-application-id + secret: encoded-application-secret diff --git a/.ci/openshift-ci/pod-oauth-factory-test.yaml b/.ci/openshift-ci/pod-oauth-factory-test.yaml new file mode 100644 index 0000000000..aeb0b380cd --- /dev/null +++ b/.ci/openshift-ci/pod-oauth-factory-test.yaml @@ -0,0 +1,89 @@ +apiVersion: v1 +kind: Pod +metadata: + name: oauth-factory-test + namespace: CHE-NAMESPACE +spec: + volumes: + - name: test-run-results + - name: ffmpeg-video + - name: dshm + emptyDir: + medium: Memory + containers: + # container containing the tests + - name: oauth-test + image: quay.io/eclipse/che-e2e:next + imagePullPolicy: Always + env: + - name: VIDEO_RECORDING + value: "true" + - name: TEST_SUITE + value: "test" + - name: TS_SELENIUM_EDITOR + value: "che-code" + - name: USERSTORY + value: "Factory" + - name: NODE_TLS_REJECT_UNAUTHORIZED + value: "0" + - name: TS_SELENIUM_BASE_URL + value: "CHE_URL" + - name: TS_SELENIUM_LOG_LEVEL + value: "TRACE" + - name: TS_SELENIUM_OCP_USERNAME + value: "OCP_USER_NAME" + - name: TS_SELENIUM_OCP_PASSWORD + value: "OCP_USER_PASSWORD" + - name: TS_SELENIUM_VALUE_OPENSHIFT_OAUTH + value: "true" + - name: TS_SELENIUM_FACTORY_GIT_REPO_URL + value: "FACTORY_REPO_URL" + - name: TS_SELENIUM_FACTORY_GIT_REPO_BRANCH + value: "GIT_BRANCH" + - name: TS_SELENIUM_FACTORY_GIT_PROVIDER + value: "GIT_PROVIDER_TYPE" + - name: TS_SELENIUM_GIT_PROVIDER_OAUTH + value: "true" + - name: TS_SELENIUM_GIT_PROVIDER_USERNAME + value: "GIT_PROVIDER_USER_NAME" + - name: TS_SELENIUM_GIT_PROVIDER_PASSWORD + value: "GIT_PROVIDER_USER_PASSWORD" + - name: TS_OCP_LOGIN_PAGE_PROVIDER_TITLE + value: "htpasswd" + - name: DELETE_WORKSPACE_ON_FAILED_TEST + value: "true" + - name: TS_SELENIUM_START_WORKSPACE_TIMEOUT + value: "360000" + - name: TS_IDE_LOAD_TIMEOUT + value: "40000" + volumeMounts: + - name: test-run-results + mountPath: /tmp/e2e/report/ + - name: ffmpeg-video + mountPath: /tmp/ffmpeg_report/ + - name: dshm + mountPath: /dev/shm + resources: + requests: + memory: "3Gi" + cpu: "2" + limits: + memory: "4Gi" + cpu: "2" + # Download results + - name: download-reports + image: eeacms/rsync + imagePullPolicy: IfNotPresent + volumeMounts: + - name: test-run-results + mountPath: /tmp/e2e/report/ + - name: ffmpeg-video + mountPath: /tmp/ffmpeg_report/ + resources: + command: ["sh"] + args: + [ + "-c", + "while true; if [[ -f /tmp/done ]]; then exit 0; fi; do sleep 1; done", + ] + restartPolicy: Never diff --git a/.ci/openshift-ci/test-gitlab-with-oauth-setup-flow.sh b/.ci/openshift-ci/test-gitlab-with-oauth-setup-flow.sh new file mode 100644 index 0000000000..dd0b3c3e00 --- /dev/null +++ b/.ci/openshift-ci/test-gitlab-with-oauth-setup-flow.sh @@ -0,0 +1,37 @@ +#!/bin/bash +# +# Copyright (c) 2023 Red Hat, Inc. +# This program and the accompanying materials are made +# available under the terms of the Eclipse Public License 2.0 +# which is available at https://www.eclipse.org/legal/epl-2.0/ +# +# SPDX-License-Identifier: EPL-2.0 +# +# Contributors: +# Red Hat, Inc. - initial API and implementation +# + +# exit immediately when a command fails +set -ex +# only exit with zero if all commands of the pipeline exit successfully +set -o pipefail + +export TEST_POD_NAME=${TEST_POD_NAME:-"oauth-factory-test"} +export GIT_PROVIDER_TYPE=${GIT_PROVIDER_TYPE:-"gitlab"} +export GIT_PROVIDER_URL=${GIT_PROVIDER_URL:-"https://gitlab-gitlab-system.apps.git.crw-qe.com"} +export GIT_PROVIDER_LOGIN=${GIT_PROVIDER_LOGIN:-"admin-user"} +export PRIVATE_REPO_URL=${PRIVATE_REPO_URL:-"https://gitlab-gitlab-system.apps.git.crw-qe.com/admin-user/private-repo.git"} +export GIT_REPO_BRANCH=${PRIVATE_REPO_BRANCH:-"main"} +export APPLICATION_NAME=${APPLICATION_NAME:-"TestApp"} +export OAUTH_ID="" +export APPLICATION_ID="" +export APPLICATION_SECRET="" + +# import common test functions +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +source "${SCRIPT_DIR}"/common.sh + +trap "collectLogs" EXIT SIGINT + +setupTestEnvironmentOAuthFlow ${ADMIN_ACCESS_TOKEN} ${APPLICATION_NAME} ${APPLICATION_ID} ${APPLICATION_SECRET} +startOAuthFactoryTest