Package org.platformlayer.service.openldap.tests

Source Code of org.platformlayer.service.openldap.tests.OpenLdapTestHelpers

package org.platformlayer.service.openldap.tests;

import java.io.IOException;

import org.platformlayer.core.model.Secret;
import org.platformlayer.ops.OpsException;
import org.platformlayer.service.openldap.model.LdapDomain;
import org.platformlayer.service.openldap.model.LdapService;
import org.platformlayer.tests.PlatformLayerTestContext;
import org.platformlayer.tests.TestHelper;

public class OpenLdapTestHelpers extends TestHelper {

  public OpenLdapTestHelpers(PlatformLayerTestContext context) {
    super(context);
  }

  public LdapService createLdapServer() throws OpsException, IOException {
    String id = random.randomAlphanumericString(8);
    Secret ldapServerPassword = randomSecret();

    LdapService service = new LdapService();
    service.dnsName = id + ".test.platformlayer.org";
    service.ldapServerPassword = ldapServerPassword;

    service = context.putItem(id, service);
    service = context.waitForHealthy(service);

    return service;
  }

  public LdapDomain createLdapDomain(LdapService ldapService, String organizationName) throws OpsException,
      IOException {
    String domainId = "domain-" + ldapService.getId();
    Secret adminPassword = randomSecret();
    LdapDomain domain = new LdapDomain();
    domain.organizationName = organizationName;
    domain.adminPassword = adminPassword;
    domain = context.putItem(domainId, domain);
    domain = context.waitForHealthy(domain);

    return domain;
  }

}
TOP

Related Classes of org.platformlayer.service.openldap.tests.OpenLdapTestHelpers

TOP
Copyright © 2018 www.massapi.com. 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.