Skip to content

Commit

Permalink
Fix: testing
Browse files Browse the repository at this point in the history
  • Loading branch information
movd committed Nov 4, 2020
1 parent 508dedf commit f12721a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/bats-testing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Run Unit and Integration tests with Bats
run: |-
./test/hook.bats -t
sleep 120 && ./test/hook.bats -t
e2e-tests:
runs-on: ubuntu-20.04
Expand Down
46 changes: 18 additions & 28 deletions test/hook.bats
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function teardown() {
}

# test check_dependencies_and_config
@test 'exit with missing or wrong .env file' {
@test 'unit: exit with missing or wrong .env file' {
# abort if empty .env
echo "DYNV6_ZONEID=123456" > ${base_dir}/${ENV}.env
assert_file_exist ${base_dir}/${ENV}.env
Expand All @@ -42,7 +42,7 @@ function teardown() {
assert_output --partial "DYNV6_ZONEID is empty"
}

@test 'download the public suffix list' {
@test 'unit: download the public suffix list' {
run get_publicsuffix_list
assert_success
assert_file_exist "${base_dir}/public_suffix_list_sorted.dat"
Expand Down Expand Up @@ -110,7 +110,7 @@ function teardown() {
assert_line --index 0 "_acme-challenge.bender"
}

@test 'test the test_dynv6_connection function 🙃' {
@test 'unit: test the test_dynv6_connection function 🙃' {
# wrong zoneid results in 'not found'
# right token, wrong zone
export DYNV6_TOKEN=${SECRET_DYNV6_TOKEN}
Expand All @@ -127,7 +127,7 @@ function teardown() {
assert_success
}

@test 'unit test: deploy challenge response token for a dynv6.net domain (example.dynv6.net)' {
@test 'unit: deploy challenge response token for a dynv6.net domain (example.dynv6.net)' {
# right token, wrong zone
export DYNV6_TOKEN=${SECRET_DYNV6_TOKEN}
export DYNV6_ZONEID=${SECRET_DYNV6_ZONEID}
Expand All @@ -139,7 +139,7 @@ function teardown() {
assert_success
}

@test 'unit test: deploy challenge response token for a dynv6.net subdomain (foo.example.dynv6.net)' {
@test 'unit: deploy challenge response token for a dynv6.net subdomain (foo.example.dynv6.net)' {
# right token, wrong zone
export DYNV6_TOKEN=${SECRET_DYNV6_TOKEN}
export DYNV6_ZONEID=${SECRET_DYNV6_ZONEID}
Expand All @@ -151,7 +151,7 @@ function teardown() {
assert_success
}

@test 'unit test: clean challenge response token for a dynv6.net subdomain (foo.example.dynv6.net)' {
@test 'unit: clean challenge response token for a dynv6.net subdomain (foo.example.dynv6.net)' {
# right token, wrong zone
export DYNV6_TOKEN=${SECRET_DYNV6_TOKEN}
export DYNV6_ZONEID=${SECRET_DYNV6_ZONEID}
Expand All @@ -161,56 +161,46 @@ function teardown() {
assert_success
}

@test 'integration test: deploy challenge response token for a dynv6.net domain (foo.example.dynv6.net)' {
@test 'integration: deploy challenge response token for a dynv6.net subdomain (integration.example.dynv6.net)' {
export DYNV6_TOKEN=${SECRET_DYNV6_TOKEN}
export DYNV6_ZONEID=${SECRET_DYNV6_ZONEID}
output=$(${hook_script} deploy_challenge ${SECRET_DYNV6_TEST_DOMAIN} null hook_token) #TODO GITHUBSECRET
output=$(${hook_script} deploy_challenge integration.${SECRET_DYNV6_TEST_DOMAIN} null hook_token)
run echo "${output}"
assert_output --partial 'DNS entry added successfully'
assert_output --partial '{"name":"_acme-challenge","data":"hook_token","type":"TXT"}'
assert_output --partial '{"name":"_acme-challenge.integration","data":"hook_token","type":"TXT"}'
}

@test 'integration test: clean challenge response token for a dynv6.net domain (example.dynv6.net)' {
@test 'integration: clean challenge response token for a dynv6.net subdomain (integration.example.dynv6.net)' {
export DYNV6_TOKEN=${SECRET_DYNV6_TOKEN}
export DYNV6_ZONEID=${SECRET_DYNV6_ZONEID}
output=$(${hook_script} clean_challenge ${SECRET_DYNV6_TEST_DOMAIN}) #TODO GITHUBSECRET
output=$(${hook_script} clean_challenge integration.${SECRET_DYNV6_TEST_DOMAIN})
run echo "${output}"
assert_output --partial "Successfully deleted token at dynv6.com"
assert_success
}

@test 'integration test: deploy challenge response token for a dynv6.net subdomain (example.dynv6.net)' {
@test 'integration: deploy challenge response token for a dynv6.net domain (example.dynv6.net)' {
export DYNV6_TOKEN=${SECRET_DYNV6_TOKEN}
export DYNV6_ZONEID=${SECRET_DYNV6_ZONEID}
output=$(${hook_script} deploy_challenge integration.${SECRET_DYNV6_TEST_DOMAIN} null hook_token) #TODO GITHUBSECRET
output=$(${hook_script} deploy_challenge ${SECRET_DYNV6_TEST_DOMAIN} null hook_token)
run echo "${output}"
assert_output --partial 'DNS entry added successfully'
assert_output --partial '{"name":"_acme-challenge.integration","data":"hook_token","type":"TXT"}'
}


@test 'integration test: clean challenge response token for a dynv6.net subdomain (foo.example.dynv6.net)' {
export DYNV6_TOKEN=${SECRET_DYNV6_TOKEN}
export DYNV6_ZONEID=${SECRET_DYNV6_ZONEID}
output=$(${hook_script} clean_challenge integration.${SECRET_DYNV6_TEST_DOMAIN}) #TODO GITHUBSECRET
run echo "${output}"
assert_output --partial "Successfully deleted token at dynv6.com"
assert_success
assert_output --partial '{"name":"_acme-challenge","data":"hook_token","type":"TXT"}'
}

@test 'integration test: deploy challenge response token for a dynv6.net wildcard (*.example.dynv6.net)' {
@test 'integration: deploy challenge response token for a dynv6.net wildcard (*.example.dynv6.net)' {
export DYNV6_TOKEN=${SECRET_DYNV6_TOKEN}
export DYNV6_ZONEID=${SECRET_DYNV6_ZONEID}
output=$(${hook_script} deploy_challenge *.${SECRET_DYNV6_TEST_DOMAIN} null hook_token) #TODO GITHUBSECRET
output=$(${hook_script} deploy_challenge *.${SECRET_DYNV6_TEST_DOMAIN} null hook_token)
run echo "${output}"
assert_output --partial 'DNS entry added successfully'
assert_output --partial '{"name":"_acme-challenge","data":"hook_token","type":"TXT"}'
}

@test 'integration test: clean challenge response token for a dynv6.net wildcard (*.example.dynv6.net)' {
@test 'integration: clean challenge response token for a dynv6.net wildcard (*.example.dynv6.net)' {
export DYNV6_TOKEN=${SECRET_DYNV6_TOKEN}
export DYNV6_ZONEID=${SECRET_DYNV6_ZONEID}
output=$(${hook_script} clean_challenge *.${SECRET_DYNV6_TEST_DOMAIN}) #TODO GITHUBSECRET
output=$(${hook_script} clean_challenge *.${SECRET_DYNV6_TEST_DOMAIN})
run echo "${output}"
assert_output --partial "Successfully deleted token at dynv6.com"
assert_success
Expand Down

0 comments on commit f12721a

Please sign in to comment.