You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by "tcfdev (via GitHub)" <gi...@apache.org> on 2023/02/01 14:36:13 UTC

[GitHub] [trafficcontrol] tcfdev commented on a diff in pull request #7328: TP/TPv2 tests: Get admin role ID from the database

tcfdev commented on code in PR #7328:
URL: https://github.com/apache/trafficcontrol/pull/7328#discussion_r1092567719


##########
.github/workflows/tpv2.yml:
##########
@@ -212,12 +212,33 @@ jobs:
       # Setup
       - name: Install dependencies
         run: sudo apt-get update && sudo apt-get install postgresql-client gettext-base
+      - name: Hash TO user password
+        run: |2
+          password_hash="$(<<PYTHON_COMMANDS PYTHONPATH="${GITHUB_WORKSPACE}/traffic_ops/install/bin" python
+          import _postinstall
+          print(_postinstall.hash_pass('${{ env.PGPASSWORD }}12'))
+          PYTHON_COMMANDS
+          )" &&
+          echo "TO_USER_PASSWORD_HASH=${password_hash}" >> '${{ github.env }}'
+      - name: Get admin role
+        run: |2
+          admin_role_id="$(<<QUERY psql -t
+          SELECT r.id
+          FROM public."role" r
+          WHERE r."name" = 'admin'
+          QUERY
+          )" &&
+          echo "TO_ADMIN_ROLE_ID=${admin_role_id}" >> '${{ 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', ${{ env.TO_ADMIN_ROLE_ID }}, 1, '${{ env.TO_USER_PASSWORD_HASH }}');

Review Comment:
   Same question here, do we need single quotes around `${{ env.TO_ADMIN_ROLE_ID }}` like we have for '${{ env.TO_USER_PASSWORD_HASH }}'?



##########
.github/actions/tp-integration-tests/entrypoint.sh:
##########
@@ -58,9 +58,15 @@ import _postinstall
 print(_postinstall.hash_pass('${to_admin_password}'))
 PYTHON_COMMANDS
 )"
+admin_role_id="$(<<QUERY psql -t
+SELECT r.id
+FROM public."role" r
+WHERE r."name" = 'admin'
+QUERY
+)"
 <<QUERY psql
 INSERT INTO tm_user (username, role, tenant_id, local_passwd)
-  VALUES ('${to_admin_username}', 1, 1,
+  VALUES ('${to_admin_username}', ${admin_role_id}, 1,

Review Comment:
   Do you need single quotes around `${admin_role_id}` like we have with `'${to_admin_username}'`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org