-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Lukasz Gryglicki <[email protected]>
- Loading branch information
1 parent
3d71841
commit a6c9980
Showing
13 changed files
with
189 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
# SPDX-License-Identifier: MIT | ||
import json | ||
import unittest | ||
import uuid | ||
from unittest.mock import Mock | ||
|
||
import cla | ||
|
@@ -119,6 +120,23 @@ def mock_get_user_by_github_username(username): | |
u1.set_user_email('[email protected]') | ||
return [u1] | ||
|
||
def test_signature_acl(): | ||
sig = Signature() | ||
sig.set_signature_document_major_version(1) | ||
sig.set_signature_document_minor_version(0) | ||
sig.set_signature_id(str(uuid.uuid4())) | ||
sig.set_signature_project_id(str(uuid.uuid4())) | ||
sig.set_signature_reference_id(str(uuid.uuid4())) | ||
sig.set_signature_type('user') | ||
sig.set_signature_acl('lgryglicki') | ||
# print(f"signature_id1 {sig.get_signature_id()}") | ||
# sig.save() | ||
# sig2 = Signature() | ||
# sig2.load(signature_id='afcf787b-8010-4c43-8bf7-2dbbfa229f2c') | ||
# print(f"signature_id2 {sig2.get_signature_id()}") | ||
# sig2.set_signature_id(str(uuid.uuid4())) | ||
# print(f"signature_id3 {sig2.get_signature_id()}") | ||
# sig2.save() | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Copyright The Linux Foundation and each contributor to CommunityBridge. | ||
# SPDX-License-Identifier: MIT | ||
import logging | ||
import unittest | ||
|
||
import cla | ||
from cla import utils | ||
from cla.models.dynamo_models import User | ||
|
||
def test_set_user_emails(): | ||
usr = User() | ||
usr.set_user_emails('[email protected]') | ||
assert usr.get_user_emails() == {'[email protected]'} | ||
usr.set_user_emails(['[email protected]']) | ||
assert usr.get_user_emails() == {'[email protected]'} | ||
usr.set_user_emails({'[email protected]'}) | ||
assert usr.get_user_emails() == {'[email protected]'} | ||
usr.set_user_emails([]) | ||
assert usr.get_user_emails() == set() | ||
usr.set_user_emails(set()) | ||
assert usr.get_user_emails() == set() | ||
usr.set_user_emails({}) | ||
assert usr.get_user_emails() == set() | ||
usr.set_user_emails(None) | ||
assert usr.get_user_emails() == set() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,6 @@ | |
from cla import utils | ||
from cla.models.dynamo_models import User | ||
|
||
|
||
class TestUserModels(unittest.TestCase): | ||
tests_enabled = False | ||
|
||
|
@@ -90,19 +89,19 @@ def test_get_user_email(self): | |
user.set_lf_email(None) | ||
user.set_user_emails([]) | ||
assert user.get_user_email() is None | ||
|
||
user.set_lf_email("[email protected]") | ||
assert user.get_user_email() == "[email protected]" | ||
|
||
user = User(user_email="[email protected]") | ||
assert user.get_user_email() == "[email protected]" | ||
|
||
user = User(user_email="[email protected]", preferred_email="[email protected]") | ||
assert user.get_user_email() == "[email protected]" | ||
user.set_user_emails(["[email protected]", "[email protected]"]) | ||
user.set_lf_email("[email protected]") | ||
assert user.get_user_email() == "[email protected]" | ||
|
||
# the scenario where have multiple emails | ||
user = User(preferred_email="[email protected]") | ||
user.set_user_emails(["[email protected]", "[email protected]", "[email protected]"]) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/bash | ||
# API_URL=https://3f13-147-75-85-27.ngrok-free.app (defaults to localhost:5000) | ||
# auth_user: check_auth (comment out to bypass) | ||
if ( [ ! -z "$DEBUG" ] && [ -z "$project_id" ] ) | ||
then | ||
echo "$0: example:" | ||
echo "$0: project_id=88ee12de-122b-4c46-9046-19422054ed8d reference_id=9dcf5bbc-2492-11ed-97c7-3e2a23ea20b5 reference_type=user|company type=cla|ccla|ecla signed=true approved=true embargo_acked=true return_url=https://github.com/VeerSecurityOnbordingOrg/repo11/pull/1 sign_url=https://demo.docusign.net/Signing ccla_company_id='\"8530442c-1805-4a8a-bf1d-cfca6ffc7401\"'|null" | ||
echo "$0: project_id=88ee12de-122b-4c46-9046-19422054ed8d reference_id=9dcf5bbc-2492-11ed-97c7-3e2a23ea20b5 reference_type=user type=cla signed=false approved=false embargo_acked=true return_url=https://google.com sign_url=https://google.com ccla_company_id=null ./utils/create_signature_py.sh" | ||
fi | ||
|
||
if [ -z "$TOKEN" ] | ||
then | ||
# ./m2m-token-dev.secret | ||
TOKEN="$(cat ./auth0.token.secret)" | ||
fi | ||
|
||
if [ -z "$TOKEN" ] | ||
then | ||
echo "$0: TOKEN not specified and unable to obtain one" | ||
exit 1 | ||
fi | ||
|
||
if [ -z "$API_URL" ] | ||
then | ||
export API_URL="http://localhost:5000" | ||
fi | ||
|
||
data="{\"signature_project_id\":\"${project_id}\",\"signature_reference_id\":\"${reference_id}\",\"signature_reference_type\":\"${reference_type}\",\"signature_type\":\"${type}\",\"signature_signed\":${signed},\"signature_approved\":${approved},\"signature_embargo_acked\":${embargo_acked},\"signature_return_url\":\"${return_url}\",\"signature_sign_url\":\"${sign_url}\",\"signature_user_ccla_company_id\":${ccla_company_id}}" | ||
|
||
if [ ! -z "$DEBUG" ] | ||
then | ||
echo "curl -s -XPOST -H \"Authorization: Bearer ${TOKEN}\" -H \"Content-Type: application/json\" \"${API_URL}/v1/signature\" -d \"${data}\"" | ||
curl -s -XPOST -H "Authorization: Bearer ${TOKEN}" -H "Content-Type: application/json" "${API_URL}/v1/signature" -d "${data}" | ||
else | ||
curl -s -XPOST -H "Authorization: Bearer ${TOKEN}" -H "Content-Type: application/json" "${API_URL}/v1/signature" -d "${data}" | jq -r '.' | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
if [ -z "$1" ] | ||
then | ||
echo "$0: you need to specify signature_id as a 1st parameter, for example: '6168fc0b-705a-4fde-a9dd-d0a4a9c01457'" | ||
exit 1 | ||
fi | ||
|
||
if [ -z "$STAGE" ] | ||
then | ||
STAGE=dev | ||
fi | ||
aws --profile "lfproduct-${STAGE}" dynamodb delete-item --table-name "cla-${STAGE}-signatures" --key "{\"signature_id\":{\"S\":\"${1}\"}}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
if [ -z "$1" ] | ||
then | ||
echo "$0: you need to specify signature_id as a 1st parameter, for example: '6168fc0b-705a-4fde-a9dd-d0a4a9c01457'" | ||
exit 1 | ||
fi | ||
|
||
if [ -z "$STAGE" ] | ||
then | ||
STAGE=dev | ||
fi | ||
aws --profile "lfproduct-${STAGE}" dynamodb query --table-name "cla-${STAGE}-signatures" --key-condition-expression "signature_id = :signature_id" --expression-attribute-values "{\":signature_id\":{\"S\":\"${1}\"}}" | jq -r '.' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
# ./utils/lookup_signature_by_reference_id_dd.sh 3777c5a4-0ca8-11ec-9807-4ebaf2d64a25 | jq -r '.Items[].signature_id' | ||
if [ -z "$1" ] | ||
then | ||
echo "$0: you need to specify reference_id as a 1st parameter, for example: '9dcf5bbc-2492-11ed-97c7-3e2a23ea20b5', '3777c5a4-0ca8-11ec-9807-4ebaf2d64a25'" | ||
exit 1 | ||
fi | ||
|
||
if [ -z "$STAGE" ] | ||
then | ||
STAGE=dev | ||
fi | ||
aws --profile "lfproduct-${STAGE}" dynamodb query --table-name "cla-${STAGE}-signatures" --index-name reference-signature-index --key-condition-expression "signature_reference_id = :reference_id" --expression-attribute-values "{\":reference_id\":{\"S\":\"${1}\"}}" | jq -r '.' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/bash | ||
# API_URL=https://3f13-147-75-85-27.ngrok-free.app (defaults to localhost:5000) | ||
# https://api.lfcla.dev.platform.linuxfoundation.org/v2/return-url/6168fc0b-705a-4fde-a9dd-d0a4a9c01457?event=signing_complete | ||
# 'event' flag that describes the redirect reason (2nd parameter) | ||
# 7db9a47c-c8fe-4dcb-822d-3f8406b094e3 - has signature_acl = null | ||
# 6168fc0b-705a-4fde-a9dd-d0a4a9c01457 - has signature_acl type LS (list of strings) | ||
# afcf787b-8010-4c43-8bf7-2dbbfa229f2c - has signature_acl type SS (string set) | ||
|
||
if [ -z "$1" ] | ||
then | ||
echo "$0: you need to specify return_url as a 1st parameter, example '6168fc0b-705a-4fde-a9dd-d0a4a9c01457'" | ||
exit 1 | ||
fi | ||
export return_url="$1" | ||
|
||
export extra='' | ||
if [ ! -z "$2" ] | ||
then | ||
export extra="?event=$2" | ||
fi | ||
|
||
if [ -z "$API_URL" ] | ||
then | ||
export API_URL="http://localhost:5000" | ||
fi | ||
|
||
API="${API_URL}/v2/return-url/${return_url}${extra}" | ||
|
||
if [ ! -z "$DEBUG" ] | ||
then | ||
echo "curl -s -XGET -H \"Content-Type: application/json\" \"${API}\"" | ||
curl -s -XGET -H "Content-Type: application/json" "${API}" | ||
else | ||
curl -s -XGET -H "Content-Type: application/json" "${API}" | jq -r '.' | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
#!/bin/bash | ||
aws --profile lfproduct-dev dynamodb scan --table-name cla-dev-signatures --max-items 20 | ||
# add: | jq -r '.[].signature_acl' | ||
aws --profile lfproduct-dev dynamodb scan --table-name cla-dev-signatures --max-items 20 | jq -r '.Items' |