@@ -47,7 +47,8 @@ const ListOutput = `
4747 "password_expires_at": "2016-11-06T15:32:17.000000",
48484949 "options": {
50- "ignore_password_expiry": true
50+ "ignore_password_expiry": true,
51+ "multi_factor_auth_rules": [["password", "totp"], ["password", "custom-auth-method"]]
5152 }
5253 }
5354 ]
@@ -69,12 +70,63 @@ const GetOutput = `
6970 "password_expires_at": "2016-11-06T15:32:17.000000",
70717172 "options": {
72- "ignore_password_expiry": true
73+ "ignore_password_expiry": true,
74+ "multi_factor_auth_rules": [["password", "totp"], ["password", "custom-auth-method"]]
7375 }
7476 }
7577}
7678`
7779
80+ // GetOutputNoOptions provides a Get result of a user with no options.
81+ const GetOutputNoOptions = `
82+ {
83+ "user": {
84+ "default_project_id": "263fd9",
85+ "domain_id": "1789d1",
86+ "enabled": true,
87+ "id": "9fe1d3",
88+ "links": {
89+ "self": "https://example.com/identity/v3/users/9fe1d3"
90+ },
91+ "name": "jsmith",
92+ "password_expires_at": "2016-11-06T15:32:17.000000",
93+ 94+ }
95+ }
96+ `
97+
98+ // CreateRequest provides the input to a Create request.
99+ const CreateRequest = `
100+ {
101+ "user": {
102+ "default_project_id": "263fd9",
103+ "domain_id": "1789d1",
104+ "enabled": true,
105+ "name": "jsmith",
106+ "password": "secretsecret",
107+ 108+ "options": {
109+ "ignore_password_expiry": true,
110+ "multi_factor_auth_rules": [["password", "totp"], ["password", "custom-auth-method"]]
111+ }
112+ }
113+ }
114+ `
115+
116+ // CreateNoOptionsRequest provides the input to a Create request with no Options.
117+ const CreateNoOptionsRequest = `
118+ {
119+ "user": {
120+ "default_project_id": "263fd9",
121+ "domain_id": "1789d1",
122+ "enabled": true,
123+ "name": "jsmith",
124+ "password": "secretsecret",
125+ 126+ }
127+ }
128+ `
129+
78130// FirstUser is the first user in the List request.
79131var nilTime time.Time
80132var FirstUser = users.User {
@@ -109,6 +161,25 @@ var SecondUser = users.User{
109161 },
110162 Options : map [string ]interface {}{
111163 "ignore_password_expiry" : true ,
164+ "multi_factor_auth_rules" : []interface {}{
165+ []string {"password" , "totp" },
166+ []string {"password" , "custom-auth-method" },
167+ },
168+ },
169+ }
170+
171+ var SecondUserNoOptions = users.User {
172+ DefaultProjectID : "263fd9" ,
173+ DomainID : "1789d1" ,
174+ Enabled : true ,
175+ ID : "9fe1d3" ,
176+ Links : map [string ]interface {}{
177+ "self" : "https://example.com/identity/v3/users/9fe1d3" ,
178+ },
179+ Name : "jsmith" ,
180+ PasswordExpiresAt : SecondUserPasswordExpiresAt ,
181+ Extra : map [string ]interface {}{
182+ 112183 },
113184}
114185
@@ -142,3 +213,29 @@ func HandleGetUserSuccessfully(t *testing.T) {
142213 fmt .Fprintf (w , GetOutput )
143214 })
144215}
216+
217+ // HandleCreateUserSuccessfully creates an HTTP handler at `/users` on the
218+ // test handler mux that tests project creation.
219+ func HandleCreateUserSuccessfully (t * testing.T ) {
220+ th .Mux .HandleFunc ("/users" , func (w http.ResponseWriter , r * http.Request ) {
221+ th .TestMethod (t , r , "POST" )
222+ th .TestHeader (t , r , "X-Auth-Token" , client .TokenID )
223+ th .TestJSONRequest (t , r , CreateRequest )
224+
225+ w .WriteHeader (http .StatusCreated )
226+ fmt .Fprintf (w , GetOutput )
227+ })
228+ }
229+
230+ // HandleCreateNoOptionsUserSuccessfully creates an HTTP handler at `/users` on the
231+ // test handler mux that tests project creation.
232+ func HandleCreateNoOptionsUserSuccessfully (t * testing.T ) {
233+ th .Mux .HandleFunc ("/users" , func (w http.ResponseWriter , r * http.Request ) {
234+ th .TestMethod (t , r , "POST" )
235+ th .TestHeader (t , r , "X-Auth-Token" , client .TokenID )
236+ th .TestJSONRequest (t , r , CreateNoOptionsRequest )
237+
238+ w .WriteHeader (http .StatusCreated )
239+ fmt .Fprintf (w , GetOutputNoOptions )
240+ })
241+ }
0 commit comments