use of com.ctrip.framework.apollo.portal.entity.bo.UserInfo in project apollo by ctripcorp.
the class ConsumerServiceTest method testCreateConsumer.
@Test
public void testCreateConsumer() {
Consumer consumer = createConsumer(testConsumerName, testAppId, testOwner);
UserInfo owner = createUser(testOwner);
when(consumerRepository.findByAppId(testAppId)).thenReturn(null);
when(userService.findByUserId(testOwner)).thenReturn(owner);
when(userInfoHolder.getUser()).thenReturn(owner);
consumerService.createConsumer(consumer);
verify(consumerRepository).save(consumer);
}
use of com.ctrip.framework.apollo.portal.entity.bo.UserInfo in project apollo by ctripcorp.
the class DefaultUserInfoHolder method getUser.
@Override
public UserInfo getUser() {
UserInfo userInfo = new UserInfo();
userInfo.setUserId("apollo");
userInfo.setName("apollo");
return userInfo;
}
use of com.ctrip.framework.apollo.portal.entity.bo.UserInfo in project apollo by ctripcorp.
the class CtripUserServiceTest method testFindByUserId.
@Test
public void testFindByUserId() throws Exception {
String someUserId = "someUserId";
String someName = "someName";
String someEmail = "someEmail";
CtripUserService.UserServiceResponse someUserResponse = assembleUserServiceResponse(someUserId, someName, someEmail);
Map<String, List<CtripUserService.UserServiceResponse>> resultMap = ImmutableMap.of("result", Lists.newArrayList(someUserResponse));
ResponseEntity<Map<String, List<CtripUserService.UserServiceResponse>>> someResponse = new ResponseEntity<>(resultMap, HttpStatus.OK);
when(restTemplate.exchange(eq(someUserServiceUrl), eq(HttpMethod.POST), any(HttpEntity.class), eq(someResponseType))).thenReturn(someResponse);
UserInfo user = ctripUserService.findByUserId(someUserId);
compareUserInfoAndUserServiceResponse(someUserResponse, user);
}
use of com.ctrip.framework.apollo.portal.entity.bo.UserInfo in project apollo by ctripcorp.
the class PermissionController method getNamespaceEnvRoles.
@GetMapping("/apps/{appId}/envs/{env}/namespaces/{namespaceName}/role_users")
public NamespaceEnvRolesAssignedUsers getNamespaceEnvRoles(@PathVariable String appId, @PathVariable String env, @PathVariable String namespaceName) {
// validate env parameter
if (Env.UNKNOWN == Env.transformEnv(env)) {
throw new BadRequestException("env is illegal");
}
NamespaceEnvRolesAssignedUsers assignedUsers = new NamespaceEnvRolesAssignedUsers();
assignedUsers.setNamespaceName(namespaceName);
assignedUsers.setAppId(appId);
assignedUsers.setEnv(Env.valueOf(env));
Set<UserInfo> releaseNamespaceUsers = rolePermissionService.queryUsersWithRole(RoleUtils.buildReleaseNamespaceRoleName(appId, namespaceName, env));
assignedUsers.setReleaseRoleUsers(releaseNamespaceUsers);
Set<UserInfo> modifyNamespaceUsers = rolePermissionService.queryUsersWithRole(RoleUtils.buildModifyNamespaceRoleName(appId, namespaceName, env));
assignedUsers.setModifyRoleUsers(modifyNamespaceUsers);
return assignedUsers;
}
use of com.ctrip.framework.apollo.portal.entity.bo.UserInfo in project apollo by ctripcorp.
the class PermissionController method getNamespaceRoles.
@GetMapping("/apps/{appId}/namespaces/{namespaceName}/role_users")
public NamespaceRolesAssignedUsers getNamespaceRoles(@PathVariable String appId, @PathVariable String namespaceName) {
NamespaceRolesAssignedUsers assignedUsers = new NamespaceRolesAssignedUsers();
assignedUsers.setNamespaceName(namespaceName);
assignedUsers.setAppId(appId);
Set<UserInfo> releaseNamespaceUsers = rolePermissionService.queryUsersWithRole(RoleUtils.buildReleaseNamespaceRoleName(appId, namespaceName));
assignedUsers.setReleaseRoleUsers(releaseNamespaceUsers);
Set<UserInfo> modifyNamespaceUsers = rolePermissionService.queryUsersWithRole(RoleUtils.buildModifyNamespaceRoleName(appId, namespaceName));
assignedUsers.setModifyRoleUsers(modifyNamespaceUsers);
return assignedUsers;
}
Aggregations