onelogin / onelogin-java-sdk

5 stars 13 forks source link

Fix `samaccountname` parameter spelling #57

Closed tbigby-kristin closed 1 year ago

tbigby-kristin commented 1 year ago

Status

READY

Migrations

NO

Description

Fixes an issue where listUsers method fails when returning the samaccountname field from the API. It was misspelt in the SDK as samaccount_name, whereas the API returns samaccountname.

When querying the samaccountname, or all attributes, for users from the API, the User object would fail to build with an IllegalArgumentException in User.validateJsonObject():

IllegalArgumentException: The field samaccountname in the JSON string is not defined in the User properties.

Related PRs

None

Todos

None

Deploy Notes

Of note, this fix changes the getter and setter methods of samaccountname for User.

Previously, they were getSamaccountName() with a capital N because of the underscore.

Now, they are getSamaccountname() with no capital N.

If anyone were able to get the SDK to work previously even though the wrong attribute name were used, they would need to update any references to getSamaccountName() or setSamaccountName().

Steps to Test or Reproduce

Obviously, this requires testing against a real OneLogin API, with the relevant Bearer token authentication. Example at https://github.com/onelogin/onelogin-java-sdk/blob/master/docs/DefaultApi.md#listUsers .

My code looks similar to:

List<User> users = apiInstance.listUsers(
        authorization,
        42, //appId
        50, //limit number of users - default 50
        1, //page number of results to fetch
        null, //cursor of results
        null, //created since
        null, //created until
        null, //updated since
        null, //updated until
        null, //last login since
        null, //last login until
        null, //first name
        null, //last name
        null, //email
        null, //username
        null, //samaccountname
        null, //directory ID
        null, //external ID
        null, //user IDs
        null, //custom attributes
        null //fields to return - all fields
    );

Of particular note, if you are determining which fields to return (last parameter), make sure to include samaccountname in the list!

Impacted Areas in Application

List general components of the application that this PR will affect:

tbigby-kristin commented 1 year ago

Closing as this issue has been resolved in #60 - version 3.1.1.