Search in sources :

Example 6 with LdapService

use of org.platformlayer.service.openldap.model.LdapService in project platformlayer by platformlayer.

the class ITGitService method testCreateAndDeleteItem.

@Test
public void testCreateAndDeleteItem() throws Exception {
    OpenLdapTestHelpers openLdap = new OpenLdapTestHelpers(getContext());
    LdapService ldapService = openLdap.createLdapServer();
    openFirewall(ldapService, LdapServiceController.PORT);
    String organizationName = "test.platformlayer.org";
    LdapDomain ldapDomain = openLdap.createLdapDomain(ldapService, organizationName);
    String id = "git" + random.randomAlphanumericString(8);
    GitService service = new GitService();
    service.dnsName = id + ".test.platformlayer.org";
    service.ldapGroup = "ou=Git Users,dc=test,dc=platformlayer,dc=org";
    service = putItem(id, service);
    service = waitForHealthy(service);
    InetSocketAddress socketAddress = getUniqueEndpoint(service);
    Assert.assertFalse(isPortOpen(socketAddress));
    openFirewall(service, GitServerController.PORT);
    Assert.assertTrue(isPortOpen(socketAddress));
    String repoId = "repo" + id;
    GitRepository repo = new GitRepository();
    repo.name = repoId;
    repo = putItem(repoId, repo);
    repo = waitForHealthy(repo);
    // TODO: Make endpoint http://<ip>:<port>/<path>...
    String url = "http://" + socketAddress.getAddress().getHostAddress() + ":" + socketAddress.getPort() + "/git/" + repoId;
    String username = null;
    String password = null;
    testGitRepo(url, username, password);
}
Also used : GitRepository(org.platformlayer.service.git.model.GitRepository) LdapDomain(org.platformlayer.service.openldap.model.LdapDomain) InetSocketAddress(java.net.InetSocketAddress) GitService(org.platformlayer.service.git.model.GitService) OpenLdapTestHelpers(org.platformlayer.service.openldap.tests.OpenLdapTestHelpers) LdapService(org.platformlayer.service.openldap.model.LdapService) Test(org.testng.annotations.Test) PlatformLayerApiTest(org.platformlayer.tests.PlatformLayerApiTest)

Example 7 with LdapService

use of org.platformlayer.service.openldap.model.LdapService in project platformlayer by platformlayer.

the class OpenLdapProvider method beforeCreateItem.

@Override
public void beforeCreateItem(ItemBase item) throws OpsException {
    super.beforeCreateItem(item);
    // TODO: This doesn't feel like the right place for this
    if (item instanceof LdapService) {
        LdapService ldapService = (LdapService) item;
        Passwords passwords = new Passwords();
        if (Secret.isNullOrEmpty(ldapService.ldapServerPassword)) {
            ldapService.ldapServerPassword = passwords.generateRandomPassword(12);
        }
    }
    if (item instanceof LdapDomain) {
        LdapDomain ldapService = (LdapDomain) item;
        Passwords passwords = new Passwords();
        if (Secret.isNullOrEmpty(ldapService.adminPassword)) {
            ldapService.adminPassword = passwords.generateRandomPassword(12);
        }
    }
}
Also used : LdapDomain(org.platformlayer.service.openldap.model.LdapDomain) Passwords(org.platformlayer.ops.crypto.Passwords) LdapService(org.platformlayer.service.openldap.model.LdapService)

Example 8 with LdapService

use of org.platformlayer.service.openldap.model.LdapService in project platformlayer by platformlayer.

the class ITOpenLdapService method testCreateAndDeleteItem.

@Test
public void testCreateAndDeleteItem() throws Exception {
    OpenLdapTestHelpers openLdap = new OpenLdapTestHelpers(getContext());
    LdapService ldapService = openLdap.createLdapServer();
    InetSocketAddress socketAddress = getUniqueEndpoint(ldapService);
    Assert.assertFalse(isPortOpen(socketAddress));
    openFirewall(ldapService, LdapServiceController.PORT);
    Assert.assertTrue(isPortOpen(socketAddress));
    String organizationName = "test.platformlayer.org";
    LdapDomain ldapDomain = openLdap.createLdapDomain(ldapService, organizationName);
    // TODO: Make endpoint ldap://<ip>:<port>/ ???
    String ldapUrl = "ldap://" + socketAddress.getAddress().getHostAddress() + ":" + socketAddress.getPort() + "/";
    testLdap(ldapUrl, ldapDomain.adminPassword);
}
Also used : InetSocketAddress(java.net.InetSocketAddress) LdapDomain(org.platformlayer.service.openldap.model.LdapDomain) OpenLdapTestHelpers(org.platformlayer.service.openldap.tests.OpenLdapTestHelpers) LdapService(org.platformlayer.service.openldap.model.LdapService) Test(org.testng.annotations.Test) PlatformLayerApiTest(org.platformlayer.tests.PlatformLayerApiTest)

Aggregations

LdapService (org.platformlayer.service.openldap.model.LdapService)8 LdapDomain (org.platformlayer.service.openldap.model.LdapDomain)4 InetSocketAddress (java.net.InetSocketAddress)2 LdapDN (org.platformlayer.ops.ldap.LdapDN)2 PublicEndpoint (org.platformlayer.ops.networks.PublicEndpoint)2 GitService (org.platformlayer.service.git.model.GitService)2 OpenLdapTestHelpers (org.platformlayer.service.openldap.tests.OpenLdapTestHelpers)2 PlatformLayerApiTest (org.platformlayer.tests.PlatformLayerApiTest)2 Test (org.testng.annotations.Test)2 EndpointInfo (org.platformlayer.core.model.EndpointInfo)1 Secret (org.platformlayer.core.model.Secret)1 OpsException (org.platformlayer.ops.OpsException)1 Passwords (org.platformlayer.ops.crypto.Passwords)1 InstanceBuilder (org.platformlayer.ops.instances.InstanceBuilder)1 GitRepository (org.platformlayer.service.git.model.GitRepository)1