@@ -27,7 +27,35 @@ module VCAP::CloudController
2727
2828 it 'is not valid' do
2929 expect ( subject ) . not_to be_valid
30- expect ( subject . errors [ :guid ] ) . to include ( 'must be between 1 and 200 characters' )
30+ expect ( subject . errors [ :guid ] ) . to include ( "either 'guid' or 'username' and 'origin' must be provided" )
31+ end
32+ end
33+
34+ context 'when guid and username is provided' do
35+ let ( :params ) do
36+ {
37+ username : 'meow' ,
38+ guid : 'some-user-guid'
39+ }
40+ end
41+
42+ it 'is not valid' do
43+ expect ( subject ) . not_to be_valid
44+ expect ( subject . errors [ :username ] ) . to include ( "cannot be provided with 'guid'" )
45+ end
46+ end
47+
48+ context 'when guid and origin is provided' do
49+ let ( :params ) do
50+ {
51+ origin : 'meow' ,
52+ guid : 'some-user-guid'
53+ }
54+ end
55+
56+ it 'is not valid' do
57+ expect ( subject ) . not_to be_valid
58+ expect ( subject . errors [ :origin ] ) . to include ( "cannot be provided with 'guid'" )
3159 end
3260 end
3361
@@ -45,7 +73,7 @@ module VCAP::CloudController
4573 end
4674 end
4775
48- context 'guid' do
76+ describe 'guid' do
4977 context 'when not a string' do
5078 let ( :params ) do
5179 { guid : 5 }
@@ -75,6 +103,54 @@ module VCAP::CloudController
75103 end
76104 end
77105 end
106+
107+ describe 'username' do
108+ context 'when not a string' do
109+ let ( :params ) do
110+ { username : 5 }
111+ end
112+
113+ it 'is not valid' do
114+ expect ( subject ) . not_to be_valid
115+ expect ( subject . errors [ :username ] ) . to include ( 'must be a string' )
116+ end
117+ end
118+
119+ context 'when origin is missing' do
120+ let ( :params ) do
121+ { username : 5 }
122+ end
123+
124+ it 'is not valid' do
125+ expect ( subject ) . not_to be_valid
126+ expect ( subject . errors [ :username ] ) . to include ( "'origin' is missing" )
127+ end
128+ end
129+ end
130+
131+ describe 'origin' do
132+ context 'when not a string' do
133+ let ( :params ) do
134+ { origin : 5 }
135+ end
136+
137+ it 'is not valid' do
138+ expect ( subject ) . not_to be_valid
139+ expect ( subject . errors [ :origin ] ) . to include ( 'must be a string' )
140+ end
141+ end
142+
143+ context 'when username is missing' do
144+ let ( :params ) do
145+ { origin : 5 }
146+ end
147+
148+ it 'is not valid' do
149+ expect ( subject ) . not_to be_valid
150+ expect ( subject . errors [ :origin ] ) . to include ( "'username' is missing" )
151+ end
152+ end
153+ end
78154 end
79155 end
80156end
0 commit comments