Search in sources :

Example 21 with Result

use of com.alibaba.csp.sentinel.dashboard.domain.Result in project spring-boot-student by wyh-spring-ecosystem-student.

the class GatewayApiControllerTest method testUpdateApi.

@Test
public void testUpdateApi() throws Exception {
    String path = "/gateway/api/save.json";
    // Add one entity to memory repository for update
    ApiDefinitionEntity addEntity = new ApiDefinitionEntity();
    addEntity.setApp(TEST_APP);
    addEntity.setIp(TEST_IP);
    addEntity.setPort(TEST_PORT);
    addEntity.setApiName("bbb");
    Date date = new Date();
    // To make the gmtModified different when do update
    date = DateUtils.addSeconds(date, -1);
    addEntity.setGmtCreate(date);
    addEntity.setGmtModified(date);
    Set<ApiPredicateItemEntity> addRedicateItemEntities = new HashSet<>();
    addEntity.setPredicateItems(addRedicateItemEntities);
    ApiPredicateItemEntity addPredicateItemEntity = new ApiPredicateItemEntity();
    addPredicateItemEntity.setMatchStrategy(URL_MATCH_STRATEGY_EXACT);
    addPredicateItemEntity.setPattern("/order");
    addEntity = repository.save(addEntity);
    UpdateApiReqVo reqVo = new UpdateApiReqVo();
    reqVo.setId(addEntity.getId());
    reqVo.setApp(TEST_APP);
    List<ApiPredicateItemVo> itemVos = new ArrayList<>();
    ApiPredicateItemVo itemVo = new ApiPredicateItemVo();
    itemVo.setMatchStrategy(URL_MATCH_STRATEGY_PREFIX);
    itemVo.setPattern("/my_order");
    itemVos.add(itemVo);
    reqVo.setPredicateItems(itemVos);
    given(sentinelApiClient.modifyApis(eq(TEST_APP), eq(TEST_IP), eq(TEST_PORT), any())).willReturn(true);
    MockHttpServletRequestBuilder requestBuilder = MockMvcRequestBuilders.post(path);
    requestBuilder.content(JSON.toJSONString(reqVo)).contentType(MediaType.APPLICATION_JSON);
    // Do controller logic
    MvcResult mvcResult = mockMvc.perform(requestBuilder).andExpect(MockMvcResultMatchers.status().isOk()).andDo(MockMvcResultHandlers.print()).andReturn();
    // Verify the modifyApis method has been called
    verify(sentinelApiClient).modifyApis(eq(TEST_APP), eq(TEST_IP), eq(TEST_PORT), any());
    Result<ApiDefinitionEntity> result = JSONObject.parseObject(mvcResult.getResponse().getContentAsString(), new TypeReference<Result<ApiDefinitionEntity>>() {
    });
    assertTrue(result.isSuccess());
    ApiDefinitionEntity entity = result.getData();
    assertNotNull(entity);
    assertEquals("bbb", entity.getApiName());
    assertEquals(date, entity.getGmtCreate());
    // To make sure gmtModified has been set and it's different from gmtCreate
    assertNotNull(entity.getGmtModified());
    assertNotEquals(entity.getGmtCreate(), entity.getGmtModified());
    Set<ApiPredicateItemEntity> predicateItemEntities = entity.getPredicateItems();
    assertEquals(1, predicateItemEntities.size());
    ApiPredicateItemEntity predicateItemEntity = predicateItemEntities.iterator().next();
    assertEquals(URL_MATCH_STRATEGY_PREFIX, predicateItemEntity.getMatchStrategy().intValue());
    assertEquals("/my_order", predicateItemEntity.getPattern());
    // Verify the entity which is update in memory repository
    List<ApiDefinitionEntity> entitiesInMem = repository.findAllByApp(TEST_APP);
    assertEquals(1, entitiesInMem.size());
    assertEquals(entity, entitiesInMem.get(0));
}
Also used : MockHttpServletRequestBuilder(org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder) ApiDefinitionEntity(com.alibaba.csp.sentinel.dashboard.datasource.entity.gateway.ApiDefinitionEntity) MvcResult(org.springframework.test.web.servlet.MvcResult) Result(com.alibaba.csp.sentinel.dashboard.domain.Result) MvcResult(org.springframework.test.web.servlet.MvcResult) UpdateApiReqVo(com.alibaba.csp.sentinel.dashboard.domain.vo.gateway.api.UpdateApiReqVo) ApiPredicateItemVo(com.alibaba.csp.sentinel.dashboard.domain.vo.gateway.api.ApiPredicateItemVo) ApiPredicateItemEntity(com.alibaba.csp.sentinel.dashboard.datasource.entity.gateway.ApiPredicateItemEntity) Test(org.junit.Test) WebMvcTest(org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest)

Example 22 with Result

use of com.alibaba.csp.sentinel.dashboard.domain.Result in project spring-boot-student by wyh-spring-ecosystem-student.

the class GatewayFlowRuleControllerTest method testQueryFlowRules.

@Test
public void testQueryFlowRules() throws Exception {
    String path = "/gateway/flow/list.json";
    List<GatewayFlowRuleEntity> entities = new ArrayList<>();
    // Mock two entities
    GatewayFlowRuleEntity entity = new GatewayFlowRuleEntity();
    entity.setId(1L);
    entity.setApp(TEST_APP);
    entity.setIp(TEST_IP);
    entity.setPort(TEST_PORT);
    entity.setResource("httpbin_route");
    entity.setResourceMode(RESOURCE_MODE_ROUTE_ID);
    entity.setGrade(FLOW_GRADE_QPS);
    entity.setCount(5D);
    entity.setInterval(30L);
    entity.setIntervalUnit(GatewayFlowRuleEntity.INTERVAL_UNIT_SECOND);
    entity.setControlBehavior(CONTROL_BEHAVIOR_DEFAULT);
    entity.setBurst(0);
    entity.setMaxQueueingTimeoutMs(0);
    GatewayParamFlowItemEntity itemEntity = new GatewayParamFlowItemEntity();
    entity.setParamItem(itemEntity);
    itemEntity.setParseStrategy(PARAM_PARSE_STRATEGY_CLIENT_IP);
    entities.add(entity);
    GatewayFlowRuleEntity entity2 = new GatewayFlowRuleEntity();
    entity2.setId(2L);
    entity2.setApp(TEST_APP);
    entity2.setIp(TEST_IP);
    entity2.setPort(TEST_PORT);
    entity2.setResource("some_customized_api");
    entity2.setResourceMode(RESOURCE_MODE_CUSTOM_API_NAME);
    entity2.setCount(30D);
    entity2.setInterval(2L);
    entity2.setIntervalUnit(GatewayFlowRuleEntity.INTERVAL_UNIT_MINUTE);
    entity2.setControlBehavior(CONTROL_BEHAVIOR_DEFAULT);
    entity2.setBurst(0);
    entity2.setMaxQueueingTimeoutMs(0);
    GatewayParamFlowItemEntity itemEntity2 = new GatewayParamFlowItemEntity();
    entity2.setParamItem(itemEntity2);
    itemEntity2.setParseStrategy(PARAM_PARSE_STRATEGY_CLIENT_IP);
    entities.add(entity2);
    CompletableFuture<List<GatewayFlowRuleEntity>> completableFuture = mock(CompletableFuture.class);
    given(completableFuture.get()).willReturn(entities);
    given(sentinelApiClient.fetchGatewayFlowRules(TEST_APP, TEST_IP, TEST_PORT)).willReturn(completableFuture);
    MockHttpServletRequestBuilder requestBuilder = MockMvcRequestBuilders.get(path);
    requestBuilder.param("app", TEST_APP);
    requestBuilder.param("ip", TEST_IP);
    requestBuilder.param("port", String.valueOf(TEST_PORT));
    // Do controller logic
    MvcResult mvcResult = mockMvc.perform(requestBuilder).andExpect(MockMvcResultMatchers.status().isOk()).andDo(MockMvcResultHandlers.print()).andReturn();
    // Verify the fetchGatewayFlowRules method has been called
    verify(sentinelApiClient).fetchGatewayFlowRules(TEST_APP, TEST_IP, TEST_PORT);
    // Verify if two same entities are got
    Result<List<GatewayFlowRuleEntity>> result = JSONObject.parseObject(mvcResult.getResponse().getContentAsString(), new TypeReference<Result<List<GatewayFlowRuleEntity>>>() {
    });
    assertTrue(result.isSuccess());
    List<GatewayFlowRuleEntity> data = result.getData();
    assertEquals(2, data.size());
    assertEquals(entities, data);
    // Verify the entities are add into memory repository
    List<GatewayFlowRuleEntity> entitiesInMem = repository.findAllByApp(TEST_APP);
    assertEquals(2, entitiesInMem.size());
    assertEquals(entities, entitiesInMem);
}
Also used : GatewayFlowRuleEntity(com.alibaba.csp.sentinel.dashboard.datasource.entity.gateway.GatewayFlowRuleEntity) MockHttpServletRequestBuilder(org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder) ArrayList(java.util.ArrayList) GatewayParamFlowItemEntity(com.alibaba.csp.sentinel.dashboard.datasource.entity.gateway.GatewayParamFlowItemEntity) ArrayList(java.util.ArrayList) List(java.util.List) MvcResult(org.springframework.test.web.servlet.MvcResult) Result(com.alibaba.csp.sentinel.dashboard.domain.Result) MvcResult(org.springframework.test.web.servlet.MvcResult) Test(org.junit.Test) WebMvcTest(org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest)

Example 23 with Result

use of com.alibaba.csp.sentinel.dashboard.domain.Result in project spring-boot-student by wyh-spring-ecosystem-student.

the class GatewayApiController method addApi.

@PostMapping("/new.json")
@AuthAction(AuthService.PrivilegeType.WRITE_RULE)
public Result<ApiDefinitionEntity> addApi(HttpServletRequest request, @RequestBody AddApiReqVo reqVo) {
    String app = reqVo.getApp();
    if (StringUtil.isBlank(app)) {
        return Result.ofFail(-1, "app can't be null or empty");
    }
    ApiDefinitionEntity entity = new ApiDefinitionEntity();
    entity.setApp(app.trim());
    String ip = reqVo.getIp();
    if (StringUtil.isBlank(ip)) {
        return Result.ofFail(-1, "ip can't be null or empty");
    }
    entity.setIp(ip.trim());
    Integer port = reqVo.getPort();
    if (port == null) {
        return Result.ofFail(-1, "port can't be null");
    }
    entity.setPort(port);
    // API名称
    String apiName = reqVo.getApiName();
    if (StringUtil.isBlank(apiName)) {
        return Result.ofFail(-1, "apiName can't be null or empty");
    }
    entity.setApiName(apiName.trim());
    // 匹配规则列表
    List<ApiPredicateItemVo> predicateItems = reqVo.getPredicateItems();
    if (CollectionUtils.isEmpty(predicateItems)) {
        return Result.ofFail(-1, "predicateItems can't empty");
    }
    List<ApiPredicateItemEntity> predicateItemEntities = new ArrayList<>();
    for (ApiPredicateItemVo predicateItem : predicateItems) {
        ApiPredicateItemEntity predicateItemEntity = new ApiPredicateItemEntity();
        // 匹配模式
        Integer matchStrategy = predicateItem.getMatchStrategy();
        if (!Arrays.asList(URL_MATCH_STRATEGY_EXACT, URL_MATCH_STRATEGY_PREFIX, URL_MATCH_STRATEGY_REGEX).contains(matchStrategy)) {
            return Result.ofFail(-1, "invalid matchStrategy: " + matchStrategy);
        }
        predicateItemEntity.setMatchStrategy(matchStrategy);
        // 匹配串
        String pattern = predicateItem.getPattern();
        if (StringUtil.isBlank(pattern)) {
            return Result.ofFail(-1, "pattern can't be null or empty");
        }
        predicateItemEntity.setPattern(pattern);
        predicateItemEntities.add(predicateItemEntity);
    }
    entity.setPredicateItems(new LinkedHashSet<>(predicateItemEntities));
    // 检查API名称不能重复
    List<ApiDefinitionEntity> allApis = repository.findAllByMachine(MachineInfo.of(app.trim(), ip.trim(), port));
    if (allApis.stream().map(o -> o.getApiName()).anyMatch(o -> o.equals(apiName.trim()))) {
        return Result.ofFail(-1, "apiName exists: " + apiName);
    }
    Date date = new Date();
    entity.setGmtCreate(date);
    entity.setGmtModified(date);
    try {
        entity = repository.save(entity);
    } catch (Throwable throwable) {
        logger.error("add gateway api error:", throwable);
        return Result.ofThrowable(-1, throwable);
    }
    if (!publishApis(app, ip, port)) {
        logger.warn("publish gateway apis fail after add");
    }
    return Result.ofSuccess(entity);
}
Also used : AuthAction(com.alibaba.csp.sentinel.dashboard.auth.AuthAction) Result(com.alibaba.csp.sentinel.dashboard.domain.Result) ApiPredicateItemVo(com.alibaba.csp.sentinel.dashboard.domain.vo.gateway.api.ApiPredicateItemVo) java.util(java.util) Logger(org.slf4j.Logger) AuthService(com.alibaba.csp.sentinel.dashboard.auth.AuthService) InMemApiDefinitionStore(com.alibaba.csp.sentinel.dashboard.repository.gateway.InMemApiDefinitionStore) SentinelGatewayConstants(com.alibaba.csp.sentinel.adapter.gateway.common.SentinelGatewayConstants) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) ApiDefinitionEntity(com.alibaba.csp.sentinel.dashboard.datasource.entity.gateway.ApiDefinitionEntity) ApiPredicateItemEntity(com.alibaba.csp.sentinel.dashboard.datasource.entity.gateway.ApiPredicateItemEntity) StringUtil(com.alibaba.csp.sentinel.util.StringUtil) HttpServletRequest(javax.servlet.http.HttpServletRequest) SentinelApiClient(com.alibaba.csp.sentinel.dashboard.client.SentinelApiClient) AddApiReqVo(com.alibaba.csp.sentinel.dashboard.domain.vo.gateway.api.AddApiReqVo) CollectionUtils(org.springframework.util.CollectionUtils) org.springframework.web.bind.annotation(org.springframework.web.bind.annotation) MachineInfo(com.alibaba.csp.sentinel.dashboard.discovery.MachineInfo) UpdateApiReqVo(com.alibaba.csp.sentinel.dashboard.domain.vo.gateway.api.UpdateApiReqVo) ApiDefinitionEntity(com.alibaba.csp.sentinel.dashboard.datasource.entity.gateway.ApiDefinitionEntity) ApiPredicateItemVo(com.alibaba.csp.sentinel.dashboard.domain.vo.gateway.api.ApiPredicateItemVo) ApiPredicateItemEntity(com.alibaba.csp.sentinel.dashboard.datasource.entity.gateway.ApiPredicateItemEntity) AuthAction(com.alibaba.csp.sentinel.dashboard.auth.AuthAction)

Example 24 with Result

use of com.alibaba.csp.sentinel.dashboard.domain.Result in project XHuiCloud by sindaZeng.

the class GatewayApiController method addApi.

@PostMapping("/new.json")
@AuthAction(AuthService.PrivilegeType.WRITE_RULE)
public Result<ApiDefinitionEntity> addApi(HttpServletRequest request, @RequestBody AddApiReqVo reqVo) {
    String app = reqVo.getApp();
    if (StringUtil.isBlank(app)) {
        return Result.ofFail(-1, "app can't be null or empty");
    }
    ApiDefinitionEntity entity = new ApiDefinitionEntity();
    entity.setApp(app.trim());
    String ip = reqVo.getIp();
    if (StringUtil.isBlank(ip)) {
        return Result.ofFail(-1, "ip can't be null or empty");
    }
    entity.setIp(ip.trim());
    Integer port = reqVo.getPort();
    if (port == null) {
        return Result.ofFail(-1, "port can't be null");
    }
    entity.setPort(port);
    // API名称
    String apiName = reqVo.getApiName();
    if (StringUtil.isBlank(apiName)) {
        return Result.ofFail(-1, "apiName can't be null or empty");
    }
    entity.setApiName(apiName.trim());
    // 匹配规则列表
    List<ApiPredicateItemVo> predicateItems = reqVo.getPredicateItems();
    if (CollectionUtils.isEmpty(predicateItems)) {
        return Result.ofFail(-1, "predicateItems can't empty");
    }
    List<ApiPredicateItemEntity> predicateItemEntities = new ArrayList<>();
    for (ApiPredicateItemVo predicateItem : predicateItems) {
        ApiPredicateItemEntity predicateItemEntity = new ApiPredicateItemEntity();
        // 匹配模式
        Integer matchStrategy = predicateItem.getMatchStrategy();
        if (!Arrays.asList(URL_MATCH_STRATEGY_EXACT, URL_MATCH_STRATEGY_PREFIX, URL_MATCH_STRATEGY_REGEX).contains(matchStrategy)) {
            return Result.ofFail(-1, "invalid matchStrategy: " + matchStrategy);
        }
        predicateItemEntity.setMatchStrategy(matchStrategy);
        // 匹配串
        String pattern = predicateItem.getPattern();
        if (StringUtil.isBlank(pattern)) {
            return Result.ofFail(-1, "pattern can't be null or empty");
        }
        predicateItemEntity.setPattern(pattern);
        predicateItemEntities.add(predicateItemEntity);
    }
    entity.setPredicateItems(new LinkedHashSet<>(predicateItemEntities));
    // 检查API名称不能重复
    List<ApiDefinitionEntity> allApis = repository.findAllByMachine(MachineInfo.of(app.trim(), ip.trim(), port));
    if (allApis.stream().map(o -> o.getApiName()).anyMatch(o -> o.equals(apiName.trim()))) {
        return Result.ofFail(-1, "apiName exists: " + apiName);
    }
    Date date = new Date();
    entity.setGmtCreate(date);
    entity.setGmtModified(date);
    try {
        entity = repository.save(entity);
    } catch (Throwable throwable) {
        logger.error("add gateway api error:", throwable);
        return Result.ofThrowable(-1, throwable);
    }
    if (!publishApis(app, ip, port)) {
        logger.warn("publish gateway apis fail after add");
    }
    return Result.ofSuccess(entity);
}
Also used : AuthAction(com.alibaba.csp.sentinel.dashboard.auth.AuthAction) Result(com.alibaba.csp.sentinel.dashboard.domain.Result) ApiPredicateItemVo(com.alibaba.csp.sentinel.dashboard.domain.vo.gateway.api.ApiPredicateItemVo) java.util(java.util) Logger(org.slf4j.Logger) AuthService(com.alibaba.csp.sentinel.dashboard.auth.AuthService) InMemApiDefinitionStore(com.alibaba.csp.sentinel.dashboard.repository.gateway.InMemApiDefinitionStore) SentinelGatewayConstants(com.alibaba.csp.sentinel.adapter.gateway.common.SentinelGatewayConstants) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) ApiDefinitionEntity(com.alibaba.csp.sentinel.dashboard.datasource.entity.gateway.ApiDefinitionEntity) ApiPredicateItemEntity(com.alibaba.csp.sentinel.dashboard.datasource.entity.gateway.ApiPredicateItemEntity) StringUtil(com.alibaba.csp.sentinel.util.StringUtil) HttpServletRequest(javax.servlet.http.HttpServletRequest) SentinelApiClient(com.alibaba.csp.sentinel.dashboard.client.SentinelApiClient) AddApiReqVo(com.alibaba.csp.sentinel.dashboard.domain.vo.gateway.api.AddApiReqVo) CollectionUtils(org.springframework.util.CollectionUtils) org.springframework.web.bind.annotation(org.springframework.web.bind.annotation) MachineInfo(com.alibaba.csp.sentinel.dashboard.discovery.MachineInfo) UpdateApiReqVo(com.alibaba.csp.sentinel.dashboard.domain.vo.gateway.api.UpdateApiReqVo) ApiDefinitionEntity(com.alibaba.csp.sentinel.dashboard.datasource.entity.gateway.ApiDefinitionEntity) ApiPredicateItemVo(com.alibaba.csp.sentinel.dashboard.domain.vo.gateway.api.ApiPredicateItemVo) ApiPredicateItemEntity(com.alibaba.csp.sentinel.dashboard.datasource.entity.gateway.ApiPredicateItemEntity) AuthAction(com.alibaba.csp.sentinel.dashboard.auth.AuthAction)

Example 25 with Result

use of com.alibaba.csp.sentinel.dashboard.domain.Result in project RuoYi-Cloud-Plus by JavaLionLi.

the class GatewayApiController method addApi.

@PostMapping("/new.json")
@AuthAction(AuthService.PrivilegeType.WRITE_RULE)
public Result<ApiDefinitionEntity> addApi(HttpServletRequest request, @RequestBody AddApiReqVo reqVo) {
    String app = reqVo.getApp();
    if (StringUtil.isBlank(app)) {
        return Result.ofFail(-1, "app can't be null or empty");
    }
    ApiDefinitionEntity entity = new ApiDefinitionEntity();
    entity.setApp(app.trim());
    String ip = reqVo.getIp();
    if (StringUtil.isBlank(ip)) {
        return Result.ofFail(-1, "ip can't be null or empty");
    }
    entity.setIp(ip.trim());
    Integer port = reqVo.getPort();
    if (port == null) {
        return Result.ofFail(-1, "port can't be null");
    }
    entity.setPort(port);
    // API名称
    String apiName = reqVo.getApiName();
    if (StringUtil.isBlank(apiName)) {
        return Result.ofFail(-1, "apiName can't be null or empty");
    }
    entity.setApiName(apiName.trim());
    // 匹配规则列表
    List<ApiPredicateItemVo> predicateItems = reqVo.getPredicateItems();
    if (CollectionUtils.isEmpty(predicateItems)) {
        return Result.ofFail(-1, "predicateItems can't empty");
    }
    List<ApiPredicateItemEntity> predicateItemEntities = new ArrayList<>();
    for (ApiPredicateItemVo predicateItem : predicateItems) {
        ApiPredicateItemEntity predicateItemEntity = new ApiPredicateItemEntity();
        // 匹配模式
        Integer matchStrategy = predicateItem.getMatchStrategy();
        if (!Arrays.asList(URL_MATCH_STRATEGY_EXACT, URL_MATCH_STRATEGY_PREFIX, URL_MATCH_STRATEGY_REGEX).contains(matchStrategy)) {
            return Result.ofFail(-1, "invalid matchStrategy: " + matchStrategy);
        }
        predicateItemEntity.setMatchStrategy(matchStrategy);
        // 匹配串
        String pattern = predicateItem.getPattern();
        if (StringUtil.isBlank(pattern)) {
            return Result.ofFail(-1, "pattern can't be null or empty");
        }
        predicateItemEntity.setPattern(pattern);
        predicateItemEntities.add(predicateItemEntity);
    }
    entity.setPredicateItems(new LinkedHashSet<>(predicateItemEntities));
    // 检查API名称不能重复
    List<ApiDefinitionEntity> allApis = repository.findAllByMachine(MachineInfo.of(app.trim(), ip.trim(), port));
    if (allApis.stream().map(o -> o.getApiName()).anyMatch(o -> o.equals(apiName.trim()))) {
        return Result.ofFail(-1, "apiName exists: " + apiName);
    }
    Date date = new Date();
    entity.setGmtCreate(date);
    entity.setGmtModified(date);
    try {
        entity = repository.save(entity);
    } catch (Throwable throwable) {
        logger.error("add gateway api error:", throwable);
        return Result.ofThrowable(-1, throwable);
    }
    if (!publishApis(app, ip, port)) {
        logger.warn("publish gateway apis fail after add");
    }
    return Result.ofSuccess(entity);
}
Also used : AuthAction(com.alibaba.csp.sentinel.dashboard.auth.AuthAction) Result(com.alibaba.csp.sentinel.dashboard.domain.Result) ApiPredicateItemVo(com.alibaba.csp.sentinel.dashboard.domain.vo.gateway.api.ApiPredicateItemVo) java.util(java.util) Logger(org.slf4j.Logger) AuthService(com.alibaba.csp.sentinel.dashboard.auth.AuthService) InMemApiDefinitionStore(com.alibaba.csp.sentinel.dashboard.repository.gateway.InMemApiDefinitionStore) SentinelGatewayConstants(com.alibaba.csp.sentinel.adapter.gateway.common.SentinelGatewayConstants) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) ApiDefinitionEntity(com.alibaba.csp.sentinel.dashboard.datasource.entity.gateway.ApiDefinitionEntity) ApiPredicateItemEntity(com.alibaba.csp.sentinel.dashboard.datasource.entity.gateway.ApiPredicateItemEntity) StringUtil(com.alibaba.csp.sentinel.util.StringUtil) HttpServletRequest(javax.servlet.http.HttpServletRequest) SentinelApiClient(com.alibaba.csp.sentinel.dashboard.client.SentinelApiClient) AddApiReqVo(com.alibaba.csp.sentinel.dashboard.domain.vo.gateway.api.AddApiReqVo) CollectionUtils(org.springframework.util.CollectionUtils) org.springframework.web.bind.annotation(org.springframework.web.bind.annotation) MachineInfo(com.alibaba.csp.sentinel.dashboard.discovery.MachineInfo) UpdateApiReqVo(com.alibaba.csp.sentinel.dashboard.domain.vo.gateway.api.UpdateApiReqVo) ApiDefinitionEntity(com.alibaba.csp.sentinel.dashboard.datasource.entity.gateway.ApiDefinitionEntity) ApiPredicateItemVo(com.alibaba.csp.sentinel.dashboard.domain.vo.gateway.api.ApiPredicateItemVo) ApiPredicateItemEntity(com.alibaba.csp.sentinel.dashboard.datasource.entity.gateway.ApiPredicateItemEntity) AuthAction(com.alibaba.csp.sentinel.dashboard.auth.AuthAction)

Aggregations

Result (com.alibaba.csp.sentinel.dashboard.domain.Result)26 Test (org.junit.Test)16 WebMvcTest (org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest)16 MvcResult (org.springframework.test.web.servlet.MvcResult)16 MockHttpServletRequestBuilder (org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder)16 ApiDefinitionEntity (com.alibaba.csp.sentinel.dashboard.datasource.entity.gateway.ApiDefinitionEntity)13 ApiPredicateItemEntity (com.alibaba.csp.sentinel.dashboard.datasource.entity.gateway.ApiPredicateItemEntity)13 ApiPredicateItemVo (com.alibaba.csp.sentinel.dashboard.domain.vo.gateway.api.ApiPredicateItemVo)9 NoAuthConfigurationTest (com.alibaba.csp.sentinel.dashboard.config.NoAuthConfigurationTest)8 GatewayFlowRuleEntity (com.alibaba.csp.sentinel.dashboard.datasource.entity.gateway.GatewayFlowRuleEntity)8 AddApiReqVo (com.alibaba.csp.sentinel.dashboard.domain.vo.gateway.api.AddApiReqVo)7 UpdateApiReqVo (com.alibaba.csp.sentinel.dashboard.domain.vo.gateway.api.UpdateApiReqVo)7 Date (java.util.Date)7 GatewayParamFlowItemEntity (com.alibaba.csp.sentinel.dashboard.datasource.entity.gateway.GatewayParamFlowItemEntity)6 SentinelGatewayConstants (com.alibaba.csp.sentinel.adapter.gateway.common.SentinelGatewayConstants)5 AuthAction (com.alibaba.csp.sentinel.dashboard.auth.AuthAction)5 AuthService (com.alibaba.csp.sentinel.dashboard.auth.AuthService)5 SentinelApiClient (com.alibaba.csp.sentinel.dashboard.client.SentinelApiClient)5 MachineInfo (com.alibaba.csp.sentinel.dashboard.discovery.MachineInfo)5 InMemApiDefinitionStore (com.alibaba.csp.sentinel.dashboard.repository.gateway.InMemApiDefinitionStore)5