use of com.vmware.flowgate.util.WormholeUserDetails in project flowgate by vmware.
the class FacilitySoftwareControllerTest method facilitySoftwareQueryByPageExample1.
// query by currentUser
@Test
public void facilitySoftwareQueryByPageExample1() throws Exception {
WormholeUserDetails userDeails = createuser();
userDeails.setUserId("5b7d208d55368540fcba1692");
Mockito.doReturn(userDeails).when(tokenService).getCurrentUser(any());
WormholeUser user = new WormholeUser();
user.setId("5b7d208d55368540fcba1692");
List<String> roles = new ArrayList<String>();
// not admin
roles.add("queryFacility");
user.setRoleNames(roles);
userRepository.save(user);
// userId of the facilitySoftware is '5b7d208d55368540fcba1692'
FacilitySoftwareConfig facilitySoftware = createFacilitySoftware();
facilitySoftware.setUserId("5b7d208d55368540fcba1692");
facilitySoftware.setPassword(EncryptionGuard.encode(facilitySoftware.getPassword()));
facilitySoftwareRepository.save(facilitySoftware);
int pageNumber = 1;
int pageSize = 5;
try {
this.mockMvc.perform(get("/v1/facilitysoftware/page/{pageNumber}/pagesize/{pageSize}", pageNumber, pageSize)).andExpect(status().isOk()).andExpect(jsonPath("$..content[0].name").value(facilitySoftware.getName())).andExpect(jsonPath("$..content[0].userId").value(facilitySoftware.getUserId()));
} finally {
facilitySoftwareRepository.deleteById(facilitySoftware.getId());
userRepository.deleteById(user.getId());
}
}
use of com.vmware.flowgate.util.WormholeUserDetails in project flowgate by vmware.
the class SDDCSoftwareControllerTest method createuser.
WormholeUserDetails createuser() {
WormholeUserDetails user = new WormholeUserDetails();
user.setUserId("1001");
return user;
}
use of com.vmware.flowgate.util.WormholeUserDetails in project flowgate by vmware.
the class AuthControllerTest method readOneUserByUserNameExample1.
@Test
public void readOneUserByUserNameExample1() throws Exception {
WormholeUserDetails userdetail = new WormholeUserDetails();
String userId = UUID.randomUUID().toString();
userdetail.setUserId(userId);
List<String> rolenames = new ArrayList<String>();
rolenames.add("sysuser");
WormholeUser sysuser = new WormholeUser();
sysuser.setRoleNames(rolenames);
sysuser.setId(userId);
sysuser.setUserName("lucy");
userRepository.save(sysuser);
Mockito.doReturn(userdetail).when(tokenService).getCurrentUser(any());
this.mockMvc.perform(get("/v1/auth/user/username/" + sysuser.getUserName() + "")).andExpect(status().isOk()).andReturn();
userRepository.deleteById(sysuser.getId());
}
use of com.vmware.flowgate.util.WormholeUserDetails in project flowgate by vmware.
the class AuthControllerTest method readOneUserByNameExample.
@Test
public void readOneUserByNameExample() throws Exception {
WormholeUserDetails userdetail = new WormholeUserDetails();
String userId = UUID.randomUUID().toString();
userdetail.setUserId(userId);
List<String> rolenames = new ArrayList<String>();
rolenames.add("admin");
WormholeUser adminUser = new WormholeUser();
adminUser.setRoleNames(rolenames);
adminUser.setId(userId);
userRepository.save(adminUser);
Mockito.doReturn(userdetail).when(tokenService).getCurrentUser(any());
WormholeUser user = createUser();
userRepository.save(user);
this.mockMvc.perform(get("/v1/auth/user/username/{userName}", user.getUserName())).andExpect(status().isOk()).andDo(document("AuthController-readOneUserByUserName-example", pathParameters(parameterWithName("userName").description("The name of user")), responseFields(fieldWithPath("id").description("ID of User, created by flowgate"), fieldWithPath("userName").description("userName.").type(JsonFieldType.STRING), fieldWithPath("gender").description("gender").type(JsonFieldType.NUMBER), fieldWithPath("password").description("password"), fieldWithPath("mobile").description("mobile").type(JsonFieldType.STRING), fieldWithPath("status").description("status").type(JsonFieldType.NUMBER), fieldWithPath("createTime").description("createTime").type(Date.class), fieldWithPath("emailAddress").description("emailAddress").type(JsonFieldType.STRING), fieldWithPath("roleNames").description("roleNames").type(List.class), fieldWithPath("userGroupIDs").description("userGroupIDs").type(List.class), fieldWithPath("lastPasswordResetDate").description("lastPasswordResetDate").type(JsonFieldType.NUMBER)))).andReturn();
userRepository.deleteById(userId);
userRepository.deleteById(user.getId());
}
use of com.vmware.flowgate.util.WormholeUserDetails in project flowgate by vmware.
the class AuthController method getPrivilegeName.
@RequestMapping(value = "/privileges", method = RequestMethod.GET)
public Set<String> getPrivilegeName(HttpServletRequest request) {
WormholeUserDetails user = accessTokenService.getCurrentUser(request);
AuthorityUtil util = new AuthorityUtil();
return util.getPrivilege(user);
}
Aggregations