Skip to content

Commit

Permalink
Add test for pki_*_opsFlag and pki_*_opsFlagMask
Browse files Browse the repository at this point in the history
  • Loading branch information
fmarco76 committed Dec 21, 2023
1 parent 4a86f59 commit ab9bf23
Show file tree
Hide file tree
Showing 2 changed files with 141 additions and 0 deletions.
136 changes: 136 additions & 0 deletions .github/workflows/ca-hsm-operation-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
name: CA with HSM and custom operation key flags

on: workflow_call

env:
DB_IMAGE: ${{ vars.DB_IMAGE || 'quay.io/389ds/dirsrv' }}

jobs:
# docs/installation/ca/Installing_CA_with_HSM.md
test:
name: Test
runs-on: ubuntu-latest
env:
SHARED: /tmp/workdir/pki
steps:
- name: Clone repository
uses: actions/checkout@v3

- name: Retrieve PKI images
uses: actions/cache@v3
with:
key: pki-images-${{ github.sha }}
path: pki-images.tar

- name: Load PKI images
run: docker load --input pki-images.tar

- name: Create network
run: docker network create example

- name: Set up DS container
run: |
tests/bin/ds-container-create.sh ds
env:
IMAGE: ${{ env.DB_IMAGE }}
HOSTNAME: ds.example.com
PASSWORD: Secret.123

- name: Connect DS container to network
run: docker network connect example ds --alias ds.example.com

- name: Set up PKI container
run: |
tests/bin/runner-init.sh pki
env:
HOSTNAME: pki.example.com

- name: Connect PKI container to network
run: docker network connect example pki --alias pki.example.com

- name: Install dependencies
run: |
docker exec pki dnf install -y softhsm
- name: Create SoftHSM token
run: |
# allow PKI user to access SoftHSM files
docker exec pki usermod pkiuser -a -G ods
# create SoftHSM token for PKI server
docker exec pki runuser -u pkiuser -- \
softhsm2-util \
--init-token \
--label HSM \
--so-pin Secret.HSM \
--pin Secret.HSM \
--free
docker exec pki ls -laR /var/lib/softhsm/tokens
- name: Install CA with HSM and no sign flag
run: |
docker exec pki pkispawn \
-f /usr/share/pki/server/examples/installation/ca.cfg \
-s CA \
-D pki_instance_name=pki-failing-tomcat \
-D pki_ds_url=ldap://ds.example.com:3389 \
-D pki_hsm_enable=True \
-D pki_token_name=HSM \
-D pki_token_password=Secret.HSM \
-D pki_server_database_password=Secret.123 \
-D pki_ca_signing_token=HSM \
-D pki_ocsp_signing_token=HSM \
-D pki_audit_signing_token=HSM \
-D pki_subsystem_token=HSM \
-D pki_sslserver_token=internal \
-D pki_ca_signing_opsFlagMask=sign \
-v
continue-on-error: true
id: hsm_no_sign

- name: Check the install with no sign ops failed
if: job.steps.hsm_no_sign.status != failure()
run: exit 1

- name: Install CA with HSM reintroducing sign flag
run: |
docker exec pki pkispawn \
-f /usr/share/pki/server/examples/installation/ca.cfg \
-s CA \
-D pki_ds_url=ldap://ds.example.com:3389 \
-D pki_hsm_enable=True \
-D pki_token_name=HSM \
-D pki_token_password=Secret.HSM \
-D pki_server_database_password=Secret.123 \
-D pki_ca_signing_token=HSM \
-D pki_ocsp_signing_token=HSM \
-D pki_audit_signing_token=HSM \
-D pki_subsystem_token=HSM \
-D pki_sslserver_token=internal \
-D pki_ca_signing_opsFlag=sign \
-D pki_ca_signing_opsFlagMask=sign \
-v
- name: Gather artifacts
if: always()
run: |
tests/bin/ds-artifacts-save.sh --output=/tmp/artifacts/pki ds
tests/bin/pki-artifacts-save.sh pki
continue-on-error: true

- name: Remove CA
run: docker exec pki pkidestroy -i pki-tomcat -s CA -v

- name: Remove SoftHSM token
run: |
docker exec pki ls -laR /var/lib/softhsm/tokens
docker exec pki runuser -u pkiuser -- softhsm2-util --delete-token --token HSM
- name: Upload artifacts
if: always()
uses: actions/upload-artifact@v3
with:
name: ca-hsm
path: |
/tmp/artifacts/pki
5 changes: 5 additions & 0 deletions .github/workflows/ca-tests2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,8 @@ jobs:
name: SCEP responder
needs: build
uses: ./.github/workflows/scep-test.yml

hsm-operation-test:
name: CA with HSM and custom operation key flags
needs: build
uses: ./.github/workflows/ca-hsm-operation-test.yml

0 comments on commit ab9bf23

Please sign in to comment.