-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create-user doesn't require givenName/familyName
- Previously was required in CLI, but optional for UAA API. [#168790909] Signed-off-by: Andrew Edstrom <[email protected]>
- Loading branch information
1 parent
79fbfb3
commit 8626b94
Showing
3 changed files
with
193 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,23 +45,6 @@ var _ = Describe("CreateUser", func() { | |
Expect(session.Err).To(Say("The positional argument USERNAME must be specified.")) | ||
}) | ||
|
||
It("requires a family name (last name)", func() { | ||
session := runCommand("create-user", "woodstock") | ||
|
||
Eventually(session).Should(Exit(1)) | ||
Expect(session.Err).To(Say("Missing argument `familyName` must be specified.")) | ||
}) | ||
|
||
It("requires a given name (first name)", func() { | ||
session := runCommand("create-user", | ||
"woodstock", | ||
"--familyName", "Bird", | ||
) | ||
|
||
Eventually(session).Should(Exit(1)) | ||
Expect(session.Err).To(Say("Missing argument `givenName` must be specified.")) | ||
}) | ||
|
||
It("requires an email address", func() { | ||
session := runCommand("create-user", | ||
"woodstock", | ||
|
@@ -73,17 +56,17 @@ var _ = Describe("CreateUser", func() { | |
Expect(session.Err).To(Say("Missing argument `email` must be specified.")) | ||
}) | ||
}) | ||
|
||
Describe("CreateUserCmd", func() { | ||
It("performs POST with user data and bearer token", func() { | ||
server.RouteToHandler("POST", "/Users", CombineHandlers( | ||
RespondWith(http.StatusOK, fixtures.MarcusUserResponse), | ||
VerifyRequest("POST", "/Users"), | ||
VerifyHeaderKV("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ"), | ||
VerifyHeaderKV("Accept", "application/json"), | ||
VerifyHeaderKV("Content-Type", "application/json"), | ||
VerifyHeaderKV("X-Identity-Zone-Id", "twilight-zone"), | ||
VerifyJSON(` | ||
Describe("With name", func() { | ||
It("performs POST with user data and bearer token", func() { | ||
server.RouteToHandler("POST", "/Users", CombineHandlers( | ||
RespondWith(http.StatusOK, fixtures.MarcusUserResponse), | ||
VerifyRequest("POST", "/Users"), | ||
VerifyHeaderKV("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ"), | ||
VerifyHeaderKV("Accept", "application/json"), | ||
VerifyHeaderKV("Content-Type", "application/json"), | ||
VerifyHeaderKV("X-Identity-Zone-Id", "twilight-zone"), | ||
VerifyJSON(` | ||
{ | ||
"userName": "marcus", | ||
"password": "secret", | ||
|
@@ -107,57 +90,141 @@ var _ = Describe("CreateUser", func() { | |
}] | ||
} | ||
`), | ||
)) | ||
|
||
session := runCommand("create-user", "marcus", | ||
"--givenName", "Marcus", | ||
"--familyName", "Aurelius", | ||
"--email", "[email protected]", | ||
"--email", "[email protected]", | ||
"--phone", "555-5555", | ||
"--phone", "666-6666", | ||
"--password", "secret", | ||
"--origin", "uaa", | ||
"--zone", "twilight-zone", | ||
) | ||
|
||
Expect(server.ReceivedRequests()).To(HaveLen(1)) | ||
Expect(session).To(Exit(0)) | ||
)) | ||
|
||
session := runCommand("create-user", "marcus", | ||
"--givenName", "Marcus", | ||
"--familyName", "Aurelius", | ||
"--email", "[email protected]", | ||
"--email", "[email protected]", | ||
"--phone", "555-5555", | ||
"--phone", "666-6666", | ||
"--password", "secret", | ||
"--origin", "uaa", | ||
"--zone", "twilight-zone", | ||
) | ||
|
||
Expect(server.ReceivedRequests()).To(HaveLen(1)) | ||
Expect(session).To(Exit(0)) | ||
}) | ||
|
||
It("prints the created user json", func() { | ||
server.RouteToHandler("POST", "/Users", CombineHandlers( | ||
RespondWith(http.StatusOK, fixtures.MarcusUserResponse), | ||
VerifyRequest("POST", "/Users"), | ||
)) | ||
|
||
session := runCommand("create-user", "marcus", | ||
"--givenName", "Marcus", | ||
"--familyName", "Aurelius", | ||
"--email", "[email protected]", | ||
"--email", "[email protected]", | ||
) | ||
|
||
Expect(server.ReceivedRequests()).To(HaveLen(1)) | ||
Expect(session).To(Exit(0)) | ||
Expect(session.Out.Contents()).To(MatchJSON(fixtures.MarcusUserResponse)) | ||
}) | ||
|
||
It("displays an error if there is a problem during create", func() { | ||
server.RouteToHandler("POST", "/Users", CombineHandlers( | ||
RespondWith(http.StatusBadRequest, ""), | ||
VerifyRequest("POST", "/Users"), | ||
)) | ||
|
||
session := runCommand("create-user", "marcus", | ||
"--givenName", "Marcus", | ||
"--familyName", "Aurelius", | ||
"--email", "[email protected]", | ||
"--email", "[email protected]", | ||
) | ||
|
||
Expect(server.ReceivedRequests()).To(HaveLen(1)) | ||
Expect(session).To(Exit(1)) | ||
}) | ||
}) | ||
|
||
It("prints the created user json", func() { | ||
server.RouteToHandler("POST", "/Users", CombineHandlers( | ||
RespondWith(http.StatusOK, fixtures.MarcusUserResponse), | ||
VerifyRequest("POST", "/Users"), | ||
)) | ||
|
||
session := runCommand("create-user", "marcus", | ||
"--givenName", "Marcus", | ||
"--familyName", "Aurelius", | ||
"--email", "[email protected]", | ||
"--email", "[email protected]", | ||
) | ||
|
||
Expect(server.ReceivedRequests()).To(HaveLen(1)) | ||
Expect(session).To(Exit(0)) | ||
Expect(session.Out.Contents()).To(MatchJSON(fixtures.MarcusUserResponse)) | ||
Describe("Without name", func() { | ||
It("performs POST with user data and bearer token", func() { | ||
server.RouteToHandler("POST", "/Users", CombineHandlers( | ||
RespondWith(http.StatusOK, fixtures.MarcusUserResponse), | ||
VerifyRequest("POST", "/Users"), | ||
VerifyHeaderKV("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ"), | ||
VerifyHeaderKV("Accept", "application/json"), | ||
VerifyHeaderKV("Content-Type", "application/json"), | ||
VerifyHeaderKV("X-Identity-Zone-Id", "twilight-zone"), | ||
VerifyJSON(` | ||
{ | ||
"userName": "marcus", | ||
"password": "secret", | ||
"origin": "uaa", | ||
"name" : {}, | ||
"emails": [ | ||
{ | ||
"value": "[email protected]", | ||
"primary": true | ||
}, | ||
{ | ||
"value": "[email protected]", | ||
"primary": false | ||
} | ||
], | ||
"phoneNumbers": [{ | ||
"value": "555-5555" | ||
}, | ||
{ | ||
"value": "666-6666" | ||
}] | ||
} | ||
`), | ||
)) | ||
|
||
session := runCommand("create-user", "marcus", | ||
"--email", "[email protected]", | ||
"--email", "[email protected]", | ||
"--phone", "555-5555", | ||
"--phone", "666-6666", | ||
"--password", "secret", | ||
"--origin", "uaa", | ||
"--zone", "twilight-zone", | ||
) | ||
|
||
Expect(server.ReceivedRequests()).To(HaveLen(1)) | ||
Expect(session).To(Exit(0)) | ||
}) | ||
|
||
It("prints the created user json", func() { | ||
server.RouteToHandler("POST", "/Users", CombineHandlers( | ||
RespondWith(http.StatusOK, fixtures.AnonyMarcusUserResponse), | ||
VerifyRequest("POST", "/Users"), | ||
)) | ||
|
||
session := runCommand("create-user", "marcus", | ||
"--email", "[email protected]", | ||
"--email", "[email protected]", | ||
) | ||
|
||
Expect(server.ReceivedRequests()).To(HaveLen(1)) | ||
Expect(session).To(Exit(0)) | ||
Expect(session.Out.Contents()).To(MatchJSON(fixtures.AnonyMarcusUserResponse)) | ||
}) | ||
|
||
It("displays an error if there is a problem during create", func() { | ||
server.RouteToHandler("POST", "/Users", CombineHandlers( | ||
RespondWith(http.StatusBadRequest, ""), | ||
VerifyRequest("POST", "/Users"), | ||
)) | ||
|
||
session := runCommand("create-user", "marcus", | ||
"--email", "[email protected]", | ||
"--email", "[email protected]", | ||
) | ||
|
||
Expect(server.ReceivedRequests()).To(HaveLen(1)) | ||
Expect(session).To(Exit(1)) | ||
}) | ||
}) | ||
|
||
It("displays an error if there is a problem during create", func() { | ||
server.RouteToHandler("POST", "/Users", CombineHandlers( | ||
RespondWith(http.StatusBadRequest, ""), | ||
VerifyRequest("POST", "/Users"), | ||
)) | ||
|
||
session := runCommand("create-user", "marcus", | ||
"--givenName", "Marcus", | ||
"--familyName", "Aurelius", | ||
"--email", "[email protected]", | ||
"--email", "[email protected]", | ||
) | ||
|
||
Expect(server.ReceivedRequests()).To(HaveLen(1)) | ||
Expect(session).To(Exit(1)) | ||
}) | ||
}) | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,6 +59,57 @@ const MarcusUserResponse = `{ | |
"schemas" : [ "urn:scim:schemas:core:1.0" ] | ||
}` | ||
|
||
const AnonyMarcusUserResponse = `{ | ||
"id" : "fb5f32e1-5cb3-49e6-93df-6df9c8c8bd70", | ||
"externalId" : "marcus-user", | ||
"meta" : { | ||
"version" : 1, | ||
"created" : "2017-01-15T16:54:15.677Z", | ||
"lastModified" : "2017-08-15T16:54:15.677Z" | ||
}, | ||
"userName" : "[email protected]", | ||
"name" : {}, | ||
"emails" : [ { | ||
"value" : "[email protected]", | ||
"primary" : false | ||
} ], | ||
"groups" : [ { | ||
"value" : "ac2ab20e-0a2d-4b68-82e4-817ee6b258b4", | ||
"display" : "philosophy.read", | ||
"type" : "DIRECT" | ||
}, { | ||
"value" : "110b2434-4a30-439b-b5fc-f4cf47fc04f0", | ||
"display" : "philosophy.write", | ||
"type" : "DIRECT" | ||
}], | ||
"approvals" : [ { | ||
"userId" : "fb5f32e1-5cb3-49e6-93df-6df9c8c8bd70", | ||
"clientId" : "shinyclient", | ||
"scope" : "philosophy.read", | ||
"status" : "APPROVED", | ||
"lastUpdatedAt" : "2017-08-15T16:54:15.765Z", | ||
"expiresAt" : "2017-08-15T16:54:25.765Z" | ||
}, { | ||
"userId" : "fb5f32e1-5cb3-49e6-93df-6df9c8c8bd70", | ||
"clientId" : "identity", | ||
"scope" : "uaa.user", | ||
"status" : "APPROVED", | ||
"lastUpdatedAt" : "2017-08-15T16:54:45.767Z", | ||
"expiresAt" : "2017-08-15T16:54:45.767Z" | ||
} ], | ||
"phoneNumbers" : [ { | ||
"value" : "5555555555" | ||
} ], | ||
"active" : true, | ||
"verified" : true, | ||
"origin" : "uaa", | ||
"zoneId" : "uaa", | ||
"passwordLastModified" : "2017-08-15T16:54:15.000Z", | ||
"previousLogonTime" : 1502816055768, | ||
"lastLogonTime" : 1502816055768, | ||
"schemas" : [ "urn:scim:schemas:core:1.0" ] | ||
}` | ||
|
||
const DrSeussUserResponse = `{ | ||
"id" : "fb5f32e1-5cb3-49e6-93df-6df9c8c8bd70", | ||
"externalId" : "seuss-user", | ||
|