Java Code Examples for org.apache.pulsar.client.admin.PulsarAdminException#NotAuthorizedException

The following examples show how to use org.apache.pulsar.client.admin.PulsarAdminException#NotAuthorizedException . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AdminApiTlsAuthTest.java    From pulsar with Apache License 2.0 5 votes vote down vote up
@Test
public void testProxyRoleCantListTenants() throws Exception {
    try (PulsarAdmin admin = buildAdminClient("admin")) {
        admin.tenants().createTenant("tenant1",
                                     new TenantInfo(ImmutableSet.of("foobar"),
                                                    ImmutableSet.of("test")));
    }
    try (PulsarAdmin admin = buildAdminClient("proxy")) {
        admin.tenants().getTenants();
        Assert.fail("Shouldn't be able to list tenants");
    } catch (PulsarAdminException.NotAuthorizedException e) {
        // expected
    }
}
 
Example 2
Source File: AdminApiTlsAuthTest.java    From pulsar with Apache License 2.0 5 votes vote down vote up
@Test
public void testProxyRoleCantListNamespacesEvenWithAccess() throws Exception {
    try (PulsarAdmin admin = buildAdminClient("admin")) {
        admin.tenants().createTenant("tenant1",
                                     new TenantInfo(ImmutableSet.of("proxy"),
                                                    ImmutableSet.of("test")));
        admin.namespaces().createNamespace("tenant1/ns1");
    }
    try (PulsarAdmin admin = buildAdminClient("proxy")) {
        admin.namespaces().getNamespaces("tenant1");
        Assert.fail("Shouldn't be able to list namespaces");
    } catch (PulsarAdminException.NotAuthorizedException e) {
        // expected
    }
}
 
Example 3
Source File: SuperUserAuthedAdminProxyHandlerTest.java    From pulsar with Apache License 2.0 5 votes vote down vote up
@Test
public void testAuthWithRandoCert() throws Exception {
    // test that we cannot connect or do anything with a cert not signed by CA
    try (PulsarAdmin randoAdmin = getAdminClient("randouser")) {
        try {
            randoAdmin.tenants().getTenants();
            Assert.fail("Shouldn't be able to do anything");
        } catch (PulsarAdminException.NotAuthorizedException e) {
            // expected
        }
    }
}