This is an automated email from the ASF dual-hosted git repository.
srijeet0406 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
The following commit(s) were added to refs/heads/master by this push:
new ff91c6c903 TP/TPv2 tests: Get admin role ID from the database (#7328)
ff91c6c903 is described below
commit ff91c6c90375a6d01c690ce4b17edf5b92b50dce
Author: Zach Hoffman <[email protected]>
AuthorDate: Thu Feb 2 09:13:39 2023 -0700
TP/TPv2 tests: Get admin role ID from the database (#7328)
* TP/TPv2 tests: Get admin role ID from the database
* Get tenant_id from the database
Also, use subqueries to get these values
---
.github/actions/tp-integration-tests/entrypoint.sh | 14 ++++++++---
.github/workflows/tpv2.yml | 28 +++++++++++++++++++---
2 files changed, 36 insertions(+), 6 deletions(-)
diff --git a/.github/actions/tp-integration-tests/entrypoint.sh
b/.github/actions/tp-integration-tests/entrypoint.sh
index ab3c211b15..82e0706c7c 100755
--- a/.github/actions/tp-integration-tests/entrypoint.sh
+++ b/.github/actions/tp-integration-tests/entrypoint.sh
@@ -54,13 +54,21 @@ export PGPORT="5432"
to_admin_username="$(jq -r '.params.login.username'
"${GITHUB_WORKSPACE}/traffic_portal/test/integration/config.json")"
to_admin_password="$(jq -r '.params.login.password'
"${GITHUB_WORKSPACE}/traffic_portal/test/integration/config.json")"
password_hash="$(<<PYTHON_COMMANDS
PYTHONPATH="${GITHUB_WORKSPACE}/traffic_ops/install/bin" python
-import _postinstall
-print(_postinstall.hash_pass('${to_admin_password}'))
+from _postinstall import hash_pass
+print(hash_pass('${to_admin_password}'))
PYTHON_COMMANDS
)"
<<QUERY psql
INSERT INTO tm_user (username, role, tenant_id, local_passwd)
- VALUES ('${to_admin_username}', 1, 1,
+ VALUES ('${to_admin_username}', (
+ SELECT id
+ FROM "role"
+ WHERE "name" = 'admin'
+ ), (
+ SELECT id
+ FROM tenant
+ WHERE "name" = 'root'
+ ),
'${password_hash}'
);
QUERY
diff --git a/.github/workflows/tpv2.yml b/.github/workflows/tpv2.yml
index 2c4f6d632b..0b62bc0706 100644
--- a/.github/workflows/tpv2.yml
+++ b/.github/workflows/tpv2.yml
@@ -212,12 +212,34 @@ jobs:
# Setup
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install postgresql-client
gettext-base
+ - name: Hash TO user password
+ env:
+ PYTHONPATH: traffic_ops/install/bin
+ run: |2
+ password_hash="$(<<PYTHON_COMMANDS python
+ from _postinstall import hash_pass
+ print(hash_pass('${{ env.PGPASSWORD }}12'))
+ PYTHON_COMMANDS
+ )" &&
+ echo "TO_USER_PASSWORD_HASH=${password_hash}" >> '${{ github.env }}'
- name: Create admin user
- run: |
- psql -c "INSERT INTO tm_user (username, role, tenant_id,
local_passwd) VALUES ('admin', 1, 1,
'SCRYPT:16384:8:1:p0Bppp/6IBeYxSwdLuYddsdMLBU/BNSlLY6fSIF7H1XW4eTbNVeMPVm7TuTEG4FM8PbqLlVwi8sPy8ZJznAlaQ==:sRcHWGe43mm/uEmXTIw37GcLEQZTlWAdf4vJqK8f0MDh8P+8gXoNx+nxWyb3r/0Bh+yyg0g/dUvti/ePZJL+Jw==');"
+ run: |2
+ <<QUERY psql
+ INSERT INTO tm_user (username, role, tenant_id, local_passwd)
+ VALUES ('admin', (
+ SELECT id
+ FROM "role"
+ WHERE "name" = 'admin'
+ ), (
+ SELECT id
+ FROM tenant
+ WHERE "name" = 'root'
+ ), '${{ env.TO_USER_PASSWORD_HASH }}');
+ QUERY
- name: Create SSL Certificates and AES key
run: |
- openssl rand 32 | base64 | tee "${GITHUB_WORKSPACE}/aes.key"
+ set -o pipefail
+ openssl rand 32 | base64 | tee "${GITHUB_WORKSPACE}/aes.key" &&
openssl req -new -x509 -nodes -newkey rsa:4096 -out
traffic_ops/traffic_ops_golang/localhost.crt -keyout
traffic_ops/traffic_ops_golang/localhost.key -subj "/CN=tptests"
- name: NPM install
if: steps.restore-npm-cache.cache-hit != 'true'