usso 0.20.0__tar.gz → 0.20.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: usso
3
- Version: 0.20.0
3
+ Version: 0.20.2
4
4
  Summary: A plug-and-play client for integrating universal single sign-on (SSO) with Python frameworks, enabling secure and seamless authentication across microservices.
5
5
  Author-email: Mahdi Kiani <mahdikiany@gmail.com>
6
6
  Maintainer-email: Mahdi Kiani <mahdikiany@gmail.com>
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "usso"
7
- version = "0.20.0"
7
+ version = "0.20.2"
8
8
  description = "A plug-and-play client for integrating universal single sign-on (SSO) with Python frameworks, enabling secure and seamless authentication across microservices."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.8"
@@ -88,14 +88,6 @@ class UssoAPI(metaclass=Singleton):
88
88
  )
89
89
  )
90
90
 
91
- def get_user_credentials(self, user_id: str, **kwargs) -> UserData:
92
- return UserData(
93
- **self._request(
94
- endpoint=f"website/users/{user_id}/credentials",
95
- **kwargs,
96
- )
97
- )
98
-
99
91
  def get_user_by_credentials(self, credentials: dict, **kwargs) -> UserData:
100
92
  return UserData(
101
93
  **self._request(
@@ -133,7 +125,7 @@ class UssoAPI(metaclass=Singleton):
133
125
  credentials: dict | None = None,
134
126
  **kwargs,
135
127
  ) -> UserData:
136
-
128
+ user_data = user_data or {}
137
129
  if credentials:
138
130
  user_data["authenticators"] = [credentials]
139
131
  return UserData(
@@ -20,7 +20,7 @@ class UserData(BaseModel):
20
20
  phone: str | None = None
21
21
  authentication_method: str | None = None
22
22
  is_active: bool = False
23
- jti: str
23
+ jti: str | None = None
24
24
  data: dict | None = None
25
25
  token: str | None = None
26
26
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: usso
3
- Version: 0.20.0
3
+ Version: 0.20.2
4
4
  Summary: A plug-and-play client for integrating universal single sign-on (SSO) with Python frameworks, enabling secure and seamless authentication across microservices.
5
5
  Author-email: Mahdi Kiani <mahdikiany@gmail.com>
6
6
  Maintainer-email: Mahdi Kiani <mahdikiany@gmail.com>
@@ -0,0 +1,56 @@
1
+ import os
2
+ import unittest
3
+
4
+ from usso.api import UssoAPI
5
+ from usso.core import UserData, Usso
6
+
7
+
8
+ class TestAPI(unittest.TestCase):
9
+ def get_usso(self):
10
+ return UssoAPI(
11
+ url="https://sso.usso.io",
12
+ api_key=os.getenv("USSO_API_KEY"),
13
+ )
14
+
15
+ def test_get_users(self):
16
+ usso_api = self.get_usso()
17
+ users = usso_api.get_users()
18
+ self.assertIsInstance(users, list)
19
+ for user in users:
20
+ self.assertIsInstance(user, UserData)
21
+ return users
22
+
23
+ def test_get_user(self):
24
+ users = self.test_get_users()
25
+ if len(users) == 0:
26
+ self.skipTest("No users found")
27
+ user = users[0]
28
+ usso_api = self.get_usso()
29
+ user = usso_api.get_user(user["user_id"])
30
+ self.assertIsInstance(user, UserData)
31
+ return user
32
+
33
+ def test_get_user_by_credentials(self):
34
+ usso_api = self.get_usso()
35
+ users = usso_api._request(endpoint="website/users")
36
+ if len(users) == 0:
37
+ self.skipTest("No users found")
38
+ for user in users:
39
+ for auth in user['authenticators']:
40
+ cred = {
41
+ "auth_method": auth["auth_method"],
42
+ "representor": auth["representor"],
43
+ }
44
+ user = usso_api.get_user_by_credentials(cred)
45
+ self.assertIsInstance(user, UserData)
46
+ return user
47
+
48
+ def test_create_user_by_credentials(self):
49
+ usso_api = self.get_usso()
50
+ telegram_id = os.getenv("TELEGRAM_ID")
51
+ cred = {"auth_method": "telegram", "representor": telegram_id}
52
+ usso_api.create_user_by_credentials(credentials=cred)
53
+
54
+
55
+ if __name__ == "__main__":
56
+ unittest.main()
@@ -1,67 +0,0 @@
1
- import os
2
- import unittest
3
-
4
- from usso.api import UssoAPI
5
-
6
-
7
- class TestAPI(unittest.TestCase):
8
- def get_usso(self):
9
- return UssoAPI(
10
- url="https://sso.usso.io",
11
- api_key=os.getenv("USSO_API_KEY"),
12
- )
13
-
14
- def test_get_users(self):
15
- usso_api = self.get_usso()
16
- users = usso_api.get_users()
17
- self.assertIsInstance(users, list)
18
- for user in users:
19
- self.assertIsInstance(user, dict)
20
- self.assertIn("user_id", user)
21
- self.assertIn("username", user)
22
- self.assertIn("email", user)
23
- return users
24
-
25
- def test_get_user(self):
26
- users = self.test_get_users()
27
- if len(users) == 0:
28
- self.skipTest("No users found")
29
- user = users[0]
30
- usso_api = self.get_usso()
31
- user = usso_api.get_user(user["user_id"])
32
- self.assertIsInstance(user, dict)
33
- self.assertIn("user_id", user)
34
- self.assertIn("username", user)
35
- self.assertIn("email", user)
36
- return user
37
-
38
- def test_get_user_credentials(self):
39
- users = self.test_get_users()
40
- if len(users) == 0:
41
- self.skipTest("No users found")
42
- user = users[0]
43
- usso_api = self.get_usso()
44
- credentials = usso_api.get_user_credentials(user["user_id"])
45
- self.assertIsInstance(credentials, list)
46
- for credential in credentials:
47
- self.assertIsInstance(credential, dict)
48
- self.assertIn("credential_id", credential)
49
- self.assertIn("type", credential)
50
- self.assertIn("created_at", credential)
51
- return credentials
52
-
53
- def test_get_user_by_credentials(self):
54
- credentials = self.test_get_user_credentials()
55
- if len(credentials) == 0:
56
- self.skipTest("No credentials found")
57
- credential = credentials[0]
58
- usso_api = self.get_usso()
59
- user = usso_api.get_user_by_credentials(credential)
60
- self.assertIsInstance(user, dict)
61
- self.assertIn("user_id", user)
62
- self.assertIn("username", user)
63
- self.assertIn("email", user)
64
- return user
65
-
66
- if __name__ == "__main__":
67
- unittest.main()
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes