Skip to content

Commit 8945a64

Browse files
Utils to chekc mocked data
Signed-off-by: Lukasz Gryglicki <[email protected]>
1 parent d05e64d commit 8945a64

File tree

6 files changed

+49
-4
lines changed

6 files changed

+49
-4
lines changed

cla-backend-go/auth/authorizer.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ func (a Authorizer) SecurityAuth(token string, scopes []string) (*user.CLAUser,
7575
// Get the username from the token claims
7676
// LG: for V3 endpoints comment this out and set: username, name and email manually for local testing.
7777
// username, name, email := "user", "Name Surname", "[email protected]"
78+
// username, name, email := "mock-user-go-20250522", "Mock User Go 2025-05-22", "[email protected]"
7879
usernameClaim, ok := claims[a.authValidator.usernameClaim]
7980
if !ok {
8081
log.WithFields(f).Warnf("username not found in claims with key: %s", a.authValidator.usernameClaim)

cla-backend/cla/models/github_models.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1853,11 +1853,13 @@ def _get_request_session(self, request) -> dict:
18531853
return {}
18541854

18551855
def get_user_data(self, session, client_id) -> dict:
1856-
return {"email": "[email protected]", "name": "Test User", "login": "testuser", "id": 123}
1856+
# LG:
1857+
return { "id": 20250522666, "login": "mock-user-py-20250522", "name": "Mock User Py 2025-05-22", "email": "[email protected]" }
1858+
# return {"email": "[email protected]", "name": "Test User", "login": "testuser", "id": 123}
18571859

18581860
def get_user_emails(self, session, client_id):
18591861
# LG: updated MockGitHub to return emails in the same way as GitHub class
1860-
return ["test@user.com"]
1862+
return ["u20250522@mock.user.py.pl"]
18611863
# return [{"email": "[email protected]", "verified": True, "primary": True, "visibility": "public"}]
18621864

18631865
def get_pull_request(self, github_repository_id, pull_request_number, installation_id):

utils/check_mock_users.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
STAGE=dev DEBUG=1 ./utils/lookup_user_by_github_id.sh 20250522666
3+
STAGE=dev DEBUG=1 ./utils/lookup_user_by_lfid.sh "mock-user-go-20250522"

utils/describe_table.sh

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,16 @@
11
#!/bin/bash
2-
aws --profile lfproduct-dev dynamodb describe-table --table-name cla-dev-signatures
2+
if [ -z "$1" ]
3+
then
4+
echo "$0: you need to specify table as a 1st parameter, for example: 'users'"
5+
exit 1
6+
fi
7+
if [ -z "${STAGE}" ]
8+
then
9+
export STAGE=dev
10+
fi
11+
12+
if [ ! -z "${DEBUG}" ]
13+
then
14+
echo "aws --profile \"lfproduct-${STAGE}\" dynamodb describe-table --table-name \"cla-${STAGE}-${1}\""
15+
fi
16+
aws --profile "lfproduct-${STAGE}" dynamodb describe-table --table-name "cla-${STAGE}-${1}"

utils/lookup_user_by_github_id.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
if [ -z "$1" ]
3+
then
4+
echo "$0: you need to specify GitHub ID as a 1st parameter, for example: 2469783"
5+
exit 1
6+
fi
7+
if [ -z "${STAGE}" ]
8+
then
9+
export STAGE=dev
10+
fi
11+
12+
if [ ! -z "${DEBUG}" ]
13+
then
14+
echo "aws --profile \"lfproduct-${STAGE}\" dynamodb query --table-name \"cla-${STAGE}-users\" --index-name github-id-index --key-condition-expression \"user_github_id = :github_id\" --expression-attribute-values '{\":github_id\":{\"N\":\"${1}\"}}' | jq -r '.'"
15+
fi
16+
aws --profile "lfproduct-${STAGE}" dynamodb query --table-name "cla-${STAGE}-users" --index-name github-id-index --key-condition-expression "user_github_id = :github_id" --expression-attribute-values "{\":github_id\":{\"N\":\"${1}\"}}" | jq -r '.'

utils/lookup_user_by_lfid.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,13 @@ then
44
echo "$0: you need to specify lfid as a 1st parameter, for example: 'lgryglicki'"
55
exit 1
66
fi
7-
aws --profile lfproduct-prod dynamodb query --table-name cla-prod-users --index-name lf-username-index --key-condition-expression "lf_username = :name" --expression-attribute-values "{\":name\":{\"S\":\"${1}\"}}" | jq -r '.'
7+
if [ -z "${STAGE}" ]
8+
then
9+
export STAGE=dev
10+
fi
11+
12+
if [ ! -z "${DEBUG}" ]
13+
then
14+
echo "aws --profile \"lfproduct-${STAGE}\" dynamodb query --table-name \"cla-${STAGE}-users\" --index-name lf-username-index --key-condition-expression \"lf_username = :name\" --expression-attribute-values '{\":name\":{\"S\":\"${1}\"}}' | jq -r '.'"
15+
fi
16+
aws --profile "lfproduct-${STAGE}" dynamodb query --table-name "cla-${STAGE}-users" --index-name lf-username-index --key-condition-expression "lf_username = :name" --expression-attribute-values "{\":name\":{\"S\":\"${1}\"}}" | jq -r '.'

0 commit comments

Comments
 (0)