Skip to content

Conversation

@SaifuddinMerchant
Copy link
Contributor

No description provided.

@SaifuddinMerchant
Copy link
Contributor Author

This PR would supersede #1297

Copy link
Contributor

@Kehrlann Kehrlann left a 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())
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor Author

@SaifuddinMerchant SaifuddinMerchant Dec 31, 2025

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

Comment on lines +44 to +46
/**
* Origin of the user to be created. This can only be provided together with username and cannot be uaa.
*/
Copy link
Contributor

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?

Copy link
Contributor Author

@SaifuddinMerchant SaifuddinMerchant Dec 31, 2025

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.

  1. 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'))

  1. 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants