Search in sources :

Example 1 with MockServerCnxn

use of org.apache.zookeeper.server.MockServerCnxn in project zookeeper by apache.

the class X509AuthTest method testTrustedAuth.

@Test
public void testTrustedAuth() {
    X509AuthenticationProvider provider = createProvider(clientCert);
    MockServerCnxn cnxn = new MockServerCnxn();
    cnxn.clientChain = new X509Certificate[] { clientCert };
    Assert.assertEquals(KeeperException.Code.OK, provider.handleAuthentication(cnxn, null));
}
Also used : X509AuthenticationProvider(org.apache.zookeeper.server.auth.X509AuthenticationProvider) MockServerCnxn(org.apache.zookeeper.server.MockServerCnxn) Test(org.junit.Test)

Example 2 with MockServerCnxn

use of org.apache.zookeeper.server.MockServerCnxn in project zookeeper by apache.

the class X509AuthTest method testUntrustedAuth.

@Test
public void testUntrustedAuth() {
    X509AuthenticationProvider provider = createProvider(clientCert);
    MockServerCnxn cnxn = new MockServerCnxn();
    cnxn.clientChain = new X509Certificate[] { unknownCert };
    Assert.assertEquals(KeeperException.Code.AUTHFAILED, provider.handleAuthentication(cnxn, null));
}
Also used : X509AuthenticationProvider(org.apache.zookeeper.server.auth.X509AuthenticationProvider) MockServerCnxn(org.apache.zookeeper.server.MockServerCnxn) Test(org.junit.Test)

Example 3 with MockServerCnxn

use of org.apache.zookeeper.server.MockServerCnxn in project zookeeper by apache.

the class X509AuthTest method testSuperAuth.

@Test
public void testSuperAuth() {
    X509AuthenticationProvider provider = createProvider(superCert);
    MockServerCnxn cnxn = new MockServerCnxn();
    cnxn.clientChain = new X509Certificate[] { superCert };
    Assert.assertEquals(KeeperException.Code.OK, provider.handleAuthentication(cnxn, null));
    Assert.assertEquals("super", cnxn.getAuthInfo().get(0).getScheme());
}
Also used : X509AuthenticationProvider(org.apache.zookeeper.server.auth.X509AuthenticationProvider) MockServerCnxn(org.apache.zookeeper.server.MockServerCnxn) Test(org.junit.Test)

Aggregations

MockServerCnxn (org.apache.zookeeper.server.MockServerCnxn)3 X509AuthenticationProvider (org.apache.zookeeper.server.auth.X509AuthenticationProvider)3 Test (org.junit.Test)3