File tree Expand file tree Collapse file tree 2 files changed +16
-9
lines changed
Expand file tree Collapse file tree 2 files changed +16
-9
lines changed Original file line number Diff line number Diff line change @@ -47,7 +47,13 @@ def create
4747
4848 user = UserCreate . new . create ( message :)
4949
50- render status : :created , json : Presenters ::V3 ::UserPresenter . new ( user , uaa_users : User . uaa_users_info ( [ user . guid ] ) )
50+ if message . username && message . origin
51+ render status : :created ,
52+ json : Presenters ::V3 ::UserPresenter . new ( user ,
53+ uaa_users : { user . guid => { 'username' => message . username , 'id' => user . guid , 'origin' => message . origin } } )
54+ else
55+ render status : :created , json : Presenters ::V3 ::UserPresenter . new ( user , uaa_users : User . uaa_users_info ( [ user . guid ] ) )
56+ end
5157 rescue VCAP ::CloudController ::UaaUnavailable
5258 raise CloudController ::Errors ::ApiError . new_from_details ( 'UaaUnavailable' )
5359 rescue UserCreate ::Error => e
Original file line number Diff line number Diff line change 905905 end
906906
907907 before do
908- allow ( uaa_client ) . to receive ( :users_for_ids ) . with ( [ 'new-user-guid' ] ) . and_return (
909- {
910- user_guid => {
911- 'username' => 'some-user' ,
912- 'origin' => 'idp.local'
913- }
914- }
915- )
916908 allow ( uaa_client ) . to receive ( :create_shadow_user ) . and_return ( { 'id' => user_guid } )
917909 end
918910
919911 it_behaves_like 'permissions for single object endpoint' , ALL_PERMISSIONS
912+
913+ it 'constructs the response with the given information without calling the UAA again' do
914+ post '/v3/users' , params . to_json , admin_header
915+
916+ expect ( last_response ) . to have_status_code ( 201 )
917+ expect ( parsed_response ) . to match_json_response ( user_json )
918+
919+ expect ( uaa_client ) . not_to have_received ( :users_for_ids )
920+ end
920921 end
921922
922923 context 'when parameters are invalid' do
You can’t perform that action at this time.
0 commit comments