Package io.dropwizard.auth

Examples of io.dropwizard.auth.AuthenticationException


    @Test
    public void shouldLogWhenExceptionIsThrown() throws AuthenticationException {
        final DefaultExceptionLogger defaultExceptionLogger = spy(new DefaultExceptionLogger());
        HystrixPlugins.getInstance().registerCommandExecutionHook(new ExceptionLoggingCommandHook(defaultExceptionLogger));
        when(mockAuthenticator.authenticate(any(String.class))).thenThrow(new AuthenticationException("test"));
        doCallRealMethod().when(defaultExceptionLogger).log(any(Exception.class), any(HystrixCommand.class));

        try {
            tenacityAuthenticator.authenticate("foo");
        } catch (HystrixRuntimeException err) {
View Full Code Here


        verify(defaultExceptionLogger, times(1)).log(any(Exception.class), any(HystrixCommand.class));
    }

    @Test
    public void shouldNotTransformAuthenticationExceptionIntoMappedException() throws AuthenticationException {
        when(mockAuthenticator.authenticate(any(String.class))).thenThrow(new AuthenticationException("test"));
        final ClientResponse response = resources
                .client()
                .resource("/auth")
                .header(HttpHeaders.AUTHORIZATION, "Bearer stuff")
                .get(ClientResponse.class);
View Full Code Here

    }

    @Test
    public void authenticationExceptions() throws AuthenticationException {
        try {
            when(mockAuthenticator.authenticate(anyString())).thenThrow(new AuthenticationException("auth error"));
            resources.client()
                    .resource("/")
                    .header(HttpHeaders.AUTHORIZATION, "Bearer TEST")
                    .get(String.class);
        } catch (UniformInterfaceException err) {
View Full Code Here

                    if ("good-guy".equals(credentials.getUsername()) &&
                            "secret".equals(credentials.getPassword())) {
                        return Optional.of("good-guy");
                    }
                    if ("bad-guy".equals(credentials.getUsername())) {
                        throw new AuthenticationException("CRAP");
                    }
                    return Optional.absent();
                }
            };
            register(AuthFactory.binder(new BasicAuthFactory<>(authenticator, "realm", String.class)));
View Full Code Here

                    if ("good-guy".equals(credentials)) {
                        return Optional.of("good-guy");
                    }

                    if ("bad-guy".equals(credentials)) {
                        throw new AuthenticationException("CRAP");
                    }

                    return Optional.absent();
                }
            };
View Full Code Here

TOP

Related Classes of io.dropwizard.auth.AuthenticationException

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.