Skip to content

Commit

Permalink
Fixed broken tests after merge. test_api now mocks half the auth code…
Browse files Browse the repository at this point in the history
…, but still checks iss/sub, so you can fail if the headers don't match the account
  • Loading branch information
dhakim87 committed Mar 25, 2020
2 parents befd63e + 7ee2e61 commit eacbfec
Show file tree
Hide file tree
Showing 7 changed files with 6,000 additions and 199 deletions.
24 changes: 4 additions & 20 deletions microsetta_private_api/api/implementation.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,33 +68,17 @@ def not_yet_implemented():
def register_account(body, token_info):
# First register with AuthRocket, then come here to make the account
new_acct_id = str(uuid.uuid4())
body["id"] = new_acct_id
account_obj = Account.from_dict(body, token_info['iss'], token_info['sub'])

with Transaction() as t:
kit_repo = KitRepo(t)
kit = kit_repo.get_kit(body['kit_name'])
if kit is None:
return jsonify(error=404, text="Kit name not found"), 404

acct_repo = AccountRepo(t)
# TODO: The email they provide our website may not match the email they
# use for login to our Identity Provider. If that occurs, should we
# reject the account registration? If we don't use the email from the
# IDP, we have to do our own email validation...
acct_repo.create_account(Account(
new_acct_id,
body['email'],
"standard",
token_info['iss'],
token_info['sub'],
body['first_name'],
body['last_name'],
Address(
body['address']['street'],
body['address']['city'],
body['address']['state'],
body['address']['post_code'],
body['address']['country_code'],
)
))
acct_repo.create_account(account_obj)
new_acct = acct_repo.get_account(new_acct_id)
t.commit()

Expand Down

0 comments on commit eacbfec

Please sign in to comment.