Search in sources :

Example 16 with TestUser

use of harness.TestUser in project terra-cli by DataBiosphere.

the class BqTableReferenced method numRowsForReferencedWithNoAccess.

@Test
@DisplayName("referenced dataset with no access does not fail the describe command")
void numRowsForReferencedWithNoAccess() throws IOException {
    workspaceCreator.login();
    // `terra workspace set --id=$id`
    TestCommand.runCommandExpectSuccess("workspace", "set", "--id=" + getUserFacingId());
    // `terra resource add-ref bq-table --name=$name --project-id=$projectId
    // --dataset-id=$datasetId`
    String name = "numRowsForReferencedWithNoAccess";
    TestCommand.runCommandExpectSuccess("resource", "add-ref", "bq-table", "--name=" + name, "--project-id=" + externalDataset.getProjectId(), "--dataset-id=" + externalDataset.getDatasetId(), "--table-id=" + externalDataTableName);
    // `terra resource describe --name=$name`
    UFBqTable describeDataTable = TestCommand.runAndParseCommandExpectSuccess(UFBqTable.class, "resource", "describe", "--name=" + name);
    assertEquals(BigInteger.ZERO, describeDataTable.numRows, "referenced dataset with access and has zero row.");
    // `terra workspace add-user --email=$email --role=READER`
    TestUser shareeUser = TestUser.chooseTestUserWhoIsNot(workspaceCreator);
    TestCommand.runCommandExpectSuccess("workspace", "add-user", "--email=" + shareeUser.email, "--role=READER");
    shareeUser.login();
    // `terra resource describe --name=$name`
    UFBqTable shareeDescribeDataTable = TestCommand.runAndParseCommandExpectSuccess(UFBqTable.class, "resource", "describe", "--name=" + name);
    // the external dataset created in the beforeall method should have 1 table in it, but the
    // sharee user doesn't have read access to the table so they can't know that
    assertNull(shareeDescribeDataTable.numRows, "referenced dataset with no access contains NULL numRows");
}
Also used : UFBqTable(bio.terra.cli.serialization.userfacing.resource.UFBqTable) TestUser(harness.TestUser) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 17 with TestUser

use of harness.TestUser in project terra-cli by DataBiosphere.

the class Nextflow method nextflowFromGLSTutorial.

@Test
@DisplayName("nextflow config and run with GLS tutorial")
void nextflowFromGLSTutorial() throws IOException {
    // select a test user and login
    TestUser testUser = TestUser.chooseTestUserWithSpendAccess();
    testUser.login();
    // create a workspace
    int exitCode = TestBashScript.runScript("CreateWorkspace.sh");
    assertEquals(0, exitCode, "workspace created without errors");
    // run the script that downloads the NF workflow from GH and runs it
    exitCode = TestBashScript.runScript("NextflowRnaseq.sh");
    // check that the NF script ran successfully
    assertEquals(0, exitCode, "script completed without errors");
}
Also used : TestUser(harness.TestUser) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 18 with TestUser

use of harness.TestUser in project terra-cli by DataBiosphere.

the class AuthLoginLogout method checkEnabled.

@Test
@DisplayName("all test users enabled in SAM")
void checkEnabled() throws IOException {
    // check that each test user is enabled in SAM
    for (TestUser testUser : TestUser.getTestUsers()) {
        // login the user, so we have their credentials
        testUser.login();
        // check that the user is enabled
        UserStatusInfo userStatusInfo = SamService.fromContext().getUserInfoForSelf();
        assertTrue(userStatusInfo.getEnabled(), "test user is enabled in SAM");
        // `terra auth revoke`
        TestCommand.runCommandExpectSuccess("auth", "revoke");
    }
}
Also used : UserStatusInfo(org.broadinstitute.dsde.workbench.client.sam.model.UserStatusInfo) TestUser(harness.TestUser) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 19 with TestUser

use of harness.TestUser in project terra-cli by DataBiosphere.

the class AuthLoginLogout method logoutTestUser.

@Test
@DisplayName("test user logout updates global context")
void logoutTestUser() throws IOException {
    // select a test user and login
    TestUser testUser = TestUser.chooseTestUser();
    testUser.login();
    // `terra auth revoke`
    TestCommand.runCommandExpectSuccess("auth", "revoke");
    // check that the credential store on disk is empty
    DataStore<StoredCredential> dataStore = TestUser.getCredentialStore();
    assertEquals(0, dataStore.keySet().size(), "credential store is empty");
    // read the global context in from disk again to check what got persisted
    // check that the current user in the global context is unset
    Optional<User> currentUser = Context.getUser();
    assertFalse(currentUser.isPresent(), "current user unset in global context");
}
Also used : TestUser(harness.TestUser) User(bio.terra.cli.businessobject.User) StoredCredential(com.google.api.client.auth.oauth2.StoredCredential) TestUser(harness.TestUser) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 20 with TestUser

use of harness.TestUser in project terra-cli by DataBiosphere.

the class AuthStatus method authRevokeChanges.

@Test
@DisplayName("auth status changes after logout")
void authRevokeChanges() throws IOException {
    // select a test user and login
    TestUser testUser = TestUser.chooseTestUser();
    testUser.login();
    // `terra auth status --format=json`
    UFAuthStatus authStatus = TestCommand.runAndParseCommandExpectSuccess(UFAuthStatus.class, "auth", "status");
    // check that it says logged in
    assertTrue(authStatus.loggedIn, "auth status indicates user is logged in");
    // `terra auth revoke`
    TestCommand.runCommandExpectSuccess("auth", "revoke");
    // `terra auth status --format=json`
    authStatus = TestCommand.runAndParseCommandExpectSuccess(UFAuthStatus.class, "auth", "status");
    // check that it says logged out
    assertFalse(authStatus.loggedIn, "auth status indicates user is logged out");
}
Also used : TestUser(harness.TestUser) UFAuthStatus(bio.terra.cli.serialization.userfacing.UFAuthStatus) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

TestUser (harness.TestUser)30 Test (org.junit.jupiter.api.Test)28 DisplayName (org.junit.jupiter.api.DisplayName)27 UFWorkspace (bio.terra.cli.serialization.userfacing.UFWorkspace)7 UFGroup (bio.terra.cli.serialization.userfacing.UFGroup)5 UFStatus (bio.terra.cli.serialization.userfacing.UFStatus)5 TypeReference (com.fasterxml.jackson.core.type.TypeReference)5 TestCommand (harness.TestCommand)5 IOException (java.io.IOException)5 List (java.util.List)5 UFWorkspaceLight (bio.terra.cli.serialization.userfacing.UFWorkspaceLight)4 UFWorkspaceUser (bio.terra.cli.serialization.userfacing.UFWorkspaceUser)4 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)4 ClearContextUnit (harness.baseclasses.ClearContextUnit)4 Optional (java.util.Optional)4 Collectors (java.util.stream.Collectors)4 Matchers.containsString (org.hamcrest.Matchers.containsString)4 Matchers.emptyString (org.hamcrest.Matchers.emptyString)4 AfterAll (org.junit.jupiter.api.AfterAll)4 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)4