Search in sources :

Example 1 with UserAccount

use of org.activityinfo.test.sut.UserAccount in project activityinfo by bedatadriven.

the class DataEntrySteps method field_has_downloadable_link.

@Then("^\"([^\"]*)\" field has downloadable link.$")
public void field_has_downloadable_link(String attachmentFieldName) throws Throwable {
    String blobLink = firstDownloadableLinkOfFirstSubmission(attachmentFieldName);
    UserAccount currentUser = driver.setup().getCurrentUser();
    Client client = new Client();
    client.addFilter(new HTTPBasicAuthFilter(currentUser.getEmail(), currentUser.getPassword()));
    client.setFollowRedirects(false);
    ClientResponse clientResponse = client.resource(blobLink).get(ClientResponse.class);
    assertEquals(Response.Status.OK.getStatusCode(), clientResponse.getStatus());
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) Client(com.sun.jersey.api.client.Client) UserAccount(org.activityinfo.test.sut.UserAccount) HTTPBasicAuthFilter(com.sun.jersey.api.client.filter.HTTPBasicAuthFilter) Then(cucumber.api.java.en.Then)

Example 2 with UserAccount

use of org.activityinfo.test.sut.UserAccount in project activityinfo by bedatadriven.

the class DatabaseSetupSteps method createDatabase.

@Given("I have created a database \"(.*)\" in (.+)")
public void createDatabase(String databaseName, String countryName) throws Exception {
    UserAccount account = accounts.any();
    driver.login(account);
    driver.setup().createDatabase(name(databaseName), property("country", countryName));
    this.currentDatabase = databaseName;
}
Also used : UserAccount(org.activityinfo.test.sut.UserAccount) Given(cucumber.api.java.en.Given)

Example 3 with UserAccount

use of org.activityinfo.test.sut.UserAccount in project activityinfo by bedatadriven.

the class SignUpSteps method I_try_to_choose_the_password.

@And("^I choose the password \"([^\"]*)\"$")
public void I_try_to_choose_the_password(String password) throws Throwable {
    applicationPage = confirmPage.confirmPassword(password);
    newUserAccount = new UserAccount(newUserAccount.getEmail(), password);
}
Also used : UserAccount(org.activityinfo.test.sut.UserAccount) And(cucumber.api.java.en.And)

Example 4 with UserAccount

use of org.activityinfo.test.sut.UserAccount in project activityinfo by bedatadriven.

the class UiApplicationDriver method addUserToDatabase.

public void addUserToDatabase(String userEmail, String databaseName, String partner, List<FieldValue> permissions) {
    UserAccount account = accounts.ensureAccountExists(userEmail);
    ensureLoggedIn();
    UsersPage usersPage = applicationPage.navigateToDesignTab().selectDatabase(getAliasTable().getAlias(databaseName)).users();
    GxtModal modal = usersPage.addUser();
    modal.form().fillTextField("Name", account.getEmail());
    modal.form().fillTextField("Email", account.getEmail());
    modal.form().select("Partner", getAliasTable().getAlias(partner));
    modal.accept();
    Sleep.sleepSeconds(1);
    usersPage.setPermission(account.getEmail(), permissions);
}
Also used : GxtModal(org.activityinfo.test.pageobject.gxt.GxtModal) UserAccount(org.activityinfo.test.sut.UserAccount)

Example 5 with UserAccount

use of org.activityinfo.test.sut.UserAccount in project activityinfo by bedatadriven.

the class ApiApplicationDriver method grantPermission.

@Override
public void grantPermission(TestObject properties) throws Exception {
    UserAccount email = accounts.ensureAccountExists(properties.getString("user"));
    JSONObject model = new JSONObject();
    model.put("name", "A User");
    model.put("email", email.getEmail());
    model.put("partnerId", aliases.getId(properties.getString("partner")));
    for (String permission : properties.getStringList("permissions")) {
        switch(permission) {
            case "View":
                model.put("allowView", true);
                break;
            case "View All":
                model.put("allowViewAll", true);
                break;
            case "Edit":
                model.put("allowEdit", true);
                break;
            case "Edit All":
                model.put("allowEditAll", true);
                break;
            case "Manage Users":
                model.put("allowManageUsers", true);
                break;
            case "Manage All Users":
                model.put("allowManageAllUsers", true);
                break;
            case "Design":
                model.put("allowDesign", true);
                break;
        }
    }
    JSONObject command = new JSONObject();
    command.put("databaseId", aliases.getId(properties.getString("database")));
    command.put("model", model);
    LOGGER.fine(format("Granting access to database '%s' [%d] to %s [%s] within %s [%d]", properties.getString("database"), command.getInt("databaseId"), properties.getString("user"), email.getEmail(), properties.getString("partner"), model.getInt("partnerId")));
    executeCommand("UpdateUserPermissions", command);
}
Also used : JSONObject(org.json.JSONObject) UserAccount(org.activityinfo.test.sut.UserAccount)

Aggregations

UserAccount (org.activityinfo.test.sut.UserAccount)10 Client (com.sun.jersey.api.client.Client)2 ClientResponse (com.sun.jersey.api.client.ClientResponse)2 HTTPBasicAuthFilter (com.sun.jersey.api.client.filter.HTTPBasicAuthFilter)2 Given (cucumber.api.java.en.Given)2 Then (cucumber.api.java.en.Then)2 When (cucumber.api.java.en.When)2 And (cucumber.api.java.en.And)1 ScenarioContext (org.activityinfo.test.capacity.model.ScenarioContext)1 UserRole (org.activityinfo.test.capacity.model.UserRole)1 GxtModal (org.activityinfo.test.pageobject.gxt.GxtModal)1 DevServerAccounts (org.activityinfo.test.sut.DevServerAccounts)1 JSONObject (org.json.JSONObject)1