Search in sources :

Example 1 with NotAuthorizedException

use of jakarta.ws.rs.NotAuthorizedException in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method constructorStringResponseThrowableTest.

/*
   * @testName: constructorStringResponseThrowableTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:1086; JAXRS:JAVADOC:12;
   * 
   * @test_Strategy: Construct a new "not authorized" exception. getResponse
   */
@Test
public void constructorStringResponseThrowableTest() throws Fault {
    Throwable[] throwables = new Throwable[] { new RuntimeException(), new IOException(), new Error(), new Throwable() };
    for (Throwable t : throwables) {
        NotAuthorizedException e = new NotAuthorizedException(MESSAGE, buildResponse(STATUS), t);
        assertResponse(e, HOST);
        assertCause(e, t);
        assertMessage(e);
    }
}
Also used : IOException(java.io.IOException) NotAuthorizedException(jakarta.ws.rs.NotAuthorizedException) Test(org.junit.jupiter.api.Test)

Example 2 with NotAuthorizedException

use of jakarta.ws.rs.NotAuthorizedException in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method constructorResponseTest.

/*
   * @testName: constructorResponseTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:336; JAXRS:JAVADOC:12;
   * 
   * @test_Strategy: Construct a new "not authorized" exception.
   * java.lang.IllegalArgumentException - in case the status code set in the
   * response is not HTTP 401.
   * 
   * getResponse
   */
@Test
public void constructorResponseTest() throws Fault {
    NotAuthorizedException e = new NotAuthorizedException(buildResponse(STATUS));
    assertResponse(e, HOST);
}
Also used : NotAuthorizedException(jakarta.ws.rs.NotAuthorizedException) Test(org.junit.jupiter.api.Test)

Example 3 with NotAuthorizedException

use of jakarta.ws.rs.NotAuthorizedException in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method constructorObjectsThrowsNPEWhenNullTest.

/*
   * @testName: constructorObjectsThrowsNPEWhenNullTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:335;
   * 
   * @test_Strategy: Throws: java.lang.NullPointerException - in case the
   * challenge parameter is null.
   */
@Test
public void constructorObjectsThrowsNPEWhenNullTest() throws Fault {
    try {
        NotAuthorizedException e = new NotAuthorizedException((Object) null, CHALLENGE[1], CHALLENGE[2]);
        fault("NullPointerException has NOT been thrown as expected for null challenge; exception", e);
    } catch (NullPointerException npe) {
        logMsg("NullPointerException has been thrown as expected for null challenge");
    }
}
Also used : NotAuthorizedException(jakarta.ws.rs.NotAuthorizedException) Test(org.junit.jupiter.api.Test)

Example 4 with NotAuthorizedException

use of jakarta.ws.rs.NotAuthorizedException in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method constructorResponseThrowableTest.

/*
   * @testName: constructorResponseThrowableTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:338; JAXRS:JAVADOC:12;
   * 
   * @test_Strategy: Construct a new "not authorized" exception.
   * java.lang.IllegalArgumentException - in case the status code set in the
   * response is not HTTP 401. getResponse
   */
@Test
public void constructorResponseThrowableTest() throws Fault {
    Throwable[] throwables = new Throwable[] { new RuntimeException(), new IOException(), new Error(), new Throwable() };
    for (Throwable t : throwables) {
        NotAuthorizedException e = new NotAuthorizedException(buildResponse(STATUS), t);
        assertResponse(e, HOST);
        assertCause(e, t);
    }
}
Also used : IOException(java.io.IOException) NotAuthorizedException(jakarta.ws.rs.NotAuthorizedException) Test(org.junit.jupiter.api.Test)

Example 5 with NotAuthorizedException

use of jakarta.ws.rs.NotAuthorizedException in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method constructorStringResponseTest.

/*
   * @testName: constructorStringResponseTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:1084; JAXRS:JAVADOC:12;
   * 
   * @test_Strategy: Construct a new "not authorized" exception.
   * 
   * getResponse
   */
@Test
public void constructorStringResponseTest() throws Fault {
    NotAuthorizedException e = new NotAuthorizedException(MESSAGE, buildResponse(STATUS));
    assertResponse(e, HOST);
    assertMessage(e);
}
Also used : NotAuthorizedException(jakarta.ws.rs.NotAuthorizedException) Test(org.junit.jupiter.api.Test)

Aggregations

NotAuthorizedException (jakarta.ws.rs.NotAuthorizedException)18 Test (org.junit.jupiter.api.Test)10 IOException (java.io.IOException)5 Test (org.junit.Test)4 ForbiddenException (jakarta.ws.rs.ForbiddenException)3 InternalServerErrorException (jakarta.ws.rs.InternalServerErrorException)3 BadRequestException (jakarta.ws.rs.BadRequestException)2 ClientErrorException (jakarta.ws.rs.ClientErrorException)2 NotAcceptableException (jakarta.ws.rs.NotAcceptableException)2 NotAllowedException (jakarta.ws.rs.NotAllowedException)2 NotFoundException (jakarta.ws.rs.NotFoundException)2 NotSupportedException (jakarta.ws.rs.NotSupportedException)2 ServerErrorException (jakarta.ws.rs.ServerErrorException)2 Response (jakarta.ws.rs.core.Response)2 SecurityContext (jakarta.ws.rs.core.SecurityContext)2 ResteasyClient (org.jboss.resteasy.client.jaxrs.ResteasyClient)2 JWT (com.auth0.jwt.JWT)1 JWTVerificationException (com.auth0.jwt.exceptions.JWTVerificationException)1 Claim (com.auth0.jwt.interfaces.Claim)1 DecodedJWT (com.auth0.jwt.interfaces.DecodedJWT)1