Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
jwtSubject renamed to jwtToken
  • Loading branch information
axshani committed Oct 12, 2022
commit 3efbe69b8689f5c861377ced78da0a58b872c8b6
4 changes: 3 additions & 1 deletion e2e_tests/customerToken_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ def test_create_token():
response = client.customerTokens.create_token(request)
assert response.data.type == "customerBearerToken"


def test_create_jwt_token():
account_id = create_individual_customer()
request = CreateCustomerToken(account_id, "customers accounts",
jwt_subject="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9fQ")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is jwt_subject and jwt_token the same field? What is the diff between these 2 fields?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, they are not the same, you understood correctly it should be the token.
the jwt_subject should be set for the customer in order to identify that the token sent is related to the specific customer

jwt_token="eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IlZPV3VLR1R4eFlwRUNWSlAwdDRTNiJ9.eyJpc3MiOiJodHRwczovL2Rldi04NTRvbjk3dC51cy5hdXRoMC5jb20vIiwic3ViIjoiYkpjUkQ1SHo2eWRDWXlaTDVnTjE4MXo0OGxKamFOQURAY2xpZW50cyIsImF1ZCI6Imh0dHBzOi8vZGV2LTg1NG9uOTd0LnVzLmF1dGgwLmNvbS9hcGkvdjIvIiwiaWF0IjoxNjQyOTMwNDA5LCJleHAiOjE2NDMwMTY4MDksImF6cCI6ImJKY1JENUh6NnlkQ1l5Wkw1Z04xODF6NDhsSmphTkFEIiwiZ3R5IjoiY2xpZW50LWNyZWRlbnRpYWxzIn0.DCF_ODpiBPhn-fcr-FF3-Ayf6fq9g8UjSqTssfvdALNxZDQMGXaQeCIisy2NLrhF81PHAX3dZzcZbpeO93OlOAomXlaVzNomEd-pCLvjv1dQoQRc2BB3IMWUxbPBdGV7kztJzIfUwrOBTNV-DqSdB4SoGYROveFa3An4Mlj2FjArTXDXhnUytq15X5p_k4zLLNzznHVd-Tdcnd7hz9sA1vvtWXu")
response = client.customerTokens.create_token(request)
assert response.data.type == "customerBearerToken"


def test_create_token_verification():
account_id = create_individual_customer()
request = CreateCustomerTokenVerification(account_id, "sms")
Expand Down
10 changes: 6 additions & 4 deletions unit/models/customerToken.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from unit.models import *


class CustomerTokenDTO(object):
def __init__(self, token: str, expires_in: int):
self.type = "customerBearerToken"
Expand All @@ -9,6 +10,7 @@ def __init__(self, token: str, expires_in: int):
def from_json_api(_id, _type, attributes, relationships):
return CustomerTokenDTO(attributes["token"], attributes["expiresIn"])


class CustomerVerificationTokenDTO(object):
def __init__(self, verification_token: str):
self.type = "customerTokenVerification"
Expand All @@ -22,13 +24,13 @@ def from_json_api(_id, _type, attributes, relationships):
class CreateCustomerToken(UnitRequest):
def __init__(self, customer_id: str, scope: str, verification_token: Optional[str] = None,
verification_code: Optional[str] = None, expires_in: Optional[int] = None,
jwt_subject: Optional[str] = None):
jwt_token: Optional[str] = None):
self.customer_id = customer_id
self.scope = scope
self.verification_token = verification_token
self.verification_code = verification_code
self.expires_in = expires_in
self.jwt_subject = jwt_subject
self.jwt_token = jwt_token

def to_json_api(self) -> Dict:
payload = {
Expand All @@ -49,8 +51,8 @@ def to_json_api(self) -> Dict:
if self.verification_code:
payload["data"]["attributes"]["verificationCode"] = self.verification_code

if self.jwt_subject:
payload["data"]["attributes"]["jwtSubject"] = self.jwt_subject
if self.jwt_token:
payload["data"]["attributes"]["jwtToken"] = self.jwt_token

return payload

Expand Down