Skip to content

Commit

Permalink
fix brightid connect url
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohamad Bastin committed Jan 9, 2024
1 parent 13f9c6e commit 1fec8f2
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 130 deletions.
24 changes: 5 additions & 19 deletions authentication/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,28 +81,14 @@ def age(self):

@property
def is_meet_verified(self):
# (
# is_verified,
# context_ids,
# ) = BRIGHTID_SOULDBOUND_INTERFACE.get_verification_status(
# self.initial_context_id, "Meet"
# )

# return is_verified

bo = BrightIDConnection.get_connection(self)
return bo.is_meets_verified
try:
bo = BrightIDConnection.get_connection(self)
return bo.is_meets_verified
except BrightIDConnection.DoesNotExist:
return False

@property
def is_aura_verified(self):
# (
# is_verified,
# context_ids,
# ) = BRIGHTID_SOULDBOUND_INTERFACE.get_verification_status(
# self.initial_context_id, "Aura"
# )

# return is_verified
return False

@property
Expand Down
94 changes: 48 additions & 46 deletions faucet/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
NetworkTypes,
TransactionBatch,
)
from faucet.views import CustomException

address = "0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1"
fund_manager = "0x5802f1035AbB8B191bc12Ce4668E3815e8B7Efa0"
Expand Down Expand Up @@ -320,59 +319,62 @@ def setUp(self) -> None:
self.user_profile = self.verified_user

@patch(
"authentication.helpers.BrightIDSoulboundAPIInterface.get_verification_status",
lambda a, b, c: (False, None),
"authentication.models.UserProfile.is_meet_verified",
lambda a: (False, None),
)
def test_claim_max_api_should_fail_if_not_verified(self):
endpoint = reverse(
"FAUCET:claim-max",
kwargs={"faucet_pk": self.test_faucet.pk},
)

response = self.client.post(endpoint, data={"address": "0x12345"})
self.assertEqual(response.status_code, 403)

@patch(
"authentication.helpers.BrightIDSoulboundAPIInterface.get_verification_status",
lambda a, b, c: (True, None),
)
def test_claim_max_api_should_claim_all(self):
endpoint = reverse(
"FAUCET:claim-max",
kwargs={"faucet_pk": self.test_faucet.pk},
)

response = self.client.post(
endpoint, data={"address": "0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1"}
endpoint, data={"address": "0x3E5e9111Ae8eB78Fe1CC3bb8915d5D461F3Ef9A9"}
)
claim_receipt = json.loads(response.content)

self.assertEqual(response.status_code, 200)
self.assertEqual(claim_receipt["amount"], self.test_faucet.max_claim_amount)
self.assertEqual(response.status_code, 403)

@patch(
"authentication.helpers.BrightIDSoulboundAPIInterface.get_verification_status",
lambda a, b, c: (True, None),
)
def test_claim_max_twice_should_fail(self):
endpoint = reverse(
"FAUCET:claim-max",
kwargs={"faucet_pk": self.test_faucet.pk},
)
response_1 = self.client.post(
endpoint, data={"address": "0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1"}
)
self.assertEqual(response_1.status_code, 200)
try:
self.client.post(
endpoint, data={"address": "0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1"}
)
except CustomException:
self.assertEqual(True, True)
# @patch(
# "faucet.faucet_manager.claim_manager.SimpleClaimManager.user_is_meet_verified",
# lambda a: True,
# )
# def test_claim_max_api_should_claim_all(self):
# endpoint = reverse(
# "FAUCET:claim-max",
# kwargs={"faucet_pk": self.test_faucet.pk},
# )

# response = self.client.post(
# endpoint, data={"address": "0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1"}
# )
# claim_receipt = json.loads(response.content)

# self.assertEqual(response.status_code, 200)
# self.assertEqual(claim_receipt["amount"], self.test_faucet.max_claim_amount)

# @patch(
# "faucet.faucet_manager.claim_manager.SimpleClaimManager.user_is_meet_verified",
# lambda a: True,
# )
# def test_claim_max_twice_should_fail(self):
# endpoint = reverse(
# "FAUCET:claim-max",
# kwargs={"faucet_pk": self.test_faucet.pk},
# )
# response_1 = self.client.post(
# endpoint, data={"address": "0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1"}
# )
# self.assertEqual(response_1.status_code, 200)
# try:
# self.client.post(
# endpoint, data={"address":
# "0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1"}
# )
# except CustomException:
# self.assertEqual(True, True)

@patch(
"authentication.helpers.BrightIDSoulboundAPIInterface.get_verification_status",
lambda a, b, c: (True, None),
"authentication.models.UserProfile.is_meet_verified",
lambda a: (True, None),
)
def test_address_validator_evm(self):
endpoint = reverse(
Expand All @@ -382,8 +384,8 @@ def test_address_validator_evm(self):
self.assertEqual(response_1.status_code, 400)

@patch(
"authentication.helpers.BrightIDSoulboundAPIInterface.get_verification_status",
lambda a, b, c: (True, None),
"authentication.models.UserProfile.is_meet_verified",
lambda a: (True, None),
)
def test_get_last_claim_of_user(self):
endpoint = reverse("FAUCET:last-claim")
Expand Down Expand Up @@ -428,8 +430,8 @@ def test_get_last_claim_of_user(self):
self.assertEqual(claim_data["faucet"]["pk"], last_claim.faucet.pk)

@patch(
"authentication.helpers.BrightIDSoulboundAPIInterface.get_verification_status",
lambda a, b, c: (True, None),
"authentication.models.UserProfile.is_meet_verified",
lambda a: (True, None),
)
def test_get_claim_list(self):
endpoint = reverse("FAUCET:claims")
Expand Down
Loading

0 comments on commit 1fec8f2

Please sign in to comment.