From 242c25b57d0d9496910f7d818cbce80c46472b32 Mon Sep 17 00:00:00 2001 From: Brady Wied Date: Fri, 2 May 2025 10:59:13 -0600 Subject: [PATCH 1/7] run on all PRs --- .github/workflows/test.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 1df2db1..ba67e3e 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -10,9 +10,6 @@ on: - main - develop pull_request: - branches: - - main - - develop workflow_dispatch: jobs: From ea9a8f74346bc4e89a2f8844bea882644e15e251 Mon Sep 17 00:00:00 2001 From: Brady Wied Date: Fri, 2 May 2025 11:18:41 -0600 Subject: [PATCH 2/7] Python updates --- .../python/fusionauth/fusionauth_client.py | 6 ++++-- .../fusionauth/fusionauth_client_test.py | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/main/python/fusionauth/fusionauth_client.py b/src/main/python/fusionauth/fusionauth_client.py index 264dc80..e8822f5 100644 --- a/src/main/python/fusionauth/fusionauth_client.py +++ b/src/main/python/fusionauth/fusionauth_client.py @@ -3365,15 +3365,17 @@ def retrieve_user_by_email(self, email): .get() \ .go() - def retrieve_user_by_login_id(self, login_id): + def retrieve_user_by_login_id(self, login_id, login_id_types=None): """ - Retrieves the user for the loginId. The loginId can be either the username or the email. + Retrieves the user for the loginId, using specific loginIdTypes. Attributes: login_id: The email or username of the user. + login_id_types: (Optional) the identity types that FusionAuth will compare the loginId to. Defaults to [email, username] """ return self.start().uri('/api/user') \ .url_parameter('loginId', self.convert_true_false(login_id)) \ + .url_parameter('loginIdTypes', self.convert_true_false(login_id_types)) \ .get() \ .go() diff --git a/src/test/python/fusionauth/fusionauth_client_test.py b/src/test/python/fusionauth/fusionauth_client_test.py index dd72caf..584da08 100644 --- a/src/test/python/fusionauth/fusionauth_client_test.py +++ b/src/test/python/fusionauth/fusionauth_client_test.py @@ -84,6 +84,25 @@ def test_create_user_retrieve_user(self): self.assertFalse('password' in get_user_response.success_response['user']) self.assertFalse('salt' in get_user_response.success_response['user']) + # Retrieve the user via loginId + get_user_response = self.client.retrieve_user_by_login_id('user@example.com') + self.assertEqual(get_user_response.status, 200) + self.assertIsNotNone(get_user_response.success_response) + self.assertIsNone(get_user_response.error_response) + self.assertEqual(get_user_response.success_response['user']['email'], 'user@example.com') + + # Explicit loginIdType + get_user_response = self.client.retrieve_user_by_login_id('user@example.com', ['email']) + self.assertEqual(get_user_response.status, 200) + self.assertIsNotNone(get_user_response.success_response) + self.assertIsNone(get_user_response.error_response) + self.assertEqual(get_user_response.success_response['user']['email'], 'user@example.com') + +# TODO: Once issue 1 is released, this test should pass +# # wrong loginIdType +# get_user_response = self.client.retrieve_user_by_login_id('user@example.com', ['phoneNumber']) +# self.assertEqual(get_user_response.status, 404) + def test_retrieve_user_missing(self): user_id = uuid.uuid4() client_response = self.client.retrieve_user(user_id) From 6bdd827d7d9fa56650ede02213f73049be52367f Mon Sep 17 00:00:00 2001 From: Brady Wied Date: Fri, 2 May 2025 15:24:28 -0600 Subject: [PATCH 3/7] add report method --- src/main/python/fusionauth/fusionauth_client.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/python/fusionauth/fusionauth_client.py b/src/main/python/fusionauth/fusionauth_client.py index e8822f5..6ddcdda 100644 --- a/src/main/python/fusionauth/fusionauth_client.py +++ b/src/main/python/fusionauth/fusionauth_client.py @@ -3541,9 +3541,9 @@ def retrieve_user_login_report(self, user_id, start, end, application_id=None): .get() \ .go() - def retrieve_user_login_report_by_login_id(self, login_id, start, end, application_id=None): + def retrieve_user_login_report_by_login_id(self, login_id, start, end, application_id=None, login_id_types=None): """ - Retrieves the login report between the two instants for a particular user by login Id. If you specify an application id, it will only return the + Retrieves the login report between the two instants for a particular user by login Id, using specific loginIdTypes. If you specify an application id, it will only return the login counts for that application. Attributes: @@ -3551,12 +3551,14 @@ def retrieve_user_login_report_by_login_id(self, login_id, start, end, applicati login_id: The userId id. start: The start instant as UTC milliseconds since Epoch. end: The end instant as UTC milliseconds since Epoch. + login_id_types: (Optional) the identity types that FusionAuth will compare the loginId to. Defaults to [email, username] """ return self.start().uri('/api/report/login') \ .url_parameter('applicationId', self.convert_true_false(application_id)) \ .url_parameter('loginId', self.convert_true_false(login_id)) \ .url_parameter('start', self.convert_true_false(start)) \ .url_parameter('end', self.convert_true_false(end)) \ + .url_parameter('loginIdTypes', self.convert_true_false(login_id_types)) \ .get() \ .go() From 057b5407635e1c65957ab04dd806c6c2231fefff Mon Sep 17 00:00:00 2001 From: Brady Wied Date: Tue, 6 May 2025 16:33:39 -0600 Subject: [PATCH 4/7] revert overloads --- .../python/fusionauth/fusionauth_client.py | 35 +++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/src/main/python/fusionauth/fusionauth_client.py b/src/main/python/fusionauth/fusionauth_client.py index 6ddcdda..267f3fb 100644 --- a/src/main/python/fusionauth/fusionauth_client.py +++ b/src/main/python/fusionauth/fusionauth_client.py @@ -3365,7 +3365,19 @@ def retrieve_user_by_email(self, email): .get() \ .go() - def retrieve_user_by_login_id(self, login_id, login_id_types=None): + def retrieve_user_by_login_id(self, login_id): + """ + Retrieves the user for the loginId. The loginId can be either the username or the email. + + Attributes: + login_id: The email or username of the user. + """ + return self.start().uri('/api/user') \ + .url_parameter('loginId', self.convert_true_false(login_id)) \ + .get() \ + .go() + + def retrieve_user_by_login_id_with_login_id_types(self, login_id, login_id_types=None): """ Retrieves the user for the loginId, using specific loginIdTypes. @@ -3541,7 +3553,26 @@ def retrieve_user_login_report(self, user_id, start, end, application_id=None): .get() \ .go() - def retrieve_user_login_report_by_login_id(self, login_id, start, end, application_id=None, login_id_types=None): + def retrieve_user_login_report_by_login_id(self, login_id, start, end, application_id=None): + """ + Retrieves the login report between the two instants for a particular user by login Id. If you specify an application id, it will only return the + login counts for that application. + + Attributes: + application_id: (Optional) The application id. + login_id: The userId id. + start: The start instant as UTC milliseconds since Epoch. + end: The end instant as UTC milliseconds since Epoch. + """ + return self.start().uri('/api/report/login') \ + .url_parameter('applicationId', self.convert_true_false(application_id)) \ + .url_parameter('loginId', self.convert_true_false(login_id)) \ + .url_parameter('start', self.convert_true_false(start)) \ + .url_parameter('end', self.convert_true_false(end)) \ + .get() \ + .go() + + def retrieve_user_login_report_by_login_id_and_login_id_types(self, login_id, start, end, application_id=None, login_id_types=None): """ Retrieves the login report between the two instants for a particular user by login Id, using specific loginIdTypes. If you specify an application id, it will only return the login counts for that application. From 70c87c29ed567908fffaa5035ce2570eb82a7222 Mon Sep 17 00:00:00 2001 From: Brady Wied Date: Wed, 7 May 2025 07:43:06 -0600 Subject: [PATCH 5/7] test fixes --- .../fusionauth/fusionauth_client_test.py | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/test/python/fusionauth/fusionauth_client_test.py b/src/test/python/fusionauth/fusionauth_client_test.py index 584da08..8f7545c 100644 --- a/src/test/python/fusionauth/fusionauth_client_test.py +++ b/src/test/python/fusionauth/fusionauth_client_test.py @@ -1,4 +1,16 @@ -# Copyright (c) 2024, FusionAuth, All Rights Reserved +# Copyright (c) 2024-2025, FusionAuth, All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the License. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -26,9 +38,8 @@ import json import os -import uuid - import unittest +import uuid from fusionauth.fusionauth_client import FusionAuthClient @@ -92,16 +103,16 @@ def test_create_user_retrieve_user(self): self.assertEqual(get_user_response.success_response['user']['email'], 'user@example.com') # Explicit loginIdType - get_user_response = self.client.retrieve_user_by_login_id('user@example.com', ['email']) + get_user_response = self.client.retrieve_user_by_login_id_with_login_id_types('user@example.com', ['email']) self.assertEqual(get_user_response.status, 200) self.assertIsNotNone(get_user_response.success_response) self.assertIsNone(get_user_response.error_response) self.assertEqual(get_user_response.success_response['user']['email'], 'user@example.com') -# TODO: Once issue 1 is released, this test should pass -# # wrong loginIdType -# get_user_response = self.client.retrieve_user_by_login_id('user@example.com', ['phoneNumber']) -# self.assertEqual(get_user_response.status, 404) + # TODO: Once issue 1 is released, this test should pass + # # wrong loginIdType + # get_user_response = self.client.retrieve_user_by_login_id_with_login_id_types('user@example.com', ['phoneNumber']) + # self.assertEqual(get_user_response.status, 404) def test_retrieve_user_missing(self): user_id = uuid.uuid4() From 3d055a5a5ec29eebbcfda35d16cc40181d4e1914 Mon Sep 17 00:00:00 2001 From: Brady Wied Date: Wed, 7 May 2025 07:59:52 -0600 Subject: [PATCH 6/7] client correct/optional --- src/main/python/fusionauth/fusionauth_client.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/python/fusionauth/fusionauth_client.py b/src/main/python/fusionauth/fusionauth_client.py index 267f3fb..efcd4a7 100644 --- a/src/main/python/fusionauth/fusionauth_client.py +++ b/src/main/python/fusionauth/fusionauth_client.py @@ -3377,13 +3377,13 @@ def retrieve_user_by_login_id(self, login_id): .get() \ .go() - def retrieve_user_by_login_id_with_login_id_types(self, login_id, login_id_types=None): + def retrieve_user_by_login_id_with_login_id_types(self, login_id, login_id_types): """ Retrieves the user for the loginId, using specific loginIdTypes. Attributes: login_id: The email or username of the user. - login_id_types: (Optional) the identity types that FusionAuth will compare the loginId to. Defaults to [email, username] + login_id_types: the identity types that FusionAuth will compare the loginId to. Defaults to [email, username] """ return self.start().uri('/api/user') \ .url_parameter('loginId', self.convert_true_false(login_id)) \ @@ -3572,7 +3572,7 @@ def retrieve_user_login_report_by_login_id(self, login_id, start, end, applicati .get() \ .go() - def retrieve_user_login_report_by_login_id_and_login_id_types(self, login_id, start, end, application_id=None, login_id_types=None): + def retrieve_user_login_report_by_login_id_and_login_id_types(self, login_id, start, end, login_id_types, application_id=None): """ Retrieves the login report between the two instants for a particular user by login Id, using specific loginIdTypes. If you specify an application id, it will only return the login counts for that application. @@ -3582,7 +3582,7 @@ def retrieve_user_login_report_by_login_id_and_login_id_types(self, login_id, st login_id: The userId id. start: The start instant as UTC milliseconds since Epoch. end: The end instant as UTC milliseconds since Epoch. - login_id_types: (Optional) the identity types that FusionAuth will compare the loginId to. Defaults to [email, username] + login_id_types: the identity types that FusionAuth will compare the loginId to. Defaults to [email, username] """ return self.start().uri('/api/report/login') \ .url_parameter('applicationId', self.convert_true_false(application_id)) \ From c27d9b665c10afabdc9b2964eadf7e8952d053ae Mon Sep 17 00:00:00 2001 From: Brady Wied Date: Wed, 7 May 2025 08:33:07 -0600 Subject: [PATCH 7/7] now that this overload does not have opt params, remove defaults --- src/main/python/fusionauth/fusionauth_client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/python/fusionauth/fusionauth_client.py b/src/main/python/fusionauth/fusionauth_client.py index efcd4a7..041efaf 100644 --- a/src/main/python/fusionauth/fusionauth_client.py +++ b/src/main/python/fusionauth/fusionauth_client.py @@ -3383,7 +3383,7 @@ def retrieve_user_by_login_id_with_login_id_types(self, login_id, login_id_types Attributes: login_id: The email or username of the user. - login_id_types: the identity types that FusionAuth will compare the loginId to. Defaults to [email, username] + login_id_types: the identity types that FusionAuth will compare the loginId to. """ return self.start().uri('/api/user') \ .url_parameter('loginId', self.convert_true_false(login_id)) \ @@ -3582,7 +3582,7 @@ def retrieve_user_login_report_by_login_id_and_login_id_types(self, login_id, st login_id: The userId id. start: The start instant as UTC milliseconds since Epoch. end: The end instant as UTC milliseconds since Epoch. - login_id_types: the identity types that FusionAuth will compare the loginId to. Defaults to [email, username] + login_id_types: the identity types that FusionAuth will compare the loginId to. """ return self.start().uri('/api/report/login') \ .url_parameter('applicationId', self.convert_true_false(application_id)) \