Search in sources :

Example 6 with Account

use of io.syndesis.qe.accounts.Account in project syndesis-qe by syndesisio.

the class CommonSteps method validateCredentials.

@And("^.*validate credentials$")
public void validateCredentials() {
    Map<String, Account> accounts = AccountsDirectory.getInstance().getAccounts();
    List<List<String>> oneAccountList = new ArrayList<>();
    List<String> tmpList = Arrays.asList("a", "s", "d", "f");
    accounts.keySet().forEach(key -> {
        Optional<Account> currentAccount = AccountsDirectory.getInstance().getAccount(key);
        if (currentAccount.isPresent()) {
            String service = currentAccount.get().getService();
            Credentials current = Credentials.valueOf(service.toUpperCase());
            switch(current) {
                case DROPBOX:
                    service = "DropBox";
                    break;
                case SALESFORCE:
                    service = "Salesforce";
                    break;
                case TWITTER:
                    service = "Twitter";
                    break;
                case S3:
                    // TODO: skip for now
                    return;
                default:
                    // skip for other cred
                    return;
            }
            // type
            tmpList.set(0, service);
            // name
            tmpList.set(1, key);
            // connection name
            tmpList.set(2, "my " + key + " connection");
            // description
            tmpList.set(3, "some description");
            log.trace("Inserting: " + tmpList.toString());
            oneAccountList.add(new ArrayList<>(tmpList));
            log.trace("Current values in list list: " + oneAccountList.toString());
        }
    });
    log.debug("Final status of list: " + oneAccountList.toString());
    DataTable accountsTalbe = DataTable.create(oneAccountList);
    createConnections(accountsTalbe);
}
Also used : Account(io.syndesis.qe.accounts.Account) DataTable(cucumber.api.DataTable) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) And(cucumber.api.java.en.And)

Example 7 with Account

use of io.syndesis.qe.accounts.Account in project syndesis-qe by syndesisio.

the class ConnectionsGeneralSteps method createS3Connection.

@Given("^create S3 connection using \"([^\"]*)\" bucket")
public void createS3Connection(String s3Bucket) {
    final Connector s3Connector = connectorsEndpoint.get("aws-s3");
    final Account s3Account = accountsDirectory.getAccount("s3").get();
    log.info("Bucket name:  {}", S3BucketNameBuilder.getBucketName(s3Bucket));
    final Connection s3Connection = new Connection.Builder().connector(s3Connector).connectorId(getConnectorId(s3Connector)).id(S3BucketNameBuilder.getBucketName(s3Bucket)).name("New Fuse QE s3 " + S3BucketNameBuilder.getBucketName(s3Bucket)).icon("fa-puzzle-piece").configuredProperties(TestUtils.map("accessKey", s3Account.getProperty("accessKey"), "bucketNameOrArn", S3BucketNameBuilder.getBucketName(s3Bucket), "region", s3Account.getProperty("region"), "secretKey", s3Account.getProperty("secretKey"))).tags(Arrays.asList("aws-s3")).build();
    log.info("Creating s3 connection {}", s3Connection.getName());
    connectionsEndpoint.create(s3Connection);
}
Also used : Connector(io.syndesis.common.model.connection.Connector) Account(io.syndesis.qe.accounts.Account) S3BucketNameBuilder(io.syndesis.qe.utils.S3BucketNameBuilder) Connection(io.syndesis.common.model.connection.Connection) Given(cucumber.api.java.en.Given)

Example 8 with Account

use of io.syndesis.qe.accounts.Account in project syndesis-qe by syndesisio.

the class FtpTemplate method deploy.

public static void deploy() {
    List<ContainerPort> ports = new LinkedList<>();
    ports.add(new ContainerPortBuilder().withName("ftp-cmd").withContainerPort(2121).withProtocol("TCP").build());
    for (int i = 0; i < 10; i++) {
        ContainerPort dataPort = new ContainerPortBuilder().withName("ftp-data-" + i).withContainerPort(2300 + i).withProtocol("TCP").build();
        ports.add(dataPort);
    }
    OpenShiftUtils.client().deploymentConfigs().createOrReplaceWithNew().editOrNewMetadata().withName(APP_NAME).addToLabels(LABEL_NAME, APP_NAME).endMetadata().editOrNewSpec().addToSelector(LABEL_NAME, APP_NAME).withReplicas(1).editOrNewTemplate().editOrNewMetadata().addToLabels(LABEL_NAME, APP_NAME).endMetadata().editOrNewSpec().addNewContainer().withName(APP_NAME).withImage("dsimansk/ftpd:latest").addAllToPorts(ports).endContainer().endSpec().endTemplate().addNewTrigger().withType("ConfigChange").endTrigger().endSpec().done();
    ServiceSpecBuilder serviceSpecBuilder = new ServiceSpecBuilder().addToSelector(LABEL_NAME, APP_NAME);
    serviceSpecBuilder.addToPorts(new ServicePortBuilder().withName("ftp-cmd").withPort(2121).withTargetPort(new IntOrString(2121)).build());
    for (int i = 0; i < 10; i++) {
        serviceSpecBuilder.addToPorts(new ServicePortBuilder().withName("ftp-data-" + i).withPort(2300 + i).withTargetPort(new IntOrString(2300 + i)).build());
    }
    OpenShiftUtils.getInstance().client().services().createOrReplaceWithNew().editOrNewMetadata().withName(APP_NAME).addToLabels(LABEL_NAME, APP_NAME).endMetadata().editOrNewSpecLike(serviceSpecBuilder.build()).endSpec().done();
    try {
        OpenShiftWaitUtils.waitFor(OpenShiftWaitUtils.areExactlyNPodsReady(LABEL_NAME, APP_NAME, 1));
        Thread.sleep(20 * 1000);
    } catch (InterruptedException | TimeoutException e) {
        log.error("Wait for {} deployment failed ", APP_NAME, e);
    }
    Account ftpAccount = new Account();
    ftpAccount.setService("ftp");
    Map<String, String> accountParameters = new HashMap<>();
    accountParameters.put("host", "ftpd");
    accountParameters.put("port", "2121");
    ftpAccount.setProperties(accountParameters);
    AccountsDirectory.getInstance().addAccount("FTP", ftpAccount);
}
Also used : Account(io.syndesis.qe.accounts.Account) HashMap(java.util.HashMap) IntOrString(io.fabric8.kubernetes.api.model.IntOrString) IntOrString(io.fabric8.kubernetes.api.model.IntOrString) LinkedList(java.util.LinkedList) ServiceSpecBuilder(io.fabric8.kubernetes.api.model.ServiceSpecBuilder) ServicePortBuilder(io.fabric8.kubernetes.api.model.ServicePortBuilder) ContainerPortBuilder(io.fabric8.kubernetes.api.model.ContainerPortBuilder) ContainerPort(io.fabric8.kubernetes.api.model.ContainerPort) TimeoutException(java.util.concurrent.TimeoutException)

Aggregations

Account (io.syndesis.qe.accounts.Account)8 Given (cucumber.api.java.en.Given)4 Connection (io.syndesis.common.model.connection.Connection)4 Connector (io.syndesis.common.model.connection.Connector)4 S3BucketNameBuilder (io.syndesis.qe.utils.S3BucketNameBuilder)4 HashMap (java.util.HashMap)2 DbxRequestConfig (com.dropbox.core.DbxRequestConfig)1 DbxClientV2 (com.dropbox.core.v2.DbxClientV2)1 DataTable (cucumber.api.DataTable)1 And (cucumber.api.java.en.And)1 ContainerPort (io.fabric8.kubernetes.api.model.ContainerPort)1 ContainerPortBuilder (io.fabric8.kubernetes.api.model.ContainerPortBuilder)1 IntOrString (io.fabric8.kubernetes.api.model.IntOrString)1 ServicePortBuilder (io.fabric8.kubernetes.api.model.ServicePortBuilder)1 ServiceSpecBuilder (io.fabric8.kubernetes.api.model.ServiceSpecBuilder)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 TimeoutException (java.util.concurrent.TimeoutException)1