Search in sources :

Example 6 with ZKMetadataStore

use of org.apache.pulsar.metadata.impl.ZKMetadataStore in project pulsar by apache.

the class SimpleProxyExtensionTestBase method setup.

@BeforeClass
@Override
protected void setup() throws Exception {
    tempDirectory = Files.createTempDirectory("SimpleProxyExtensionTest").toFile();
    super.internalSetup();
    proxyConfig.setUseSeparateThreadPoolForProxyExtensions(useSeparateThreadPoolForProxyExtensions);
    proxyConfig.setProxyExtensionsDirectory(tempDirectory.getAbsolutePath());
    proxyConfig.setProxyExtensions(Collections.singleton("test"));
    buildMockNarFile(tempDirectory);
    proxyConfig.setServicePort(Optional.ofNullable(0));
    proxyConfig.setBrokerProxyAllowedTargetPorts("*");
    proxyConfig.setMetadataStoreUrl(DUMMY_VALUE);
    proxyConfig.setConfigurationMetadataStoreUrl(GLOBAL_DUMMY_VALUE);
    proxyService = Mockito.spy(new ProxyService(proxyConfig, new AuthenticationService(PulsarConfigurationLoader.convertFrom(proxyConfig))));
    doReturn(new ZKMetadataStore(mockZooKeeper)).when(proxyService).createLocalMetadataStore();
    doReturn(new ZKMetadataStore(mockZooKeeperGlobal)).when(proxyService).createConfigurationMetadataStore();
    proxyService.start();
}
Also used : ProxyService(org.apache.pulsar.proxy.server.ProxyService) AuthenticationService(org.apache.pulsar.broker.authentication.AuthenticationService) ZKMetadataStore(org.apache.pulsar.metadata.impl.ZKMetadataStore) BeforeClass(org.testng.annotations.BeforeClass)

Example 7 with ZKMetadataStore

use of org.apache.pulsar.metadata.impl.ZKMetadataStore in project pulsar by apache.

the class ProxyEnableHAProxyProtocolTest method setup.

@Override
@BeforeClass
protected void setup() throws Exception {
    conf.setHaProxyProtocolEnabled(true);
    internalSetup();
    proxyConfig.setServicePort(Optional.ofNullable(0));
    proxyConfig.setBrokerProxyAllowedTargetPorts("*");
    proxyConfig.setMetadataStoreUrl(DUMMY_VALUE);
    proxyConfig.setConfigurationMetadataStoreUrl(GLOBAL_DUMMY_VALUE);
    proxyConfig.setHaProxyProtocolEnabled(true);
    proxyService = Mockito.spy(new ProxyService(proxyConfig, new AuthenticationService(PulsarConfigurationLoader.convertFrom(proxyConfig))));
    doReturn(new ZKMetadataStore(mockZooKeeper)).when(proxyService).createLocalMetadataStore();
    doReturn(new ZKMetadataStore(mockZooKeeperGlobal)).when(proxyService).createConfigurationMetadataStore();
    proxyService.start();
}
Also used : AuthenticationService(org.apache.pulsar.broker.authentication.AuthenticationService) ZKMetadataStore(org.apache.pulsar.metadata.impl.ZKMetadataStore) BeforeClass(org.testng.annotations.BeforeClass)

Example 8 with ZKMetadataStore

use of org.apache.pulsar.metadata.impl.ZKMetadataStore in project pulsar by apache.

the class ProxyTest method setup.

@Override
@BeforeClass
protected void setup() throws Exception {
    internalSetup();
    proxyConfig.setServicePort(Optional.ofNullable(0));
    proxyConfig.setBrokerProxyAllowedTargetPorts("*");
    proxyConfig.setMetadataStoreUrl(DUMMY_VALUE);
    proxyConfig.setConfigurationMetadataStoreUrl(GLOBAL_DUMMY_VALUE);
    proxyService = Mockito.spy(new ProxyService(proxyConfig, new AuthenticationService(PulsarConfigurationLoader.convertFrom(proxyConfig))));
    doReturn(new ZKMetadataStore(mockZooKeeper)).when(proxyService).createLocalMetadataStore();
    doReturn(new ZKMetadataStore(mockZooKeeperGlobal)).when(proxyService).createConfigurationMetadataStore();
    proxyService.start();
}
Also used : AuthenticationService(org.apache.pulsar.broker.authentication.AuthenticationService) ZKMetadataStore(org.apache.pulsar.metadata.impl.ZKMetadataStore) BeforeClass(org.testng.annotations.BeforeClass)

Example 9 with ZKMetadataStore

use of org.apache.pulsar.metadata.impl.ZKMetadataStore in project pulsar by apache.

the class ProxyTlsTestWithAuth method setup.

@Override
@BeforeClass
protected void setup() throws Exception {
    internalSetup();
    File tempFile = File.createTempFile("oauth2", ".tmp");
    tempFile.deleteOnExit();
    FileWriter writer = new FileWriter(tempFile);
    writer.write("{\n" + "  \"client_id\":\"Xd23RHsUnvUlP7wchjNYOaIfazgeHd9x\",\n" + "  \"client_secret\":\"rT7ps7WY8uhdVuBTKWZkttwLdQotmdEliaM5rLfmgNibvqziZ-g07ZH52N_poGAb\"\n" + "}");
    writer.flush();
    writer.close();
    proxyConfig.setServicePort(Optional.of(0));
    proxyConfig.setBrokerProxyAllowedTargetPorts("*");
    proxyConfig.setServicePortTls(Optional.of(0));
    proxyConfig.setWebServicePort(Optional.of(0));
    proxyConfig.setWebServicePortTls(Optional.of(0));
    proxyConfig.setTlsEnabledWithBroker(true);
    proxyConfig.setTlsCertificateFilePath(TLS_PROXY_CERT_FILE_PATH);
    proxyConfig.setTlsKeyFilePath(TLS_PROXY_KEY_FILE_PATH);
    proxyConfig.setMetadataStoreUrl(DUMMY_VALUE);
    proxyConfig.setConfigurationMetadataStoreUrl(GLOBAL_DUMMY_VALUE);
    proxyConfig.setBrokerClientAuthenticationPlugin("org.apache.pulsar.client.impl.auth.oauth2.AuthenticationOAuth2");
    proxyConfig.setBrokerClientAuthenticationParameters("{\"grant_type\":\"client_credentials\"," + " \"issuerUrl\":\"https://dev-kt-aa9ne.us.auth0.com\"," + " \"audience\": \"https://dev-kt-aa9ne.us.auth0.com/api/v2/\"," + " \"privateKey\":\"file://" + tempFile.getAbsolutePath() + "\"}");
    proxyService = Mockito.spy(new ProxyService(proxyConfig, new AuthenticationService(PulsarConfigurationLoader.convertFrom(proxyConfig))));
    doReturn(new ZKMetadataStore(mockZooKeeper)).when(proxyService).createLocalMetadataStore();
    doReturn(new ZKMetadataStore(mockZooKeeperGlobal)).when(proxyService).createConfigurationMetadataStore();
    proxyService.start();
}
Also used : FileWriter(java.io.FileWriter) File(java.io.File) AuthenticationService(org.apache.pulsar.broker.authentication.AuthenticationService) ZKMetadataStore(org.apache.pulsar.metadata.impl.ZKMetadataStore) BeforeClass(org.testng.annotations.BeforeClass)

Example 10 with ZKMetadataStore

use of org.apache.pulsar.metadata.impl.ZKMetadataStore in project pulsar by apache.

the class ProxyKeyStoreTlsTestWithAuth method setup.

@Override
@BeforeMethod
protected void setup() throws Exception {
    internalSetup();
    proxyConfig.setServicePort(Optional.of(0));
    proxyConfig.setBrokerProxyAllowedTargetPorts("*");
    proxyConfig.setServicePortTls(Optional.of(0));
    proxyConfig.setWebServicePort(Optional.of(0));
    proxyConfig.setWebServicePortTls(Optional.of(0));
    proxyConfig.setTlsEnabledWithBroker(false);
    proxyConfig.setTlsEnabledWithKeyStore(true);
    proxyConfig.setTlsKeyStoreType(KEYSTORE_TYPE);
    proxyConfig.setTlsKeyStore(BROKER_KEYSTORE_FILE_PATH);
    proxyConfig.setTlsKeyStorePassword(BROKER_KEYSTORE_PW);
    proxyConfig.setTlsTrustStoreType(KEYSTORE_TYPE);
    proxyConfig.setTlsTrustStore(CLIENT_TRUSTSTORE_FILE_PATH);
    proxyConfig.setTlsTrustStorePassword(CLIENT_TRUSTSTORE_PW);
    proxyConfig.setMetadataStoreUrl(DUMMY_VALUE);
    proxyConfig.setConfigurationMetadataStoreUrl(GLOBAL_DUMMY_VALUE);
    // config for authentication and authorization.
    proxyConfig.setTlsRequireTrustedClientCertOnConnect(true);
    proxyConfig.setSuperUserRoles(Sets.newHashSet(CLIENT_KEYSTORE_CN));
    proxyConfig.setAuthenticationEnabled(true);
    proxyConfig.setAuthorizationEnabled(true);
    Set<String> providers = new HashSet<>();
    providers.add(AuthenticationProviderTls.class.getName());
    proxyConfig.setAuthenticationProviders(providers);
    proxyService = Mockito.spy(new ProxyService(proxyConfig, new AuthenticationService(PulsarConfigurationLoader.convertFrom(proxyConfig))));
    doReturn(new ZKMetadataStore(mockZooKeeper)).when(proxyService).createLocalMetadataStore();
    doReturn(new ZKMetadataStore(mockZooKeeperGlobal)).when(proxyService).createConfigurationMetadataStore();
    proxyService.start();
}
Also used : AuthenticationService(org.apache.pulsar.broker.authentication.AuthenticationService) ZKMetadataStore(org.apache.pulsar.metadata.impl.ZKMetadataStore) HashSet(java.util.HashSet) AuthenticationProviderTls(org.apache.pulsar.broker.authentication.AuthenticationProviderTls) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

ZKMetadataStore (org.apache.pulsar.metadata.impl.ZKMetadataStore)102 AuthenticationService (org.apache.pulsar.broker.authentication.AuthenticationService)52 BeforeMethod (org.testng.annotations.BeforeMethod)42 BeforeClass (org.testng.annotations.BeforeClass)38 PulsarResources (org.apache.pulsar.broker.resources.PulsarResources)26 WebSocketService (org.apache.pulsar.websocket.WebSocketService)21 WebSocketProxyConfiguration (org.apache.pulsar.websocket.service.WebSocketProxyConfiguration)18 ProxyServer (org.apache.pulsar.websocket.service.ProxyServer)15 NamespaceService (org.apache.pulsar.broker.namespace.NamespaceService)14 HashSet (java.util.HashSet)12 PulsarService (org.apache.pulsar.broker.PulsarService)12 ServiceConfiguration (org.apache.pulsar.broker.ServiceConfiguration)12 AuthenticationTls (org.apache.pulsar.client.impl.auth.AuthenticationTls)12 NioEventLoopGroup (io.netty.channel.nio.NioEventLoopGroup)9 ManagedLedgerFactory (org.apache.bookkeeper.mledger.ManagedLedgerFactory)9 MockedPulsarServiceBaseTest.createMockZooKeeper (org.apache.pulsar.broker.auth.MockedPulsarServiceBaseTest.createMockZooKeeper)9 NamespaceResources (org.apache.pulsar.broker.resources.NamespaceResources)9 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)9 MockZooKeeperSession (org.apache.zookeeper.MockZooKeeperSession)8 ZooKeeper (org.apache.zookeeper.ZooKeeper)8