Skip to content

Commit

Permalink
tests: add custom certificates checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Amygos committed Aug 5, 2024
1 parent a7b1db2 commit 7fd7092
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions tests/20_traefik_certificates_api.robot
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,62 @@ Delete certificate
Get empty certificates list
${response} = Run task module/traefik1/list-certificates null
Should Be Empty ${response}

Generate a custom private and public key
${plain_key} = Execute Command openssl genrsa 4096
${plain_csr} = Execute Command echo "${plain_key}" \| openssl req -key /dev/stdin -x509 -sha256 -days 3650 -nodes -subj "/CN=test.example.com" -addext "subjectAltName=DNS:test.example.com"
# base64 encode the key and csr
${encoded_key} = Execute Command echo "${plain_key}" \| base64 -w 0
${encoded_csr} = Execute Command echo "${plain_csr}" \| base64 -w 0
Set Suite Variable ${key} ${encoded_key}
Set Suite Variable ${csr} ${encoded_csr}

Upload a custom certificate
${response} = Run task module/traefik1/upload-certificate
... {"keyFile": "${key}", "certFile": "${csr}"}
${response} = Run task module/traefik1/get-certificate {"fqdn": "test.example.com"}
Should Be Equal As Strings ${response['fqdn']} test.example.com
Should Be Equal As Strings ${response['obtained']} True
Should Be Equal As Strings ${response['type']} custom
Run task module/traefik1/delete-certificate {"fqdn": "test.example.com"}

Upload custom certificate is no overriden by an internal certificate
Run task module/traefik1/upload-certificate
... {"keyFile": "${key}", "certFile": "${csr}"}
Run task module/traefik1/set-certificate
... {"fqdn":"test.example.com"}
${response} = Run task module/traefik1/get-certificate {"fqdn": "test.example.com"}
Should Be Equal As Strings ${response['type']} custom
Run task module/traefik1/delete-certificate {"fqdn": "test.example.com"}
${response} = Run task module/traefik1/get-certificate {"fqdn": "test.example.com"}
Should Be Empty ${response}

Requested internal certificate is overriden by an uploaded custom certificate
Run task module/traefik1/set-certificate {"fqdn":"test.example.com"}
Run task module/traefik1/upload-certificate
... {"keyFile": "${key}", "certFile": "${csr}"}
${response} = Run task module/traefik1/get-certificate {"fqdn": "test.example.com"}
Should Be Equal As Strings ${response['type']} custom
Run task module/traefik1/delete-certificate {"fqdn": "test.example.com"}
${response} = Run task module/traefik1/get-certificate {"fqdn": "test.example.com"}
Should Be Empty ${response}

The certificate must be listed only once
Run task module/traefik1/upload-certificate {"keyFile": "${key}", "certFile": "${csr}"}
Run task module/traefik1/set-certificate {"fqdn":"test.example.com"}
${response} = Run task module/traefik1/list-certificates {"expand_list": true}
Length Should Be ${response} 1
Should Be Equal As Strings ${response[0]['type']} custom

Run task module/traefik1/delete-certificate {"fqdn": "test.example.com"}
${response} = Run task module/traefik1/get-certificate {"fqdn": "test.example.com"}
Should Be Empty ${response}
Run task module/traefik1/set-certificate {"fqdn":"test.example.com"}
Run task module/traefik1/upload-certificate {"keyFile": "${key}", "certFile": "${csr}"}
${response} = Run task module/traefik1/list-certificates {"expand_list": true}
Length Should Be ${response} 1

Should Be Equal As Strings ${response[0]['type']} custom
Run task module/traefik1/delete-certificate {"fqdn": "test.example.com"}
${response} = Run task module/traefik1/get-certificate {"fqdn": "test.example.com"}
Should Be Empty ${response}

0 comments on commit 7fd7092

Please sign in to comment.