use of com.vmware.flowgate.common.model.WormholeUser in project flowgate by vmware.
the class AuthControllerTest method createUserExample.
@Test
public void createUserExample() throws Exception {
WormholeUser user = createUser();
this.mockMvc.perform(post("/v1/auth/user").contentType(MediaType.APPLICATION_JSON).content(objectMapper.writeValueAsString(user))).andExpect(status().isCreated()).andDo(document("AuthController-createUser-example", requestFields(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").type(JsonFieldType.STRING), 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(user.getId());
}
use of com.vmware.flowgate.common.model.WormholeUser in project flowgate by vmware.
the class AuthControllerTest method updateUserExample.
@Test
public void updateUserExample() 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.setUserName("admin");
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(put("/v1/auth/user").contentType(MediaType.APPLICATION_JSON_VALUE).content(objectMapper.writeValueAsString(user))).andExpect(status().isOk()).andDo(document("AuthController-updateUser-example", requestFields(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").type(JsonFieldType.STRING), 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(user.getId());
userRepository.deleteById(adminUser.getId());
}
use of com.vmware.flowgate.common.model.WormholeUser in project flowgate by vmware.
the class AuthControllerTest method readOneUserByUserNameExample2.
@Test
public void readOneUserByUserNameExample2() throws Exception {
expectedEx.expect(WormholeRequestException.class);
expectedEx.expectMessage("Forbidden");
String userId = UUID.randomUUID().toString();
WormholeUserDetails userdetail = new WormholeUserDetails();
userdetail.setUserId(userId);
List<String> rolenames = new ArrayList<String>();
rolenames.add("sysuser");
WormholeUser sysuser = createUser();
sysuser.setId(userId);
sysuser.setRoleNames(rolenames);
sysuser.setUserName("lucy");
userRepository.save(sysuser);
Mockito.doReturn(userdetail).when(tokenService).getCurrentUser(any());
MvcResult result = this.mockMvc.perform(get("/v1/auth/user/username/tom")).andExpect(status().isForbidden()).andReturn();
if (result.getResolvedException() != null) {
userRepository.deleteById(sysuser.getId());
throw result.getResolvedException();
}
}
use of com.vmware.flowgate.common.model.WormholeUser in project flowgate by vmware.
the class FacilitySoftwareControllerTest method facilitySoftwareQueryByPageAndTypeExample.
// facilitySoftwareConfigsByType
@Test
public void facilitySoftwareQueryByPageAndTypeExample() 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>();
roles.add("admin");
user.setRoleNames(roles);
userRepository.save(user);
// userId of the facilitySoftware is not '5b7d208d55368540fcba1692'
FacilitySoftwareConfig facilitySoftware = createFacilitySoftware();
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).param("softwaretypes", "Nlyte")).andExpect(status().isOk()).andExpect(jsonPath("$..content[0].name").value(facilitySoftware.getName())).andExpect(jsonPath("$..content[0].userId").value(facilitySoftware.getUserId())).andExpect(jsonPath("$..content[0].type").value(facilitySoftware.getType().name())).andDo(document("facilitySoftware-queryByTypeAndPage-example", pathParameters(parameterWithName("pageNumber").description("Get datas for this page number."), parameterWithName("pageSize").description("The number of facilitysoftwares you want to get by every request.Default value: 20")), requestParameters(parameterWithName("softwaretypes").description("A list of software, maybe contain Nlyte/PowerIQ/InfoBlox/OpenManage/Labsdb"))));
} finally {
facilitySoftwareRepository.deleteById(facilitySoftware.getId());
userRepository.deleteById(user.getId());
}
}
use of com.vmware.flowgate.common.model.WormholeUser in project flowgate by vmware.
the class FacilitySoftwareControllerTest method facilitySoftwareQueryByPageExample.
// admin can find all facilitySoftwareConfigs
@Test
public void facilitySoftwareQueryByPageExample() 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>();
roles.add("admin");
user.setRoleNames(roles);
userRepository.save(user);
// userId of the facilitySoftware is not '5b7d208d55368540fcba1692'
FacilitySoftwareConfig facilitySoftware = createFacilitySoftware();
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())).andDo(document("facilitySoftware-queryByPage-example", pathParameters(parameterWithName("pageNumber").description("Get datas for this page number."), parameterWithName("pageSize").description("The number of facilitysoftwares you want to get by every request.Default value: 20"))));
} finally {
facilitySoftwareRepository.deleteById(facilitySoftware.getId());
userRepository.deleteById(user.getId());
}
}
Aggregations