From a62b25b54cf97770645d3fb601f601d2c92006be Mon Sep 17 00:00:00 2001 From: Sander Bruens Date: Thu, 15 Feb 2024 12:24:55 -0500 Subject: [PATCH] test(server): add new PUT API to the integration test (#1504) --- src/shadowbox/README.md | 4 ++-- src/shadowbox/integration_test/test.sh | 12 +++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/shadowbox/README.md b/src/shadowbox/README.md index c12d114f..12a2d5db 100644 --- a/src/shadowbox/README.md +++ b/src/shadowbox/README.md @@ -165,7 +165,7 @@ modified image. To run the integration test: ``` -npm run action shadowbox/integration_test/start +npm run action shadowbox/integration_test/run ``` This will set up three containers and two networks: @@ -186,7 +186,7 @@ npm run action shadowbox/docker/build && docker tag quay.io/outline/shadowbox $U If you need to test an unsigned image (e.g. your dev one): ``` -DOCKER_CONTENT_TRUST=0 SB_IMAGE=$USER/shadowbox npm run action shadowbox/integration_test/start +DOCKER_CONTENT_TRUST=0 SB_IMAGE=$USER/shadowbox npm run action shadowbox/integration_test/run ``` You can add tags if you need different versions in different clients. diff --git a/src/shadowbox/integration_test/test.sh b/src/shadowbox/integration_test/test.sh index 67a40ea9..313dc5a3 100755 --- a/src/shadowbox/integration_test/test.sh +++ b/src/shadowbox/integration_test/test.sh @@ -95,7 +95,7 @@ function setup() { # Target service. docker build --force-rm -t "${TARGET_IMAGE}" "$(dirname "$0")/target" docker run -d --rm -p "10080:80" --network="${NET_OPEN}" --network-alias="target" --name="${TARGET_CONTAINER}" "${TARGET_IMAGE}" - + # Shadowsocks service. declare -ar shadowbox_flags=( -d @@ -223,6 +223,15 @@ function cleanup() { && fail "Deleted access key is still active") || (($? == 56)) } + function test_create_key_with_id() { + # Verify that we can create key with a given key ID. + local ACCESS_KEY_JSON + ACCESS_KEY_JSON="$(client_curl --insecure -X PUT "${SB_API_URL}/access-keys/myKeyId")" + if [[ "${ACCESS_KEY_JSON}" != *'"id":"myKeyId"'* ]]; then + fail "Could not create new access key with ID 'myKeyId'" + fi + } + function test_port_for_new_keys() { # Verify that we can change the port for new access keys client_curl --insecure -X PUT -H "Content-Type: application/json" -d '{"port": 12345}' "${SB_API_URL}/server/port-for-new-access-keys" \ @@ -301,6 +310,7 @@ function cleanup() { } test_networking + test_create_key_with_id test_port_for_new_keys test_hostname_for_new_keys test_encryption_for_new_keys