Package org.springframework.security.oauth2.common.exceptions

Examples of org.springframework.security.oauth2.common.exceptions.OAuth2Exception


    assertEquals(expected, getOutput());
  }

  @Test
  public void writeUnsupportedGrantType() throws Exception {
    OAuth2Exception oauthException = new UnsupportedGrantTypeException(DETAILS);
    String expected = createResponse(oauthException.getOAuth2ErrorCode());
    converter.write(oauthException, contentType, outputMessage);
    assertEquals(expected, getOutput());
  }
View Full Code Here


    assertEquals(expected, getOutput());
  }

  @Test
  public void writeUnauthorizedClient() throws Exception {
    OAuth2Exception oauthException = new UnauthorizedUserException(DETAILS);
    String expected = createResponse(oauthException.getOAuth2ErrorCode());
    converter.write(oauthException, contentType, outputMessage);
    assertEquals(expected, getOutput());
  }
View Full Code Here

    assertEquals(expected, getOutput());
  }

  @Test
  public void writeAccessDenied() throws Exception {
    OAuth2Exception oauthException = new UserDeniedAuthorizationException(DETAILS);
    String expected = createResponse(oauthException.getOAuth2ErrorCode());
    converter.write(oauthException, contentType, outputMessage);
    assertEquals(expected, getOutput());
  }
View Full Code Here

    assertEquals(expected, getOutput());
  }

  @Test
  public void writeRedirectUriMismatch() throws Exception {
    OAuth2Exception oauthException = new RedirectMismatchException(DETAILS);
    String expected = createResponse(oauthException.getOAuth2ErrorCode());
    converter.write(oauthException, contentType, outputMessage);
    assertEquals(expected, getOutput());
  }
View Full Code Here

    assertEquals(expected, getOutput());
  }

  @Test
  public void writeInvalidToken() throws Exception {
    OAuth2Exception oauthException = new InvalidTokenException(DETAILS);
    String expected = createResponse(oauthException.getOAuth2ErrorCode());
    converter.write(oauthException, contentType, outputMessage);
    assertEquals(expected, getOutput());
  }
View Full Code Here

    assertEquals(expected, getOutput());
  }

  @Test
  public void writeOAuth2Exception() throws Exception {
    OAuth2Exception oauthException = new OAuth2Exception(DETAILS);
    String expected = createResponse(oauthException.getOAuth2ErrorCode());
    converter.write(oauthException, contentType, outputMessage);
    assertEquals(expected, getOutput());
  }
View Full Code Here

  }

  @Test
  public void testExceptionDeserialization() throws Exception {
    String exception = "{\"error\": \"invalid_client\", \"error_description\": \"FOO\", \"foo\": \"bar\"}";
    OAuth2Exception result = new ObjectMapper().readValue(exception, OAuth2Exception.class);
    // System.err.println(result);
    assertEquals("FOO", result.getMessage());
    assertEquals("invalid_client", result.getOAuth2ErrorCode());
    assertEquals("{foo=bar}", result.getAdditionalInformation().toString());
    assertTrue(result instanceof InvalidClientException);
  }
View Full Code Here

  // SECOAUTH-311
  @Test
  public void writeCreatesNewUnmarshaller() throws Exception {
    useMockJAXBContext(converter, JaxbOAuth2Exception.class);
    OAuth2Exception oauthException = new OAuth2Exception(DETAILS);

    converter.write(oauthException, contentType, outputMessage);
    verify(context).createMarshaller();

    converter.write(oauthException, contentType, outputMessage);
View Full Code Here

  @Test
  public void readUndefinedException() throws Exception {
    String accessToken = createResponse("notdefinedcode");
    when(inputMessage.getBody()).thenReturn(createInputStream(accessToken));
    @SuppressWarnings("unused")
    OAuth2Exception result = converter.read(OAuth2Exception.class, inputMessage);
  }
View Full Code Here

  @Test
  public void testExceptionDeserialization() throws Exception {
    Map<String, String> exception = MapBuilder.create("error", "invalid_client").add("error_description", "FOO")
        .build();
    OAuth2Exception result = OAuth2Exception.valueOf(exception);
    // System.err.println(result);
    assertEquals("FOO", result.getMessage());
    assertEquals("invalid_client", result.getOAuth2ErrorCode());
    assertTrue(result instanceof InvalidClientException);
  }
View Full Code Here

TOP

Related Classes of org.springframework.security.oauth2.common.exceptions.OAuth2Exception

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.