forked from kinde-oss/kinde-python-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_organization_users.py
More file actions
119 lines (100 loc) · 4.27 KB
/
test_organization_users.py
File metadata and controls
119 lines (100 loc) · 4.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/usr/bin/env python3
"""
Test script for organization user endpoints in the management client.
"""
import os
import sys
# Load environment variables from .env if available
try:
from dotenv import load_dotenv
load_dotenv()
except ImportError:
pass # If python-dotenv is not installed, skip loading .env
from kinde_sdk.management.management_client import ManagementClient
def test_organization_users():
"""Test the organization users endpoints."""
# Get credentials from environment variables
domain = os.getenv('KINDE_DOMAIN')
client_id = os.getenv('KINDE_CLIENT_ID')
client_secret = os.getenv('KINDE_CLIENT_SECRET')
missing = []
if not domain:
missing.append('KINDE_DOMAIN')
if not client_id:
missing.append('KINDE_CLIENT_ID')
if not client_secret:
missing.append('KINDE_CLIENT_SECRET')
if missing:
print(f"Please set the following environment variables: {', '.join(missing)}")
print("You can create a .env file with these variables for local development.")
return
try:
# Initialize the management client
client = ManagementClient(domain, client_id, client_secret)
print("✅ Management client initialized successfully")
# Test that the organization user methods exist
methods_to_test = [
'get_organization_users',
'add_organization_user',
'update_organization_user',
'remove_organization_user',
'get_organization_user_roles',
'add_organization_user_role',
'remove_organization_user_role',
'get_organization_user_permissions',
'add_organization_user_permission',
'remove_organization_user_permission',
]
for method_name in methods_to_test:
if hasattr(client, method_name):
print(f"✅ Method {method_name} exists")
else:
print(f"❌ Method {method_name} is missing")
# Test that other new endpoints exist (using actual generated method names)
other_methods = [
'get_properties',
'get_user_properties',
'get_organization_properties',
'get_webhooks',
'get_event', # Changed from get_events (singular)
'get_connections',
'get_business',
'get_environment_feature_flags',
'get_organization_feature_flags',
'get_user_feature_flag', # Changed from get_user_feature_flags (singular)
'update_user_password',
'refresh_user_refresh_claim', # Changed from refresh_user_claims (based on action name)
]
print("\nTesting other new endpoints:")
for method_name in other_methods:
if hasattr(client, method_name):
print(f"✅ Method {method_name} exists")
else:
print(f"❌ Method {method_name} is missing")
# Let's also check what methods are actually available
print("\n🔍 Available methods on ManagementClient:")
available_methods = [method for method in dir(client) if not method.startswith('_') and callable(getattr(client, method))]
available_methods.sort()
for method in available_methods[:20]: # Show first 20 methods
print(f" - {method}")
if len(available_methods) > 20:
print(f" ... and {len(available_methods) - 20} more methods")
# Specifically check for get_ methods to debug the get_business issue
print("\n🔍 All get_ methods:")
get_methods = [method for method in available_methods if method.startswith('get_')]
get_methods.sort()
for method in get_methods:
print(f" - {method}")
# Check if get_business specifically exists
if hasattr(client, 'get_business'):
print("\n✅ get_business method exists!")
else:
print("\n❌ get_business method is missing!")
print("\n🎉 All tests completed!")
except Exception as e:
print(f"❌ Error: {e}")
return False
return True
if __name__ == "__main__":
success = test_organization_users()
sys.exit(0 if success else 1)