Search in sources :

Example 21 with Account

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

the class CommonSteps method fillFormByTestIdFromCreds.

@Then("^fill in data-testid field \"([^\"]*)\" from property \"([^\"]*)\" of credentials \"([^\"]*)\"")
public void fillFormByTestIdFromCreds(String testId, String property, String credentials) {
    Account account = AccountsDirectory.getInstance().get(credentials);
    Map<String, String> map = new HashMap<>();
    map.put(testId, account.getProperty(property));
    new Form(new SyndesisRootPage().getRootElement()).fillByTestId(map);
}
Also used : GoogleAccount(io.syndesis.qe.utils.google.GoogleAccount) Account(io.syndesis.qe.account.Account) SyndesisRootPage(io.syndesis.qe.pages.SyndesisRootPage) HashMap(java.util.HashMap) Form(io.syndesis.qe.fragments.common.form.Form) Then(io.cucumber.java.en.Then)

Example 22 with Account

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

the class CommonSteps method validateCredentials.

@Then("^.*validate credentials$")
public void validateCredentials() {
    Map<String, Account> accounts = AccountsDirectory.getInstance().getAccounts();
    List<List<String>> allAccountsWithDetailsList = new ArrayList<>();
    accounts.keySet().forEach(key -> {
        List<String> accountWithDetailsInList = new ArrayList<>();
        Account currentAccount;
        try {
            currentAccount = AccountsDirectory.getInstance().get(key);
        } catch (IllegalStateException e) {
            return;
        }
        String service = currentAccount.getService();
        Credentials current;
        try {
            current = Credentials.valueOf(service.toUpperCase().replace(" ", "_").replace("-", "_").replaceAll("[()]", ""));
        } catch (IllegalArgumentException ex) {
            throw new IllegalArgumentException("Unable to find enum value for " + service + " account." + " New account should be included in smoke tests");
        }
        switch(current) {
            case DROPBOX:
                service = "DropBox";
                break;
            case SLACK:
                service = "Slack";
                break;
            case TELEGRAM:
                service = "Telegram";
                break;
            case SERVICENOW:
                service = "ServiceNow";
                break;
            case BOX:
                service = "Box";
                break;
            case SEND_EMAIL_SMTP:
                service = "Send Email (smtp)";
                break;
            case RECEIVE_EMAIL_IMAP_OR_POP3:
                service = "Receive Email (imap or pop3)";
                break;
            default:
                log.info("Credentials for " + current + " are either tested via OAuth or do not use 3rd party application. Skipping");
                return;
        }
        // type
        accountWithDetailsInList.add(service);
        // name
        accountWithDetailsInList.add(key);
        // connection name
        accountWithDetailsInList.add("my " + key + " connection");
        // description
        accountWithDetailsInList.add("some description");
        log.trace("Inserting: " + accountWithDetailsInList.toString());
        allAccountsWithDetailsList.add(new ArrayList<>(accountWithDetailsInList));
        log.trace("Current values in list list: " + allAccountsWithDetailsList.toString());
    });
    log.debug("Final status of list: " + allAccountsWithDetailsList.toString());
    DataTable accountsTalbe = DataTable.create(allAccountsWithDetailsList);
    createConnections(accountsTalbe);
}
Also used : GoogleAccount(io.syndesis.qe.utils.google.GoogleAccount) Account(io.syndesis.qe.account.Account) DataTable(io.cucumber.datatable.DataTable) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) Then(io.cucumber.java.en.Then)

Example 23 with Account

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

the class CommonSteps method loginToGoogleIfNeeded.

private void loginToGoogleIfNeeded(String s) {
    // if the browser has previously logged into google account syndesis will
    // immediately move to next screen and will have "Successfully%20authorized%20Syndesis's%20access" in the URL
    log.info("Current url: {}", WebDriverRunner.getWebDriver().getCurrentUrl().toLowerCase());
    if (isStringInUrl("Successfully%20authorized%20Syndesis's%20access", 5) || $(Alert.SUCCESS.getBy()).is(visible)) {
        log.info("User is already logged");
        return;
    }
    waitForCallbackRedirect("google");
    Account account = AccountsDirectory.getInstance().get(s);
    // change language if needs
    if ($(ByUtils.customAttribute("data-value", "en")).has(Condition.attribute("tabindex", "-1"))) {
        $(By.id("lang-chooser")).click();
        TestUtils.sleepIgnoreInterrupt(2000);
        $(By.id("lang-chooser")).$$(ByUtils.customAttribute("data-value", "en")).filter(Condition.visible).get(0).click();
        TestUtils.sleepIgnoreInterrupt(2000);
    }
    // test if multi accounts table is shown ( https://accounts.google.com/accountchooser )
    SelenideElement loginView = $(By.id("initialView"));
    if (loginView.text().contains("Choose an account")) {
        log.info("More Google accounts are available. Choosing the correct one:" + account.getProperty("email"));
        try {
            loginView.$(ByUtils.customAttribute("data-email", account.getProperty("email"))).should(Condition.exist).click();
        } catch (ElementNotFound ex) {
            log.warn("That account is not in the Google multi-accounts table. It needs to fill in the credentials.");
            // use another account button
            loginView.$$(ByUtils.hasEqualText("div", "Use another account")).filter(visible).last().click();
            fillAndValidateGoogleAccount(account);
        }
    } else {
        fillAndValidateGoogleAccount(account);
    }
    TestUtils.sleepIgnoreInterrupt(5000L);
}
Also used : GoogleAccount(io.syndesis.qe.utils.google.GoogleAccount) Account(io.syndesis.qe.account.Account) SelenideElement(com.codeborne.selenide.SelenideElement) ElementNotFound(com.codeborne.selenide.ex.ElementNotFound)

Example 24 with Account

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

the class TodoSteps method setCredentials.

@Given("^Set Todo app credentials$")
public void setCredentials() {
    Account todoAppAccount = new Account();
    todoAppAccount.setService("todo");
    Map<String, String> accountParameters = new HashMap<>();
    accountParameters.put("username", "test");
    accountParameters.put("password", "test");
    todoAppAccount.setProperties(accountParameters);
    AccountsDirectory.getInstance().addAccount("todo", todoAppAccount);
}
Also used : Account(io.syndesis.qe.account.Account) HashMap(java.util.HashMap) Given(io.cucumber.java.en.Given)

Example 25 with Account

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

the class ApiClientConnectorsSteps method setPetstoreCredentials.

@When("^set swagger petstore credentials")
public void setPetstoreCredentials() {
    Account petStoreAccount = new Account();
    petStoreAccount.setService("Swagger Petstore");
    Map<String, String> accountParameters = new HashMap<>();
    accountParameters.put("authenticationparametervalue", "special-key");
    petStoreAccount.setProperties(accountParameters);
    AccountsDirectory.getInstance().addAccount("Swagger Petstore Account", petStoreAccount);
}
Also used : Account(io.syndesis.qe.account.Account) HashMap(java.util.HashMap) When(io.cucumber.java.en.When)

Aggregations

Account (io.syndesis.qe.account.Account)51 HashMap (java.util.HashMap)21 GoogleAccount (io.syndesis.qe.utils.google.GoogleAccount)10 IntOrString (io.fabric8.kubernetes.api.model.IntOrString)9 Then (io.cucumber.java.en.Then)6 When (io.cucumber.java.en.When)6 Given (io.cucumber.java.en.Given)5 ArrayList (java.util.ArrayList)5 TimeoutException (java.util.concurrent.TimeoutException)5 List (java.util.List)4 ElementsCollection (com.codeborne.selenide.ElementsCollection)3 Form (io.syndesis.qe.fragments.common.form.Form)3 AsynchronousJiraRestClientFactory (com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory)2 SelenideElement (com.codeborne.selenide.SelenideElement)2 ElementNotFound (com.codeborne.selenide.ex.ElementNotFound)2 DataTable (io.cucumber.datatable.DataTable)2 ContainerPort (io.fabric8.kubernetes.api.model.ContainerPort)2 ContainerPortBuilder (io.fabric8.kubernetes.api.model.ContainerPortBuilder)2 EnvVar (io.fabric8.kubernetes.api.model.EnvVar)2 ServicePortBuilder (io.fabric8.kubernetes.api.model.ServicePortBuilder)2