Интеграционные тесты для безопасной конечной точки в QuarkusJAVA

Программисты JAVA общаются здесь
Ответить
Гость
 Интеграционные тесты для безопасной конечной точки в Quarkus

Сообщение Гость »


I have a quarkus application, created a custom annotation with interceptor to secure endpoints.

// Custom annotation

Код: Выделить всё

@InterceptorBinding @Retention(RetentionPolicy.RUNTIME) @Target({ ElementType.METHOD, ElementType.TYPE }) public @interface PermitRole { } 
//Interceptor binded with annotation

Код: Выделить всё

@Interceptor @PermitRole public class LiveTraderRolesAuthorization {     @Inject    HttpHeaders headers;    @Inject    JWTTokenParser jwtTokenParser;    @AroundInvoke    public Object authorize(InvocationContext context) throws Exception {        // here i have logic to ***parse Authorization header JWT token using nimbus-jose*** and setting authorized flag.        if(authorized) {         return context.proceed();       }     } } 
// my controller method

Код: Выделить всё

    @GET     @PermitRole     @Produces(MediaType.APPLICATION_JSON)     public RestResponse getSome(@PathParam("Id") String Id) {         //logic     } 
Question : Now integration tests for my controller is failing after adding the custom annotation. One way to solve this is I can mock JWTTokenParser in tests and return the mocked claims, But is there a better way to write integration tests for interceptor and controller together so that whole interceptor and token parsing logic can be tested like real application. Really appreciate any help !!

NOTE: I am using nimbus-jose-jwt library to parse the Jwt token, not anything specific to quarkus.


Источник: https://stackoverflow.com/questions/781 ... in-quarkus
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «JAVA»