Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion onelogin/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class User(BaseModel):
directory_id: Optional[StrictInt] = Field(None, description="The ID of the OneLogin Directory of the user.")
trusted_idp_id: Optional[StrictInt] = Field(None, description="The ID of the OneLogin Trusted IDP of the user.")
manager_ad_id: Optional[StrictStr] = Field(None, description="The ID of the user's manager in Active Directory.")
manager_user_id: Optional[StrictInt] = Field(None, description="The OneLogin User ID for the user's manager.")
manager_user_id: Optional[StrictStr] = Field(None, description="The OneLogin User ID for the user's manager.")
samaccountname: Optional[StrictStr] = Field(None, description="The user's Active Directory username.")
member_of: Optional[StrictStr] = Field(None, description="The user's directory membership.")
userprincipalname: Optional[StrictStr] = Field(None, description="The principle name of the user.")
Expand Down
114 changes: 114 additions & 0 deletions test/test_user_manager_user_id_fix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# coding: utf-8

"""
OneLogin API

OpenAPI Specification for OneLogin # noqa: E501

The version of the OpenAPI document: 3.1.1
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
"""


import unittest
import datetime

import onelogin
from onelogin.models.user import User # noqa: E501
from onelogin.rest import ApiException


class TestUserManagerUserIdFix(unittest.TestCase):
"""Test case for manager_user_id field fix (GitHub issue #100)"""

def setUp(self):
pass

def tearDown(self):
pass

def test_manager_user_id_with_string_value(self):
"""
Test that manager_user_id accepts string values from API response.
This test validates the fix for GitHub issue #100 where API returns
manager_user_id as string but model expected integer.
"""
user_data = {
"id": 123,
"username": "testuser",
"email": "test@example.com",
"manager_user_id": "252462756" # String value as returned by API
}

# This should work without validation errors
user = User.from_dict(user_data)
self.assertEqual(user.manager_user_id, "252462756")
self.assertIsInstance(user.manager_user_id, str)

def test_manager_user_id_with_none_value(self):
"""
Test that manager_user_id accepts None values.
"""
user_data = {
"id": 123,
"username": "testuser",
"email": "test@example.com",
"manager_user_id": None
}

user = User.from_dict(user_data)
self.assertIsNone(user.manager_user_id)

def test_manager_user_id_missing_field(self):
"""
Test that manager_user_id can be omitted (defaults to None).
"""
user_data = {
"id": 123,
"username": "testuser",
"email": "test@example.com"
# manager_user_id field is omitted
}

user = User.from_dict(user_data)
self.assertIsNone(user.manager_user_id)

def test_user_serialization_with_manager_user_id(self):
"""
Test that User can be serialized back to dict with manager_user_id.
"""
user_data = {
"id": 123,
"username": "testuser",
"email": "test@example.com",
"manager_user_id": "252462756"
}

user = User.from_dict(user_data)
user_dict = user.to_dict()

self.assertEqual(user_dict["manager_user_id"], "252462756")
self.assertIsInstance(user_dict["manager_user_id"], str)

def test_parse_obj_compatibility(self):
"""
Test that parse_obj method (used in API deserialization) works correctly.
This specifically tests the flow mentioned in the original issue traceback.
"""
user_data = {
"id": 123,
"username": "testuser",
"email": "test@example.com",
"manager_user_id": "252462756"
}

# This is the method called in the traceback from the original issue
user = User.parse_obj(user_data)
Comment thread
Subterrane marked this conversation as resolved.
self.assertEqual(user.manager_user_id, "252462756")
self.assertIsInstance(user.manager_user_id, str)


if __name__ == '__main__':
unittest.main()