Skip to content

Commit

Permalink
Merge branch 'feat/custom-data-access' of https://github.com/uc-cdis/…
Browse files Browse the repository at this point in the history
…fence into feat/custom-data-access
  • Loading branch information
BinamB committed Jul 5, 2022
2 parents 1afd7c2 + 15d43d7 commit ba1c456
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
6 changes: 3 additions & 3 deletions .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -200,14 +200,14 @@
"filename": "tests/conftest.py",
"hashed_secret": "1348b145fa1a555461c1b790a2f66614781091e9",
"is_verified": false,
"line_number": 1482
"line_number": 1513
},
{
"type": "Base64 High Entropy String",
"filename": "tests/conftest.py",
"hashed_secret": "227dea087477346785aefd575f91dd13ab86c108",
"is_verified": false,
"line_number": 1505
"line_number": 1536
}
],
"tests/credentials/google/test_credentials.py": [
Expand Down Expand Up @@ -282,5 +282,5 @@
}
]
},
"generated_at": "2022-04-07T17:08:49Z"
"generated_at": "2022-06-27T19:35:11Z"
}
16 changes: 14 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
import flask
from datetime import datetime
import mock
import uuid
import random
import string

from addict import Dict
from authutils.testing.fixtures import (
Expand Down Expand Up @@ -262,6 +265,13 @@ def kid_2():
return "test-keypair-2"


def random_txn():
"""Return a random txn to use for mocking passports and visas"""
random_chars = random.choices(string.ascii_lowercase + string.digits, k=33)
random_chars[16] = "."
return "".join(random_chars)


def get_subjects_to_passports(
subject_to_encoded_visas=None, passport_exp=None, kid=None, rsa_private_key=None
):
Expand All @@ -281,8 +291,8 @@ def get_subjects_to_passports(
"iat": int(time.time()),
"exp": int(time.time()) + 1000,
"scope": "openid ga4gh_passport_v1 email profile",
"jti": "jtiajoidasndokmasdl",
"txn": "sapidjspa.asipidja",
"jti": str(uuid.uuid4()),
"txn": random_txn(),
"name": "",
"ga4gh_visa_v1": {
"type": "https://ras.nih.gov/visas/v1",
Expand All @@ -308,6 +318,8 @@ def get_subjects_to_passports(
"kid": kid,
}
new_passport = {
"jti": str(uuid.uuid4()),
"txn": random_txn(),
"iss": "https://stsstg.nih.gov",
"sub": subject,
"iat": int(time.time()),
Expand Down
8 changes: 5 additions & 3 deletions tests/dbgap_sync/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import time
import jwt
import uuid

from unittest.mock import MagicMock, patch
from yaml import safe_load as yaml_load
Expand Down Expand Up @@ -28,6 +29,8 @@
User,
)

from tests.conftest import random_txn

logger = get_logger(__name__)

LOCAL_CSV_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "data/csv")
Expand Down Expand Up @@ -259,9 +262,8 @@ def get_test_encoded_decoded_visa_and_exp(
"iat": int(time.time()),
"exp": expires,
"scope": "openid ga4gh_passport_v1 email profile",
"jti": "jtiajoidasndokmasdl"
+ str(expires), # expires to make unique from others
"txn": "sapidjspa.asipidja" + str(expires),
"jti": str(uuid.uuid4()),
"txn": random_txn(),
"name": "",
"ga4gh_visa_v1": {
"type": "https://ras.nih.gov/visas/v1",
Expand Down

0 comments on commit ba1c456

Please sign in to comment.