Skip to content

Commit 2555913

Browse files
committed
Merge branch 'main' into fix/jira-mixed-case-key-matching
2 parents 6bddeb0 + 5f2a689 commit 2555913

3 files changed

Lines changed: 60 additions & 3 deletions

File tree

.snyk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,7 @@ exclude:
1717
# (a graphql `Login` field) as a hardcoded credential. It is a public
1818
# identifier in test data, not a secret. See kosli-dev/server#5479.
1919
- internal/github/build_pr_evidence_test.go
20+
# False positive: Snyk Code flags the hardcoded test session token (auth_token)
21+
# in this test-user fixture as a secret. It is fake test data, not a real
22+
# credential, and is used only to seed the local integration-test server.
23+
- server-scripts/create_standalone_test_users.py

bin/reset-or-start-server.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,16 @@ check_success()
2424
restart_server()
2525
{
2626
echo restarting server ...
27-
./bin/docker_login_aws.sh staging
27+
# Only remote (digest-pinned) images need an AWS login and pull. The local-image
28+
# flow uses the plain "merkely" tag, which is built locally — skip both.
29+
if [[ "$KOSLI_SERVER_IMAGE" == *"@sha256:"* ]]; then
30+
./bin/docker_login_aws.sh staging
31+
docker pull "${KOSLI_SERVER_IMAGE}" || true
32+
else
33+
echo "local image — skipping AWS login and pull"
34+
fi
2835
docker compose down || true
2936
echo -e "\033[38;5;208musing server image\033[0m ${KOSLI_SERVER_IMAGE}"
30-
docker pull ${KOSLI_SERVER_IMAGE} || true
3137
docker compose up -d
3238
./mongo/ip_wait.sh localhost:9010/minio/health/live
3339
./mongo/ip_wait.sh localhost:8001/ready
@@ -46,5 +52,5 @@ else
4652
fi
4753

4854
echo creating test users on server ...
49-
docker exec $container_name /demo/create_standalone_test_users.py
55+
docker exec $container_name /app/test/create_standalone_test_users.py
5056
check_success
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/env python3
2+
3+
# Creates the standalone test users used by the Kosli CLI integration tests.
4+
#
5+
# This script is owned by the CLI repo (the test users are CLI test data). It is
6+
# mounted into the server container at /app/test via docker-compose and executed
7+
# there, so it relies on the server's `lib` and `model` packages being importable
8+
# via PYTHONPATH=/app/src.
9+
10+
import hashlib
11+
12+
from lib import Sku
13+
from model import Organizations, Users
14+
15+
# key == person-id, value == api-key
16+
CLI_TEST_USERS = {
17+
"docs-cmd-test-user": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6ImNkNzg4OTg5In0.e8i_lA_QrEhFncb05Xw6E_tkCHU9QfcY4OLTVUCHffY",
18+
"acme-org": "v3OWZiYWu9G2IMQStYg9BcPQUQ88lJNNnTJTNq8jfvmkR1C5wVpHSs7F00JcB5i6OGeUzrKt3CwRq7ndcN4TTfMeo8ASVJ5NdHpZT7DkfRfiFvm8s7GbsIHh2PtiQJYs2UoN13T8DblV5C4oKb6-yWH73h67OhotPlKfVKazR-c",
19+
"iu-org": "qM9u2_grv6pJLbACwsMMMT5LIQy82tQj2k1zjZnlXti1smnFaGwCKW4jzk0La7ae9RrSYvEwCXSsXknD6YZqd-onLaaIUUKtEn6-B6yh53vWIe9EC5u85FCbKZjFbaicp_d0Me0Zcqq_KcCgrAZRX9xggl_pBb2oaCsNdllqNjk",
20+
"system-tests-user": "95-IeGBfyKdTteLdKidiAnXk6uMmV6jTkGM9v3DEtrQ",
21+
}
22+
23+
24+
def create_standalone_test_users(test_users):
25+
users = Users()
26+
orgs = Organizations()
27+
28+
for user_name, api_key in test_users.items():
29+
uid = hashlib.sha256(user_name.encode("utf-8")).hexdigest()[0:24]
30+
login_data = {
31+
"userId": uid,
32+
"name": user_name,
33+
"email": "default@example.com",
34+
"picture": "",
35+
}
36+
users.create("descope", login_data)
37+
user = users.find_by_auth_user_id(login_data["userId"])
38+
user.completed_signup = True
39+
user.add_api_key(api_key=api_key, setting_user=user, expires_at=0, description="")
40+
# fixed auth_token so tests have a stable session token to authenticate with
41+
user.auth_token = "213c18081df7f738ec479107b86f97ec678b1d54"
42+
43+
orgs.create_shared(f"{user_name}-shared", sku=Sku().existing_orgs, owner=user)
44+
45+
46+
if __name__ == "__main__":
47+
create_standalone_test_users(CLI_TEST_USERS)

0 commit comments

Comments
 (0)