Skip to content

Commit

Permalink
test(server): add new PUT API to the integration test (Jigsaw-Code#1504)
Browse files Browse the repository at this point in the history
  • Loading branch information
sbruens authored Feb 15, 2024
1 parent 06646f7 commit a62b25b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/shadowbox/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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.
Expand Down
12 changes: 11 additions & 1 deletion src/shadowbox/integration_test/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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" \
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a62b25b

Please sign in to comment.