-
Notifications
You must be signed in to change notification settings - Fork 322
issue-1294 - implement user version 3 api #1333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
issue-1294 - implement user version 3 api #1333
Conversation
|
This PR would supersede #1297 |
Kehrlann
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution! Have you tested this against a CF deployment?
Please consider adding an integration test for creating a user by username + origin.
|
|
||
| this.cloudFoundryClient | ||
| .usersV3() | ||
| .create(CreateUserRequest.builder().userId(userId).build()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this work if the GUID does not match that of a UAA user?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I don't believe a UAA user is required to create the CF user. The user won't be able to login of course ;)
Locally I just added a sysout to have the user print out...
mvn clean test -Dtest=org.cloudfoundry.client.v3.UsersTest#list
10:36:48.385 main cloudfoundry-client.test Performing clean slate cleanup. Should happen once per integration test run.
UserResource{createdAt=2025-12-31T17:36:56Z, id=test-user-id-4e2dt, links={self=Link{href=https:///v3/users/test-user-id-4e2dt, method=null}}, updatedAt=2025-12-31T17:36:56Z, username=null, presentationName=test-user-id-4e2dt, origin=null, metadata=Metadata{annotations={}, labels={}}}
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 13.20 s -- in org.cloudfoundry.client.v3.UsersTest
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking about this, how do I create a test that runs on other cloud foundry installations. I don't think there any api that allows me to create / manipulate "origins".
Also when the origin does exists, create actually validate the user name against that origin ....
Suppressed: org.cloudfoundry.client.v3.ClientV3Exception: CF-UnprocessableEntity(10008): User with username '<id-exists>' and origin 'ldap' already exists.
at org.cloudfoundry.reactor.util.ErrorPayloadMappers.lambda$null$2(ErrorPayloadMappers.java:62)
Suppressed: The stacktrace has been enhanced by Reactor, refer to additional information below:
I have not been able to successfully create a user with username and origin, I get a unknown exception, even when I directly user the API on the command line
$ cf curl -X POST /v3/users -d @data.json
{
"origin": "ldap",
"username": "<valid-ldap-user>"
}
{
"errors": [
{
"code": 10001,
"detail": "An unknown error occurred.",
"title": "UnknownError"
}
]
}
**I did find one bug will trying this out locally, see bug fix about allowing username and origin in the create user request
c3349a9
| /** | ||
| * Origin of the user to be created. This can only be provided together with username and cannot be uaa. | ||
| */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What kind of error do we get from CAPI if username is provided with userId ; or without origin? What if we pass the uaa origin?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The commend is copied over from the documentation
https://v3-apidocs.cloudfoundry.org/version/3.208.0/index.html#create-a-user
origin | string | Origin of the user to be created. This can only be provided together with username and cannot be uaa.
- if origin is passed with user id
java.lang.AssertionError: expectation "expectNextCount(1)" failed (expected: count = 1; actual: counted = 0; signal: onError(org.cloudfoundry.client.v3.ClientV3Exception: CF-UnprocessableEntity(10008): Origin cannot be provided with 'guid'))
- if uaa is passed as origin when using user name
Suppressed: org.cloudfoundry.client.v3.ClientV3Exception: CF-UnprocessableEntity(10008): Origin cannot be 'uaa' when creating a user by username
…using username and origin and integration clean up should use version 3
No description provided.