diff --git a/alice/config.py b/alice/config.py index be27b22..c39d9a0 100644 --- a/alice/config.py +++ b/alice/config.py @@ -3,9 +3,9 @@ @dataclass class Config: - onboarding_url: str = "https://pre.alicebiometrics.com/onboarding" - sandbox_url: str = "https://pre.alicebiometrics.com/onboarding/sandbox" - auth_url: str = "https://pre.alicebiometrics.com/auth" + onboarding_url: str = "https://apis.alicebiometrics.com/onboarding" + sandbox_url: str = "https://apis.alicebiometrics.com/onboarding/sandbox" + auth_url: str = "https://apis.alicebiometrics.com/auth" api_key: str = None sandbox_token: str = None send_agent: bool = True diff --git a/alice/webhooks/webhooks_client.py b/alice/webhooks/webhooks_client.py index 71c27e0..895248f 100644 --- a/alice/webhooks/webhooks_client.py +++ b/alice/webhooks/webhooks_client.py @@ -52,7 +52,6 @@ def get_available_events(self, verbose: bool = False) -> Response: backend_token = self.auth.create_backend_token().unwrap() print_token("backend_token_with_user", backend_token, verbose=verbose) - headers = self._auth_headers(backend_token) response = requests.get(self.url + "/events", headers=headers) diff --git a/tests/test_integration_webhooks.py b/tests/test_integration_webhooks.py index 6735c2d..2e0af19 100644 --- a/tests/test_integration_webhooks.py +++ b/tests/test_integration_webhooks.py @@ -15,15 +15,14 @@ def test_should_return_an_error_when_the_api_key_is_not_configured(): assert_failure(result) -def test_should_execute_all_webhook_lifecycle( - given_valid_api_key, given_any_valid_mail -): +def test_should_execute_all_webhook_lifecycle(given_valid_api_key): config = Config(api_key=given_valid_api_key) webhooks_client = Webhooks.from_config(config) # Check Available events - available_events = webhooks_client.get_available_events().unwrap() - selected_event = available_events[0] + result = webhooks_client.get_available_events() + assert_success(result, value_is_instance_of=list) + selected_event = result.value[0] # Create a new Webhook webhook = Webhook( @@ -34,7 +33,7 @@ def test_should_execute_all_webhook_lifecycle( event_version=selected_event.get("version"), secret=str(secrets.token_hex(20)), ) - webhook_id = webhooks_client.create_webhook(webhook).unwrap() + webhook_id = webhooks_client.create_webhook(webhook=webhook).unwrap_or_return() # Update an existent Webhook webhook_to_update = Webhook( @@ -63,15 +62,21 @@ def test_should_execute_all_webhook_lifecycle( result = webhooks_client.get_webhooks() assert_success(result, value_is_instance_of=list) - # Delete a configured webhook - result = webhooks_client.delete_webhook(webhook_id) - assert_success(result) - # Retrieve las webhook result of an specific webhook result = webhooks_client.get_last_webhook_result(webhook_id) + assert_success(result, value_is_instance_of=dict) + + # Retrieve all webhook results of an specific webhook + result = webhooks_client.get_webhook_results(webhook_id) + assert_success(result, value_is_instance_of=list) + assert len(result.value) > 0 + + # Delete a configured webhook + result = webhooks_client.delete_webhook(webhook_id) assert_success(result) # Retrieve all webhook results of an specific webhook result = webhooks_client.get_webhook_results(webhook_id) assert_success(result, value_is_instance_of=list) - assert not any([webhook.webhook_id == webhook_id for webhook in result.value]) + for webhook in result.value: + assert not webhook.get("webhook_id") == webhook_id