Skip to content

Commit 29b97d5

Browse files
committed
Disallow using origin 'uaa' when creating user by username
1 parent 8401ecb commit 29b97d5

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

app/messages/user_create_message.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ def validate(record)
1313
elsif record.username || record.origin
1414
record.errors.add(:origin, message: "'username' is missing") unless record.username
1515
record.errors.add(:username, message: "'origin' is missing") unless record.origin
16+
record.errors.add(:origin, message: "cannot be 'uaa' when creating a user by username") unless record.origin != 'uaa'
1617
else
1718
record.errors.add(:guid, message: "either 'guid' or 'username' and 'origin' must be provided")
1819
end

spec/unit/messages/user_create_message_spec.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,17 @@ module VCAP::CloudController
150150
expect(subject.errors[:origin]).to include("'username' is missing")
151151
end
152152
end
153+
154+
context 'when equal to "uaa"' do
155+
let(:params) do
156+
{ origin: 'uaa' }
157+
end
158+
159+
it 'is not valid' do
160+
expect(subject).not_to be_valid
161+
expect(subject.errors[:origin]).to include("cannot be 'uaa' when creating a user by username")
162+
end
163+
end
153164
end
154165
end
155166
end

0 commit comments

Comments
 (0)