未验证 提交 f1eca02f 编写于 作者: W wxq 提交者: GitHub

feat(open-api): get authorized apps (#3647)

* feat(open-api): get authorized apps

* refactor: delete new class

* fix: test failure

* rename method name

* fix: extractAppIdFromMasterRoleName -> extractAppIdFromRoleName

* test: find app authorized

* Update CHANGES.md

* refactor: create method findAppIdsAuthorizedByConsumerId in ConsumerService

* test: use sql to prepare data

* test: add more app consumer-test-app-id-2

* test: restTemplate call api with token

* test: append 000 to all id in sql

* test: move sql to folder /sql/openapi
Co-authored-by: NJason Song <nobodyiam@gmail.com>
上级 9a6f8e27
......@@ -47,6 +47,7 @@ Apollo 1.9.0
* [add More... link for known users](https://github.com/ctripcorp/apollo/pull/3757)
* [update OIDC documentation](https://github.com/ctripcorp/apollo/pull/3766)
* [feature: add Spring Boot 2.4 config data loader support](https://github.com/ctripcorp/apollo/pull/3754)
* [feat(open-api): get authorized apps](https://github.com/ctripcorp/apollo/pull/3647)
------------------
All issues and pull requests are [here](https://github.com/ctripcorp/apollo/milestone/6?closed=1)
......@@ -87,6 +87,15 @@ public class ApolloOpenApiClient {
return appService.getAppsInfo(null);
}
/**
* Get applications which can be operated by current open api client.
*
* @return app's information
*/
public List<OpenAppDTO> getAuthorizedApps() {
return this.appService.getAuthorizedApps();
}
/**
* Get App information by app ids
*/
......
......@@ -63,4 +63,13 @@ public class AppOpenApiService extends AbstractOpenApiService {
throw new RuntimeException(String.format("Load app information for appIds: %s failed", appIds), ex);
}
}
public List<OpenAppDTO> getAuthorizedApps() {
String path = "apps/authorized";
try(CloseableHttpResponse response = this.get(path)) {
return gson.fromJson(EntityUtils.toString(response.getEntity()), OPEN_APP_DTO_LIST_TYPE);
} catch (Throwable ex) {
throw new RuntimeException("Load authorized apps failed", ex);
}
}
}
......@@ -28,6 +28,7 @@ import com.ctrip.framework.apollo.openapi.repository.ConsumerTokenRepository;
import com.ctrip.framework.apollo.portal.component.config.PortalConfig;
import com.ctrip.framework.apollo.portal.entity.bo.UserInfo;
import com.ctrip.framework.apollo.portal.entity.po.Role;
import com.ctrip.framework.apollo.portal.repository.RoleRepository;
import com.ctrip.framework.apollo.portal.service.RolePermissionService;
import com.ctrip.framework.apollo.portal.spi.UserInfoHolder;
import com.ctrip.framework.apollo.portal.spi.UserService;
......@@ -37,6 +38,9 @@ import com.google.common.base.Joiner;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import com.google.common.hash.Hashing;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Collectors;
import org.apache.commons.lang.time.FastDateFormat;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -62,6 +66,7 @@ public class ConsumerService {
private final PortalConfig portalConfig;
private final RolePermissionService rolePermissionService;
private final UserService userService;
private final RoleRepository roleRepository;
public ConsumerService(
final UserInfoHolder userInfoHolder,
......@@ -71,7 +76,8 @@ public class ConsumerService {
final ConsumerRoleRepository consumerRoleRepository,
final PortalConfig portalConfig,
final RolePermissionService rolePermissionService,
final UserService userService) {
final UserService userService,
final RoleRepository roleRepository) {
this.userInfoHolder = userInfoHolder;
this.consumerTokenRepository = consumerTokenRepository;
this.consumerRepository = consumerRepository;
......@@ -80,6 +86,7 @@ public class ConsumerService {
this.portalConfig = portalConfig;
this.rolePermissionService = rolePermissionService;
this.userService = userService;
this.roleRepository = roleRepository;
}
......@@ -257,4 +264,33 @@ public class ConsumerService {
return consumerRole;
}
public Set<String> findAppIdsAuthorizedByConsumerId(long consumerId) {
List<ConsumerRole> consumerRoles = this.findConsumerRolesByConsumerId(consumerId);
List<Long> roleIds = consumerRoles.stream().map(ConsumerRole::getRoleId)
.collect(Collectors.toList());
Set<String> appIds = this.findAppIdsByRoleIds(roleIds);
return appIds;
}
private List<ConsumerRole> findConsumerRolesByConsumerId(long consumerId) {
List<ConsumerRole> consumerRoles = this.consumerRoleRepository.findByConsumerId(consumerId);
return consumerRoles;
}
private Set<String> findAppIdsByRoleIds(List<Long> roleIds) {
Iterable<Role> roleIterable = this.roleRepository.findAllById(roleIds);
Set<String> appIds = new HashSet<>();
roleIterable.forEach(role -> {
if (!role.isDeleted()) {
String roleName = role.getRoleName();
String appId = RoleUtils.extractAppIdFromRoleName(roleName);
appIds.add(appId);
}
});
return appIds;
}
}
......@@ -19,6 +19,9 @@ package com.ctrip.framework.apollo.openapi.v1.controller;
import com.ctrip.framework.apollo.common.dto.ClusterDTO;
import com.ctrip.framework.apollo.common.entity.App;
import com.ctrip.framework.apollo.common.utils.BeanUtils;
import com.ctrip.framework.apollo.openapi.entity.ConsumerRole;
import com.ctrip.framework.apollo.openapi.service.ConsumerService;
import com.ctrip.framework.apollo.openapi.util.ConsumerAuthUtil;
import com.ctrip.framework.apollo.portal.environment.Env;
import com.ctrip.framework.apollo.openapi.dto.OpenAppDTO;
import com.ctrip.framework.apollo.openapi.dto.OpenEnvClusterDTO;
......@@ -27,6 +30,8 @@ import com.ctrip.framework.apollo.portal.component.PortalSettings;
import com.ctrip.framework.apollo.portal.service.AppService;
import com.ctrip.framework.apollo.portal.service.ClusterService;
import com.google.common.collect.Sets;
import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
......@@ -41,13 +46,19 @@ public class AppController {
private final PortalSettings portalSettings;
private final ClusterService clusterService;
private final AppService appService;
private final ConsumerAuthUtil consumerAuthUtil;
private final ConsumerService consumerService;
public AppController(final PortalSettings portalSettings,
final ClusterService clusterService,
final AppService appService) {
final ClusterService clusterService,
final AppService appService,
final ConsumerAuthUtil consumerAuthUtil,
final ConsumerService consumerService) {
this.portalSettings = portalSettings;
this.clusterService = clusterService;
this.appService = appService;
this.consumerAuthUtil = consumerAuthUtil;
this.consumerService = consumerService;
}
@GetMapping(value = "/apps/{appId}/envclusters")
......@@ -80,4 +91,19 @@ public class AppController {
}
return OpenApiBeanUtils.transformFromApps(apps);
}
/**
* @return which apps can be operated by open api
*/
@GetMapping("/apps/authorized")
public List<OpenAppDTO> findAppsAuthorized(HttpServletRequest request) {
long consumerId = this.consumerAuthUtil.retrieveConsumerId(request);
Set<String> appIds = this.consumerService.findAppIdsAuthorizedByConsumerId(consumerId);
List<App> apps = this.appService.findByAppIds(appIds);
List<OpenAppDTO> openAppDTOS = OpenApiBeanUtils.transformFromApps(apps);
return openAppDTOS;
}
}
/*
* Copyright 2021 Apollo Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.ctrip.framework.apollo.openapi.service;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import com.ctrip.framework.apollo.portal.AbstractIntegrationTest;
import com.google.common.collect.Sets;
import java.util.Set;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.jdbc.Sql;
/**
* @author wxq
*/
public class ConsumerServiceIntegrationTest extends AbstractIntegrationTest {
@Autowired
private ConsumerService consumerService;
@Test
@Sql(scripts = "/sql/openapi/ConsumerServiceIntegrationTest.testFindAppIdsAuthorizedByConsumerId.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/sql/cleanup.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
public void testFindAppIdsAuthorizedByConsumerId() {
Set<String> appIds = this.consumerService.findAppIdsAuthorizedByConsumerId(1000L);
assertEquals(Sets.newHashSet("consumer-test-app-id-0", "consumer-test-app-id-1"), appIds);
assertFalse(appIds.contains("consumer-test-app-id-2"));
}
}
/*
* Copyright 2021 Apollo Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.ctrip.framework.apollo.openapi.v1.controller;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import com.ctrip.framework.apollo.openapi.dto.OpenAppDTO;
import com.ctrip.framework.apollo.portal.AbstractIntegrationTest;
import java.util.HashSet;
import java.util.Set;
import org.junit.Test;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.jdbc.Sql;
/**
* Integration test for {@link AppController}.
*
* @author wxq
*/
public class AppControllerIntegrationTest extends AbstractIntegrationTest {
@Test
@Sql(scripts = "/sql/openapi/ConsumerServiceIntegrationTest.testFindAppIdsAuthorizedByConsumerId.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/sql/cleanup.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
public void testFindAppsAuthorized() {
final String token = "3c16bf5b1f44b465179253442460e8c0ad845289";
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.set(HttpHeaders.AUTHORIZATION, token);
ResponseEntity<OpenAppDTO[]> responseEntity =
restTemplate.exchange(this.url("/openapi/v1/apps/authorized"), HttpMethod.GET,
new HttpEntity<>(httpHeaders), OpenAppDTO[].class);
OpenAppDTO[] openAppDTOS = responseEntity.getBody();
assertEquals(2, openAppDTOS.length);
Set<String> appIds = new HashSet<>();
for (OpenAppDTO openAppDTO : openAppDTOS) {
appIds.add(openAppDTO.getAppId());
}
assertTrue(appIds.contains("consumer-test-app-id-0"));
assertTrue(appIds.contains("consumer-test-app-id-1"));
}
}
/*
* Copyright 2021 Apollo Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.ctrip.framework.apollo.openapi.v1.controller;
import static org.junit.Assert.assertEquals;
import com.ctrip.framework.apollo.openapi.entity.ConsumerRole;
import com.ctrip.framework.apollo.openapi.repository.ConsumerAuditRepository;
import com.ctrip.framework.apollo.openapi.repository.ConsumerRepository;
import com.ctrip.framework.apollo.openapi.repository.ConsumerRoleRepository;
import com.ctrip.framework.apollo.openapi.repository.ConsumerTokenRepository;
import com.ctrip.framework.apollo.openapi.service.ConsumerService;
import com.ctrip.framework.apollo.openapi.util.ConsumerAuthUtil;
import com.ctrip.framework.apollo.portal.component.PortalSettings;
import com.ctrip.framework.apollo.portal.component.config.PortalConfig;
import com.ctrip.framework.apollo.portal.entity.po.Role;
import com.ctrip.framework.apollo.portal.repository.PermissionRepository;
import com.ctrip.framework.apollo.portal.repository.RolePermissionRepository;
import com.ctrip.framework.apollo.portal.repository.RoleRepository;
import com.ctrip.framework.apollo.portal.service.AppService;
import com.ctrip.framework.apollo.portal.service.ClusterService;
import com.ctrip.framework.apollo.portal.service.RolePermissionService;
import com.ctrip.framework.apollo.portal.spi.UserInfoHolder;
import com.ctrip.framework.apollo.portal.spi.UserService;
import com.google.common.collect.Sets;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Import;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.test.web.servlet.result.MockMvcResultHandlers;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
/**
* @author wxq
*/
@RunWith(SpringRunner.class)
@WebMvcTest(controllers = AppController.class)
@Import(ConsumerService.class)
public class AppControllerTest {
@Autowired
private MockMvc mockMvc;
@MockBean
private PortalSettings portalSettings;
@MockBean
private AppService appService;
@MockBean
private ClusterService clusterService;
@MockBean
private ConsumerAuthUtil consumerAuthUtil;
@MockBean
private PermissionRepository permissionRepository;
@MockBean
private RolePermissionRepository rolePermissionRepository;
@MockBean
private UserInfoHolder userInfoHolder;
@MockBean
private ConsumerTokenRepository consumerTokenRepository;
@MockBean
private ConsumerRepository consumerRepository;
@MockBean
private ConsumerAuditRepository consumerAuditRepository;
@MockBean
private ConsumerRoleRepository consumerRoleRepository;
@MockBean
private PortalConfig portalConfig;
@MockBean
private RolePermissionService rolePermissionService;
@MockBean
private UserService userService;
@MockBean
private RoleRepository roleRepository;
@Test
public void testFindAppsAuthorized() throws Exception {
final long consumerId = 123456;
Mockito.when(this.consumerAuthUtil.retrieveConsumerId(Mockito.any())).thenReturn(consumerId);
final List<ConsumerRole> consumerRoles = Arrays.asList(
generateConsumerRoleByRoleId(6),
generateConsumerRoleByRoleId(7),
generateConsumerRoleByRoleId(8)
);
Mockito.when(this.consumerRoleRepository.findByConsumerId(consumerId))
.thenReturn(consumerRoles);
Mockito.when(this.roleRepository.findAllById(Mockito.any())).thenAnswer(invocation -> {
Set<Role> roles = new HashSet<>();
Iterable<Long> roleIds = invocation.getArgument(0);
for (Long roleId : roleIds) {
if (roleId == 6) {
roles.add(generateRoleByIdAndRoleName(6, "ModifyNamespace+app1+application+DEV"));
}
if (roleId == 7) {
roles.add(generateRoleByIdAndRoleName(7, "ReleaseNamespace+app1+application+DEV"));
}
if (roleId == 8) {
roles.add(generateRoleByIdAndRoleName(8, "Master+app2"));
}
}
assertEquals(3, roles.size());
return roles;
});
this.mockMvc.perform(MockMvcRequestBuilders.get("/openapi/v1/apps/authorized"))
.andDo(MockMvcResultHandlers.print())
.andExpect(MockMvcResultMatchers.status().is2xxSuccessful());
Mockito.verify(this.consumerRoleRepository, Mockito.times(1)).findByConsumerId(consumerId);
Mockito.verify(this.roleRepository, Mockito.times(1)).findAllById(Mockito.any());
ArgumentCaptor<Set<String>> appIdsCaptor = ArgumentCaptor.forClass(Set.class);
Mockito.verify(this.appService).findByAppIds(appIdsCaptor.capture());
Set<String> appIds = appIdsCaptor.getValue();
assertEquals(Sets.newHashSet("app1", "app2"), appIds);
}
private static ConsumerRole generateConsumerRoleByRoleId(long roleId) {
ConsumerRole consumerRole = new ConsumerRole();
consumerRole.setRoleId(roleId);
return consumerRole;
}
private static Role generateRoleByIdAndRoleName(long id, String roleName) {
Role role = new Role();
role.setId(id);
role.setRoleName(roleName);
return role;
}
}
\ No newline at end of file
......@@ -13,11 +13,17 @@
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
delete from Permission;
delete from Role;
delete from RolePermission;
delete from UserRole;
delete from AppNamespace;
DELETE FROM Favorite;
DELETE FROM ServerConfig;
DELETE FROM App;
DELETE FROM `App`;
DELETE FROM `AppNamespace`;
-- DELETE FROM `Authorities`;
DELETE FROM `Consumer`;
DELETE FROM `ConsumerAudit`;
DELETE FROM `ConsumerRole`;
DELETE FROM `ConsumerToken`;
DELETE FROM `Favorite`;
DELETE FROM `Permission`;
DELETE FROM `Role`;
DELETE FROM `RolePermission`;
DELETE FROM `ServerConfig`;
DELETE FROM `UserRole`;
DELETE FROM `Users`;
--
-- Copyright 2021 Apollo Authors
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
/*
This sql is dumped from a apollo portal database.
The logic is as follows
create app:
consumer-test-app-id-0
consumer-test-app-id-1
consumer-test-app-id-2
create consumer:
consumer-test-app-role
Authorization, let consumer-test-app-role manage:
consumer-test-app-id-0:
Authorization type: App
consumer-test-app-id-1:
Authorization type: Namespace
Managed Namespace: application
*/
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET NAMES utf8 */;
/*!50503 SET NAMES utf8mb4 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
/*!40000 ALTER TABLE `App` DISABLE KEYS */;
INSERT INTO `App` (`Id`, `AppId`, `Name`, `OrgId`, `OrgName`, `OwnerName`, `OwnerEmail`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(1000, 'consumer-test-app-id-0', 'consumer-test-app-id-0', 'TEST1', '样例部门1', 'apollo', 'apollo@acme.com', 'apollo', 'apollo');
INSERT INTO `App` (`Id`, `AppId`, `Name`, `OrgId`, `OrgName`, `OwnerName`, `OwnerEmail`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(2000, 'consumer-test-app-id-1', 'consumer-test-app-id-1', 'TEST2', '样例部门2', 'apollo', 'apollo@acme.com', 'apollo', 'apollo');
INSERT INTO `App` (`Id`, `AppId`, `Name`, `OrgId`, `OrgName`, `OwnerName`, `OwnerEmail`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(3000, 'consumer-test-app-id-2', 'consumer-test-app-id-2', 'TEST2', '样例部门2', 'apollo', 'apollo@acme.com', 'apollo', 'apollo');
/*!40000 ALTER TABLE `App` ENABLE KEYS */;
/*!40000 ALTER TABLE `AppNamespace` DISABLE KEYS */;
INSERT INTO `AppNamespace` (`Id`, `Name`, `AppId`, `Format`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(1000, 'application', 'consumer-test-app-id-0', 'properties', 'default app namespace', 'apollo', 'apollo');
INSERT INTO `AppNamespace` (`Id`, `Name`, `AppId`, `Format`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(2000, 'application', 'consumer-test-app-id-1', 'properties', 'default app namespace', 'apollo', 'apollo');
INSERT INTO `AppNamespace` (`Id`, `Name`, `AppId`, `Format`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(3000, 'application', 'consumer-test-app-id-2', 'properties', 'default app namespace', 'apollo', 'apollo');
/*!40000 ALTER TABLE `AppNamespace` ENABLE KEYS */;
/*!40000 ALTER TABLE `Consumer` DISABLE KEYS */;
INSERT INTO `Consumer` (`Id`, `AppId`, `Name`, `OrgId`, `OrgName`, `OwnerName`, `OwnerEmail`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(1000, 'consumer-test-app-role', 'consumer-test-app-role', 'TEST2', '样例部门2', 'apollo', 'apollo@acme.com', 'apollo', 'apollo');
/*!40000 ALTER TABLE `Consumer` ENABLE KEYS */;
/*!40000 ALTER TABLE `ConsumerAudit` DISABLE KEYS */;
/*!40000 ALTER TABLE `ConsumerAudit` ENABLE KEYS */;
/*!40000 ALTER TABLE `ConsumerRole` DISABLE KEYS */;
INSERT INTO `ConsumerRole` (`Id`, `ConsumerId`, `RoleId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(1000, 1000, 1000, 'apollo', 'apollo');
INSERT INTO `ConsumerRole` (`Id`, `ConsumerId`, `RoleId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(2000, 1000, 11000, 'apollo', 'apollo');
INSERT INTO `ConsumerRole` (`Id`, `ConsumerId`, `RoleId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(3000, 1000, 12000, 'apollo', 'apollo');
/*!40000 ALTER TABLE `ConsumerRole` ENABLE KEYS */;
/*!40000 ALTER TABLE `ConsumerToken` DISABLE KEYS */;
INSERT INTO `ConsumerToken` (`Id`, `ConsumerId`, `Token`, `Expires`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(1000, 1000, '3c16bf5b1f44b465179253442460e8c0ad845289', '2098-12-31 10:00:00', 'apollo', 'apollo');
/*!40000 ALTER TABLE `ConsumerToken` ENABLE KEYS */;
/*!40000 ALTER TABLE `Favorite` DISABLE KEYS */;
/*!40000 ALTER TABLE `Favorite` ENABLE KEYS */;
/*!40000 ALTER TABLE `Permission` DISABLE KEYS */;
INSERT INTO `Permission` (`Id`, `PermissionType`, `TargetId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(1000, 'AssignRole', 'consumer-test-app-id-0', 'apollo', 'apollo');
INSERT INTO `Permission` (`Id`, `PermissionType`, `TargetId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(2000, 'CreateNamespace', 'consumer-test-app-id-0', 'apollo', 'apollo');
INSERT INTO `Permission` (`Id`, `PermissionType`, `TargetId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(3000, 'CreateCluster', 'consumer-test-app-id-0', 'apollo', 'apollo');
INSERT INTO `Permission` (`Id`, `PermissionType`, `TargetId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(4000, 'ManageAppMaster', 'consumer-test-app-id-0', 'apollo', 'apollo');
INSERT INTO `Permission` (`Id`, `PermissionType`, `TargetId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(5000, 'ModifyNamespace', 'consumer-test-app-id-0+application', 'apollo', 'apollo');
INSERT INTO `Permission` (`Id`, `PermissionType`, `TargetId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(6000, 'ReleaseNamespace', 'consumer-test-app-id-0+application', 'apollo', 'apollo');
INSERT INTO `Permission` (`Id`, `PermissionType`, `TargetId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(7000, 'ModifyNamespace', 'consumer-test-app-id-0+application+DEV', 'apollo', 'apollo');
INSERT INTO `Permission` (`Id`, `PermissionType`, `TargetId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(8000, 'ReleaseNamespace', 'consumer-test-app-id-0+application+DEV', 'apollo', 'apollo');
INSERT INTO `Permission` (`Id`, `PermissionType`, `TargetId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(9000, 'CreateNamespace', 'consumer-test-app-id-1', 'apollo', 'apollo');
INSERT INTO `Permission` (`Id`, `PermissionType`, `TargetId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(10000, 'AssignRole', 'consumer-test-app-id-1', 'apollo', 'apollo');
INSERT INTO `Permission` (`Id`, `PermissionType`, `TargetId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(11000, 'CreateCluster', 'consumer-test-app-id-1', 'apollo', 'apollo');
INSERT INTO `Permission` (`Id`, `PermissionType`, `TargetId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(12000, 'ManageAppMaster', 'consumer-test-app-id-1', 'apollo', 'apollo');
INSERT INTO `Permission` (`Id`, `PermissionType`, `TargetId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(13000, 'ModifyNamespace', 'consumer-test-app-id-1+application', 'apollo', 'apollo');
INSERT INTO `Permission` (`Id`, `PermissionType`, `TargetId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(14000, 'ReleaseNamespace', 'consumer-test-app-id-1+application', 'apollo', 'apollo');
INSERT INTO `Permission` (`Id`, `PermissionType`, `TargetId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(15000, 'ModifyNamespace', 'consumer-test-app-id-1+application+DEV', 'apollo', 'apollo');
INSERT INTO `Permission` (`Id`, `PermissionType`, `TargetId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(16000, 'ReleaseNamespace', 'consumer-test-app-id-1+application+DEV', 'apollo', 'apollo');
INSERT INTO `Permission` (`Id`, `PermissionType`, `TargetId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(17000, 'CreateCluster', 'consumer-test-app-id-2', 'apollo', 'apollo');
INSERT INTO `Permission` (`Id`, `PermissionType`, `TargetId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(18000, 'AssignRole', 'consumer-test-app-id-2', 'apollo', 'apollo');
INSERT INTO `Permission` (`Id`, `PermissionType`, `TargetId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(19000, 'CreateNamespace', 'consumer-test-app-id-2', 'apollo', 'apollo');
INSERT INTO `Permission` (`Id`, `PermissionType`, `TargetId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(20000, 'ManageAppMaster', 'consumer-test-app-id-2', 'apollo', 'apollo');
INSERT INTO `Permission` (`Id`, `PermissionType`, `TargetId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(21000, 'ModifyNamespace', 'consumer-test-app-id-2+application', 'apollo', 'apollo');
INSERT INTO `Permission` (`Id`, `PermissionType`, `TargetId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(22000, 'ReleaseNamespace', 'consumer-test-app-id-2+application', 'apollo', 'apollo');
INSERT INTO `Permission` (`Id`, `PermissionType`, `TargetId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(23000, 'ModifyNamespace', 'consumer-test-app-id-2+application+DEV', 'apollo', 'apollo');
INSERT INTO `Permission` (`Id`, `PermissionType`, `TargetId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(24000, 'ReleaseNamespace', 'consumer-test-app-id-2+application+DEV', 'apollo', 'apollo');
/*!40000 ALTER TABLE `Permission` ENABLE KEYS */;
/*!40000 ALTER TABLE `Role` DISABLE KEYS */;
INSERT INTO `Role` (`Id`, `RoleName`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(1000, 'Master+consumer-test-app-id-0', 'apollo', 'apollo');
INSERT INTO `Role` (`Id`, `RoleName`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(2000, 'ManageAppMaster+consumer-test-app-id-0', 'apollo', 'apollo');
INSERT INTO `Role` (`Id`, `RoleName`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(3000, 'ModifyNamespace+consumer-test-app-id-0+application', 'apollo', 'apollo');
INSERT INTO `Role` (`Id`, `RoleName`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(4000, 'ReleaseNamespace+consumer-test-app-id-0+application', 'apollo', 'apollo');
INSERT INTO `Role` (`Id`, `RoleName`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(5000, 'ModifyNamespace+consumer-test-app-id-0+application+DEV', 'apollo', 'apollo');
INSERT INTO `Role` (`Id`, `RoleName`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(6000, 'ReleaseNamespace+consumer-test-app-id-0+application+DEV', 'apollo', 'apollo');
INSERT INTO `Role` (`Id`, `RoleName`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(7000, 'Master+consumer-test-app-id-1', 'apollo', 'apollo');
INSERT INTO `Role` (`Id`, `RoleName`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(8000, 'ManageAppMaster+consumer-test-app-id-1', 'apollo', 'apollo');
INSERT INTO `Role` (`Id`, `RoleName`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(9000, 'ModifyNamespace+consumer-test-app-id-1+application', 'apollo', 'apollo');
INSERT INTO `Role` (`Id`, `RoleName`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(10000, 'ReleaseNamespace+consumer-test-app-id-1+application', 'apollo', 'apollo');
INSERT INTO `Role` (`Id`, `RoleName`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(11000, 'ModifyNamespace+consumer-test-app-id-1+application+DEV', 'apollo', 'apollo');
INSERT INTO `Role` (`Id`, `RoleName`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(12000, 'ReleaseNamespace+consumer-test-app-id-1+application+DEV', 'apollo', 'apollo');
INSERT INTO `Role` (`Id`, `RoleName`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(13000, 'Master+consumer-test-app-id-2', 'apollo', 'apollo');
INSERT INTO `Role` (`Id`, `RoleName`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(14000, 'ManageAppMaster+consumer-test-app-id-2', 'apollo', 'apollo');
INSERT INTO `Role` (`Id`, `RoleName`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(15000, 'ModifyNamespace+consumer-test-app-id-2+application', 'apollo', 'apollo');
INSERT INTO `Role` (`Id`, `RoleName`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(16000, 'ReleaseNamespace+consumer-test-app-id-2+application', 'apollo', 'apollo');
INSERT INTO `Role` (`Id`, `RoleName`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(17000, 'ModifyNamespace+consumer-test-app-id-2+application+DEV', 'apollo', 'apollo');
INSERT INTO `Role` (`Id`, `RoleName`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(18000, 'ReleaseNamespace+consumer-test-app-id-2+application+DEV', 'apollo', 'apollo');
/*!40000 ALTER TABLE `Role` ENABLE KEYS */;
/*!40000 ALTER TABLE `RolePermission` DISABLE KEYS */;
INSERT INTO `RolePermission` (`Id`, `RoleId`, `PermissionId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(1000, 1000, 1000, 'apollo', 'apollo');
INSERT INTO `RolePermission` (`Id`, `RoleId`, `PermissionId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(2000, 1000, 2000, 'apollo', 'apollo');
INSERT INTO `RolePermission` (`Id`, `RoleId`, `PermissionId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(3000, 1000, 3000, 'apollo', 'apollo');
INSERT INTO `RolePermission` (`Id`, `RoleId`, `PermissionId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(4000, 2000, 4000, 'apollo', 'apollo');
INSERT INTO `RolePermission` (`Id`, `RoleId`, `PermissionId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(5000, 3000, 5000, 'apollo', 'apollo');
INSERT INTO `RolePermission` (`Id`, `RoleId`, `PermissionId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(6000, 4000, 6000, 'apollo', 'apollo');
INSERT INTO `RolePermission` (`Id`, `RoleId`, `PermissionId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(7000, 5000, 7000, 'apollo', 'apollo');
INSERT INTO `RolePermission` (`Id`, `RoleId`, `PermissionId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(8000, 6000, 8000, 'apollo', 'apollo');
INSERT INTO `RolePermission` (`Id`, `RoleId`, `PermissionId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(9000, 7000, 9000, 'apollo', 'apollo');
INSERT INTO `RolePermission` (`Id`, `RoleId`, `PermissionId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(10000, 7000, 10000, 'apollo', 'apollo');
INSERT INTO `RolePermission` (`Id`, `RoleId`, `PermissionId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(11000, 7000, 11000, 'apollo', 'apollo');
INSERT INTO `RolePermission` (`Id`, `RoleId`, `PermissionId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(12000, 8000, 12000, 'apollo', 'apollo');
INSERT INTO `RolePermission` (`Id`, `RoleId`, `PermissionId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(13000, 9000, 13000, 'apollo', 'apollo');
INSERT INTO `RolePermission` (`Id`, `RoleId`, `PermissionId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(14000, 10000, 14000, 'apollo', 'apollo');
INSERT INTO `RolePermission` (`Id`, `RoleId`, `PermissionId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(15000, 11000, 15000, 'apollo', 'apollo');
INSERT INTO `RolePermission` (`Id`, `RoleId`, `PermissionId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(16000, 12000, 16000, 'apollo', 'apollo');
INSERT INTO `RolePermission` (`Id`, `RoleId`, `PermissionId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(17000, 13000, 17000, 'apollo', 'apollo');
INSERT INTO `RolePermission` (`Id`, `RoleId`, `PermissionId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(18000, 13000, 18000, 'apollo', 'apollo');
INSERT INTO `RolePermission` (`Id`, `RoleId`, `PermissionId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(19000, 13000, 19000, 'apollo', 'apollo');
INSERT INTO `RolePermission` (`Id`, `RoleId`, `PermissionId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(20000, 14000, 20000, 'apollo', 'apollo');
INSERT INTO `RolePermission` (`Id`, `RoleId`, `PermissionId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(21000, 15000, 21000, 'apollo', 'apollo');
INSERT INTO `RolePermission` (`Id`, `RoleId`, `PermissionId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(22000, 16000, 22000, 'apollo', 'apollo');
INSERT INTO `RolePermission` (`Id`, `RoleId`, `PermissionId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(23000, 17000, 23000, 'apollo', 'apollo');
INSERT INTO `RolePermission` (`Id`, `RoleId`, `PermissionId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(24000, 18000, 24000, 'apollo', 'apollo');
/*!40000 ALTER TABLE `RolePermission` ENABLE KEYS */;
/*!40000 ALTER TABLE `UserRole` DISABLE KEYS */;
INSERT INTO `UserRole` (`Id`, `UserId`, `RoleId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(1000, 'apollo', 1000, 'apollo', 'apollo');
INSERT INTO `UserRole` (`Id`, `UserId`, `RoleId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(2000, 'apollo', 3000, 'apollo', 'apollo');
INSERT INTO `UserRole` (`Id`, `UserId`, `RoleId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(3000, 'apollo', 4000, 'apollo', 'apollo');
INSERT INTO `UserRole` (`Id`, `UserId`, `RoleId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(4000, 'apollo', 7000, 'apollo', 'apollo');
INSERT INTO `UserRole` (`Id`, `UserId`, `RoleId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(5000, 'apollo', 9000, 'apollo', 'apollo');
INSERT INTO `UserRole` (`Id`, `UserId`, `RoleId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(6000, 'apollo', 10000, 'apollo', 'apollo');
INSERT INTO `UserRole` (`Id`, `UserId`, `RoleId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(7000, 'apollo', 13000, 'apollo', 'apollo');
INSERT INTO `UserRole` (`Id`, `UserId`, `RoleId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(8000, 'apollo', 15000, 'apollo', 'apollo');
INSERT INTO `UserRole` (`Id`, `UserId`, `RoleId`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES
(9000, 'apollo', 16000, 'apollo', 'apollo');
/*!40000 ALTER TABLE `UserRole` ENABLE KEYS */;
/*!40000 ALTER TABLE `Users` DISABLE KEYS */;
INSERT INTO `Users` (`Id`, `Username`, `Password`, `UserDisplayName`, `Email`, `Enabled`) VALUES
(1000, 'apollo', '$2a$10$7r20uS.BQ9uBpf3Baj3uQOZvMVvB1RN3PYoKE94gtz2.WAOuiiwXS', 'apollo', 'apollo@acme.com', 1);
/*!40000 ALTER TABLE `Users` ENABLE KEYS */;
/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
/*!40014 SET FOREIGN_KEY_CHECKS=IFNULL(@OLD_FOREIGN_KEY_CHECKS, 1) */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40111 SET SQL_NOTES=IFNULL(@OLD_SQL_NOTES, 1) */;
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册