Skip to content

Commit

Permalink
Add basic pki and pki-server CLI tests
Browse files Browse the repository at this point in the history
The CI tests have been updated to check some basic operations
of pki and pki-server CLIs for displaying help messages, showing
version number, and handling subcommands.
  • Loading branch information
edewata committed Feb 3, 2025
1 parent 6902bf3 commit fdac0ff
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 49 deletions.
27 changes: 13 additions & 14 deletions .github/workflows/ca-existing-ds-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,19 @@ jobs:
--cert admin.crt \
caadmin
- name: Check pki-server ca CLI help message
run: |
docker exec pki pki-server ca
docker exec pki pki-server ca --help
# TODO: validate output
- name: Check pki-server ca-create CLI help message
run: |
docker exec pki pki-server ca-create --help
# TODO: validate output
- name: Create CA subsystem
run: |
docker exec pki pki-server ca-create -v
Expand Down Expand Up @@ -402,17 +415,3 @@ jobs:
if: always()
run: |
docker exec pki find /var/lib/pki/pki-tomcat/logs/ca -name "debug.*" -exec cat {} \;
- name: Gather artifacts
if: always()
run: |
tests/bin/ds-artifacts-save.sh ds
tests/bin/pki-artifacts-save.sh pki
continue-on-error: true

- name: Upload artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: ca-existing-ds
path: /tmp/artifacts
70 changes: 70 additions & 0 deletions .github/workflows/pki-basic-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Basic PKI CLI
# https://github.com/dogtagpki/pki/wiki/PKI-CLI

on: workflow_call

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

jobs:
test:
name: Test
runs-on: ubuntu-latest
env:
SHARED: /tmp/workdir/pki
steps:
- name: Clone repository
uses: actions/checkout@v4

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

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

- name: Set up runner container
run: |
tests/bin/runner-init.sh \
--hostname=pki.example.com \
pki
- name: Check pki CLI help message
run: |
docker exec pki pki
docker exec pki pki --help
# TODO: validate output
- name: Check pki CLI version
run: |
docker exec pki pki --version
# TODO: validate output
- name: Check pki CLI with wrong option
run: |
docker exec pki pki --wrong \
> >(tee stdout) 2> >(tee stderr >&2) || true
# TODO: validate output
- name: Check pki CLI with wrong sub-command
run: |
docker exec pki pki wrong \
> >(tee stdout) 2> >(tee stderr >&2) || true
cat > expected << EOF
ERROR: Invalid module "wrong".
EOF
diff expected stderr
- name: Check pki nss CLI help message
run: |
docker exec pki pki nss
docker exec pki pki nss --help
# TODO: validate output
59 changes: 38 additions & 21 deletions .github/workflows/server-basic-test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: Basic server
# https://github.com/dogtagpki/pki/wiki/PKI-Server-CLI

on: workflow_call

Expand Down Expand Up @@ -37,6 +38,43 @@ jobs:
- name: Connect server container to network
run: docker network connect example pki --alias pki.example.com

- name: Check pki-server CLI help message
run: |
docker exec pki pki-server
docker exec pki pki-server --help
# TODO: validate output
- name: Check pki-server CLI version
run: |
docker exec pki pki-server --version
# TODO: validate output
- name: Check pki-server CLI with wrong option
run: |
docker exec pki pki-server --wrong \
> >(tee stdout) 2> >(tee stderr >&2) || true
# TODO: validate output
- name: Check pki-server CLI with wrong sub-command
run: |
docker exec pki pki-server wrong \
> >(tee stdout) 2> >(tee stderr >&2) || true
cat > expected << EOF
ERROR: Invalid module "wrong".
EOF
diff expected stderr
- name: Check pki-server create CLI help message
run: |
docker exec pki pki-server create --help
# TODO: validate output
- name: Create pki-tomcat server
run: |
docker exec pki pki-server create -v
Expand Down Expand Up @@ -412,24 +450,3 @@ jobs:
EOF
diff expected output
- name: Gather artifacts from server container
if: always()
run: |
tests/bin/pki-artifacts-save.sh pki
docker exec pki ls -la /var/lib/tomcats/pki/conf
mkdir -p /tmp/artifacts/pki/var/lib/tomcats/pki/conf
docker cp pki:/var/lib/tomcats/pki/conf/* /tmp/artifacts/var/lib/tomcats/pki/conf
docker exec pki ls -la /var/lib/tomcats/pki/logs
mkdir -p /tmp/artifacts/pki/var/lib/tomcats/pki/logs
docker cp pki:/var/lib/tomcats/pki/logs/* /tmp/artifacts/var/lib/tomcats/pki/logs
continue-on-error: true

- name: Upload artifacts from server container
if: always()
uses: actions/upload-artifact@v4
with:
name: server-basic-test
path: /tmp/artifacts
27 changes: 13 additions & 14 deletions .github/workflows/server-https-nss-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,19 @@ jobs:
run: |
docker exec pki pki-server create -v
- name: Check pki-server nss CLI help message
run: |
docker exec pki pki-server nss
docker exec pki pki-server nss --help
# TODO: validate output
- name: Check pki-server nss-create CLI help message
run: |
docker exec pki pki-server nss-create --help
# TODO: validate output
- name: Create NSS database in PKI server
run: |
docker exec pki pki-server nss-create --no-password
Expand Down Expand Up @@ -371,17 +384,3 @@ jobs:
if: always()
run: |
docker exec pki find /var/lib/pki/pki-tomcat/logs/pki -name "debug.*" -exec cat {} \;
- name: Gather artifacts from server container
if: always()
run: |
tests/bin/pki-artifacts-save.sh pki
continue-on-error: true

- name: Upload artifacts from server container
if: always()
uses: actions/upload-artifact@v4
with:
name: server-https-nss-test
path: |
/tmp/artifacts/pki
5 changes: 5 additions & 0 deletions .github/workflows/tools-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ jobs:
uses: ./.github/workflows/wait-for-build.yml
secrets: inherit

pki-basic-test:
name: Basic PKI CLI
needs: build
uses: ./.github/workflows/pki-basic-test.yml

PKICertImport-test:
name: PKICertImport
needs: build
Expand Down

0 comments on commit fdac0ff

Please sign in to comment.