小编Rab*_*tha的帖子

Spring boot:我如何自定义禁止错误json

我想知道是否可以自定义以下禁止的 JSON 错误:

实际反应

{
  "timestamp": "2018-09-26T06:11:05.047+0000",
  "status": 403,
  "error": "Forbidden",
  "message": "Access Denied",
  "path": "/api/rest/hello/me"
}
Run Code Online (Sandbox Code Playgroud)

自定义响应 - 当用户请求没有权限时我会收到它。

{ 
  "code": 403,
  "message": "Access denied by the system",
  "status": "Failure"
}
Run Code Online (Sandbox Code Playgroud)

我的网络安全课程

@Configuration
@EnableGlobalMethodSecurity(prePostEnabled = true)
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

  @Autowired
  private JwtTokenProvider jwtTokenProvider;

  @Override
  protected void configure(HttpSecurity http) throws Exception {
    http.csrf().disable();
    http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS);
    http.authorizeRequests()//
        .antMatchers("/rest/hello/signin").permitAll()//
        .anyRequest().authenticated();
    http.apply(new JwtTokenFilterConfigurer(jwtTokenProvider));
  @Bean
  public PasswordEncoder passwordEncoder() {
    return new BCryptPasswordEncoder(12);
  }
}
Run Code Online (Sandbox Code Playgroud)

java spring-security jwt spring-boot

8
推荐指数
2
解决办法
6319
查看次数

testng范围报告中的测试和步骤之间的差异

我对testng范围报告中的测试和步骤之间的区别感到困惑.

我有2个测试用例,1次通过,1次失败.在测试范围报告中:1个测试通过1个测试失败,0个其他测试失败,步骤:1个步骤通过2个步骤失败,0个其他

那么有人会澄清两者之间有什么区别吗?

附加代码段和testng范围报告

    @Test
    public void demoTestPass()
    {
        test = extent.createTest("demoTestPass", "This test will demonstrate the PASS test case");
        Assert.assertTrue(true);
    }


    @Test
    public void demoTestFail()
    {
        test = extent.createTest("demoTestFail", "This test will demonstrate the FAIL test case");
        Assert.assertEquals("Hi", "Hello");
    }
Run Code Online (Sandbox Code Playgroud)

请点击此处查看范围报告.

任何澄清将非常感激.

java selenium-extent-report extentreports

5
推荐指数
2
解决办法
1385
查看次数

如何在 OpenAPI 中定义 XML 对象数组?

我正在使用 OpenAPI 3.0 和 SwaggerHub 设计一个 API。我的 API 有一个 GET 端点,它以 XML 格式返回员工数组:

<Employees>
  <Employee>
    <EmpId>001</EmpId>
    <Name>Steven</Name>
    <Mobile>1-541-754-3010</Mobile>
    <EmailId>steven@yourcomany.com</EmailId>
  </Employee>
  <Employee>
    <EmpId>002</EmpId>
    <Name>Mark</Name>
    <Mobile>1-551-754-3010</Mobile>
    <EmailId>mark@yourcomany.com</EmailId>
  </Employee>
</Employees>
Run Code Online (Sandbox Code Playgroud)

这是到目前为止我的 OpenAPI YAML 文件:

openapi: 3.0.0
info:
  title: General Document
  version: "1.0"
  contact:
    email: developer@email.com
  description: >
    # Introduction 

    This document describes a list of API's available. \

paths:
  /employees:
    get:
      description: This will return employees information in JSON and XML formats
      responses:
        200:
          $ref: '#/components/responses/employeesAPI'

components:
  responses:
    employeesAPI:
      description: This will return …
Run Code Online (Sandbox Code Playgroud)

swagger openapi swaggerhub

5
推荐指数
1
解决办法
4621
查看次数