Permalink
Browse files

Users can be created without given and family names

[#40808947]

Change-Id: I882fb10fbc77bb7a975dc855a5f40016aaa228a2
  • Loading branch information...
1 parent 05a2541 commit 0894200a41dc2f6dc3f2d616d4cf8a554e2ea4d8 @joeldsa joeldsa committed Nov 27, 2012
@@ -178,8 +178,14 @@ public void setValues(PreparedStatement ps) throws SQLException {
ps.setTimestamp(4, new Timestamp(new Date().getTime()));
ps.setString(5, user.getUserName());
ps.setString(6, user.getPrimaryEmail());
- ps.setString(7, user.getName().getGivenName());
- ps.setString(8, user.getName().getFamilyName());
+ if (user.getName() == null) {
+ ps.setString(7, null);
+ ps.setString(8, null);
+ }
+ else {
+ ps.setString(7, user.getName().getGivenName());
+ ps.setString(8, user.getName().getFamilyName());
+ }
ps.setBoolean(9, user.isActive());
String phoneNumber = extractPhoneNumber(user);
ps.setString(10, phoneNumber);
@@ -139,6 +139,20 @@ public void canCreateUser() {
assertEquals(user.getUserType(), map.get(UaaAuthority.UAA_USER.getUserType()));
assertNull(created.getGroups());
}
+
+ @Test
+ public void canCreateUserWithoutGivenNameAndFamilyName() {
+ ScimUser user = new ScimUser(null, "JO@FOO.COM", null, null);
+ user.addEmail("jo@blah.com");
+ ScimUser created = db.createUser(user, "j7hyqpassX");
+ assertEquals("JO@FOO.COM", created.getUserName());
+ assertNotNull(created.getId());
+ assertNotSame(user.getId(), created.getId());
+ Map<String, Object> map = template.queryForMap("select * from users where id=?", created.getId());
+ assertEquals(user.getUserName(), map.get("userName"));
+ assertEquals(user.getUserType(), map.get(UaaAuthority.UAA_USER.getUserType()));
+ assertNull(created.getGroups());
+ }
@Test(expected = InvalidScimResourceException.class)
public void cannotCreateUserWithNonAsciiUsername() {

0 comments on commit 0894200

Please sign in to comment.