Skip to content

Commit 26b3360

Browse files
committed
Add unit test for scenario feature off but admin can still create shadow user using username and origin
1 parent f7f2b3c commit 26b3360

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

spec/request/users_spec.rb

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,55 @@
662662
end
663663

664664
it_behaves_like 'permissions for single object endpoint', ALL_PERMISSIONS
665+
666+
context 'using username and origin' do
667+
let(:params) do
668+
{
669+
username: 'some-user',
670+
origin: 'idp.local'
671+
}
672+
end
673+
674+
let(:user_guid) { 'new-user-guid' }
675+
676+
let(:api_call) { ->(user_headers) { post '/v3/users', params.to_json, user_headers } }
677+
678+
let(:user_json) do
679+
{
680+
guid: user_guid,
681+
created_at: iso8601,
682+
updated_at: iso8601,
683+
username: params[:username],
684+
presentation_name: params[:username],
685+
origin: params[:origin],
686+
metadata: {
687+
labels: {},
688+
annotations: {}
689+
},
690+
links: {
691+
self: { href: %r{#{Regexp.escape(link_prefix)}/v3/users/#{user_guid}} }
692+
}
693+
}
694+
end
695+
696+
let(:expected_codes_and_responses) do
697+
h = Hash.new(
698+
code: 403
699+
)
700+
h['admin'] = {
701+
code: 201,
702+
response_object: user_json
703+
}
704+
h
705+
end
706+
707+
before do
708+
allow(CloudController::DependencyLocator.instance).to receive(:uaa_shadow_user_creation_client).and_return(uaa_client)
709+
allow(uaa_client).to receive(:create_shadow_user).and_return({ 'id' => user_guid })
710+
end
711+
712+
it_behaves_like 'permissions for single object endpoint', ALL_PERMISSIONS
713+
end
665714
end
666715

667716
describe 'when creating a user that exists in uaa' do

0 commit comments

Comments
 (0)