diff --git a/scripts/promotion-smoke-test.sh b/scripts/promotion-smoke-test.sh index b65e23ef..0a45ce38 100755 --- a/scripts/promotion-smoke-test.sh +++ b/scripts/promotion-smoke-test.sh @@ -8,7 +8,7 @@ FAIL=0 USER_COOKIE="$(mktemp)" ADMIN_COOKIE="$(mktemp)" WORK_DIR="$(mktemp -d)" -SLUG="psmoke$(date +%s)" +SLUG="psmoke$(date +%s)${RANDOM}" cleanup() { rm -f "$USER_COOKIE" "$ADMIN_COOKIE" @@ -89,54 +89,132 @@ if [[ -z "$USER_CSRF" || -z "$ADMIN_CSRF" ]]; then exit 1 fi -GLOBAL_RESPONSE="$(curl -sS -H "X-Mock-User-Id: local-user" -b "$USER_COOKIE" -c "$USER_COOKIE" \ +GLOBAL_RESPONSE="$(curl -sS -H "X-Mock-User-Id: local-admin" -b "$ADMIN_COOKIE" -c "$ADMIN_COOKIE" \ "$BASE_URL/api/web/namespaces/global")" assert_code "Global namespace detail is available" "$GLOBAL_RESPONSE" "0" GLOBAL_NAMESPACE_ID="$(json_field "$GLOBAL_RESPONSE" "data.id")" -CREATE_NAMESPACE_RESPONSE="$(curl -sS -H "X-Mock-User-Id: local-user" -b "$USER_COOKIE" -c "$USER_COOKIE" \ - -H "X-XSRF-TOKEN: $USER_CSRF" \ +CREATE_NAMESPACE_RESPONSE="$(curl -sS -H "X-Mock-User-Id: local-admin" -b "$ADMIN_COOKIE" -c "$ADMIN_COOKIE" \ + -H "X-XSRF-TOKEN: $ADMIN_CSRF" \ -H "Content-Type: application/json" \ -X POST "$BASE_URL/api/web/namespaces" \ -d "{\"slug\":\"$SLUG\",\"displayName\":\"Promotion Smoke $SLUG\",\"description\":\"promotion smoke test\"}")" -assert_code "Owner can create promotion smoke namespace" "$CREATE_NAMESPACE_RESPONSE" "0" +assert_code "Admin can create promotion smoke namespace" "$CREATE_NAMESPACE_RESPONSE" "0" NAMESPACE_ID="$(json_field "$CREATE_NAMESPACE_RESPONSE" "data.id")" -cat > "$WORK_DIR/SKILL.md" <<'EOF' +ADD_MEMBER_RESPONSE="$(curl -sS -H "X-Mock-User-Id: local-admin" -b "$ADMIN_COOKIE" -c "$ADMIN_COOKIE" \ + -H "X-XSRF-TOKEN: $ADMIN_CSRF" \ + -H "Content-Type: application/json" \ + -X POST "$BASE_URL/api/web/namespaces/$SLUG/members" \ + -d '{"userId":"local-user","role":"MEMBER"}')" +assert_code "Admin can add the regular user as a namespace member" "$ADD_MEMBER_RESPONSE" "0" + +cat > "$WORK_DIR/SKILL.md" <