diff --git a/.circleci/config.yml b/.circleci/config.yml index eaa266188..5e67381f0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -52,7 +52,7 @@ common_jobs: &common_jobs - integration-tests: matrix: parameters: - testing_profile: [ "singularity-tests", "bitbucket-tests", "toil-integration-tests" ] + testing_profile: [ "singularity-tests", "toil-integration-tests" ] <<: *common_filters <<: *slack_context requires: diff --git a/dockstore-cli-integration-testing/src/test/java/io/dockstore/client/cli/BitBucketBasicIT.java b/dockstore-cli-integration-testing/src/test/java/io/dockstore/client/cli/BitBucketBasicIT.java deleted file mode 100644 index 3938a8410..000000000 --- a/dockstore-cli-integration-testing/src/test/java/io/dockstore/client/cli/BitBucketBasicIT.java +++ /dev/null @@ -1,302 +0,0 @@ -package io.dockstore.client.cli; - -import static io.dockstore.client.cli.Client.CONFIG; -import static io.dockstore.client.cli.Client.SCRIPT_FLAG; -import static io.dockstore.client.cli.Client.TOOL; -import static io.dockstore.client.cli.nested.AbstractEntryClient.MANUAL_PUBLISH; -import static io.dockstore.client.cli.nested.AbstractEntryClient.PUBLISH; -import static io.dockstore.client.cli.nested.AbstractEntryClient.REFRESH; -import static io.dockstore.client.cli.nested.WesCommandParser.ENTRY; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static uk.org.webcompere.systemstubs.SystemStubs.catchSystemExit; - -import io.dockstore.common.BitBucketTest; -import io.dockstore.common.CLICommonTestUtilities; -import io.dockstore.common.CommonTestUtilities; -import io.dockstore.common.ConfidentialTest; -import io.dockstore.common.Registry; -import io.dockstore.webservice.DockstoreWebserviceApplication; -import io.dropwizard.testing.ResourceHelpers; -import org.hibernate.Session; -import org.hibernate.context.internal.ManagedSessionContext; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Tag; -import org.junit.jupiter.api.Test; -import uk.org.webcompere.systemstubs.jupiter.SystemStub; -import uk.org.webcompere.systemstubs.stream.SystemErr; -import uk.org.webcompere.systemstubs.stream.SystemOut; - -@Tag(ConfidentialTest.NAME) -@Tag(BitBucketTest.NAME) -class BitBucketBasicIT extends BaseIT { - - @SystemStub - public final SystemOut systemOutRule = new SystemOut(); - - @SystemStub - public final SystemErr systemErrRule = new SystemErr(); - - @BeforeEach - @Override - public void resetDBBetweenTests() throws Exception { - CLICommonTestUtilities.cleanStatePrivate1(SUPPORT, testingPostgres, true); - } - - @AfterEach - public void preserveBitBucketTokens() { - // used to allow us to use cacheBitbucketTokens outside of the web service - DockstoreWebserviceApplication application = SUPPORT.getApplication(); - Session session = application.getHibernate().getSessionFactory().openSession(); - ManagedSessionContext.bind(session); - CommonTestUtilities.cacheBitbucketTokens(SUPPORT); - } - - /** - * Checks that you can properly publish and unpublish a Quay/Bitbucket entry - */ - @Test - void testQuayAndBitbucketPublishAndUnpublishAentry() { - // Publish - Client.main(new String[] { CONFIG, ResourceHelpers.resourceFilePath("config_file.txt"), TOOL, PUBLISH, ENTRY, - "quay.io/dockstoretestuser/quayandbitbucket", SCRIPT_FLAG }); - - final long count = testingPostgres - .runSelectStatement("select count(*) from tool where name = 'quayandbitbucket' and ispublished='t'", long.class); - assertEquals(1, count, "there should be 1 registered"); - - // Unpublish - Client.main(new String[] { CONFIG, ResourceHelpers.resourceFilePath("config_file.txt"), TOOL, PUBLISH, "--unpub", ENTRY, - "quay.io/dockstoretestuser/quayandbitbucket", SCRIPT_FLAG }); - - final long count2 = testingPostgres - .runSelectStatement("select count(*) from tool where name = 'quayandbitbucket' and ispublished='t'", long.class); - assertEquals(0, count2, "there should be 0 registered"); - } - - /** - * This tests that you can refresh user data by refreshing a tool - * ONLY WORKS if the current user in the database dump has no metadata, and on Github there is metadata (bio, location) - * If the user has metadata, test will pass as long as the user's metadata isn't the same as Github already - */ - @Test - void testRefreshingUserMetadata() { - // Setup database - - // Refresh a tool - Client.main(new String[] { CONFIG, ResourceHelpers.resourceFilePath("config_file.txt"), TOOL, REFRESH, ENTRY, - "quay.io/dockstoretestuser/quayandbitbucket", SCRIPT_FLAG }); - - // Check that user has been updated - // TODO: bizarrely, the new GitHub Java API library doesn't seem to handle bio - //final long count = testingPostgres.runSelectStatement("select count(*) from enduser where location='Toronto' and bio='I am a test user'", long.class); - final long count = testingPostgres.runSelectStatement("select count(*) from user_profile where location='Toronto'", long.class); - assertEquals(1, count, "One user should have this info now, there are " + count); - } - - /** - * Check that refreshing an existing tool will not throw an error - * Todo: Update test to check the outcome of a refresh - */ - @Test - void testRefreshCorrectTool() { - Client.main(new String[] { CONFIG, ResourceHelpers.resourceFilePath("config_file.txt"), TOOL, REFRESH, ENTRY, - "quay.io/dockstoretestuser/quayandbitbucket", SCRIPT_FLAG }); - Client.main(new String[] { CONFIG, ResourceHelpers.resourceFilePath("config_file.txt"), TOOL, MANUAL_PUBLISH, "--registry", - Registry.DOCKER_HUB.name(), Registry.DOCKER_HUB.toString(), "--namespace", "dockstoretestuser", "--name", - "dockerhubandbitbucket", "--git-url", "git@bitbucket.org:dockstoretestuser/dockstore-whalesay.git", "--git-reference", "master", - "--toolname", "regular", SCRIPT_FLAG }); - Client.main(new String[] { CONFIG, ResourceHelpers.resourceFilePath("config_file.txt"), TOOL, REFRESH, ENTRY, - "registry.hub.docker.com/dockstoretestuser/dockerhubandbitbucket/regular", SCRIPT_FLAG }); - Client.main(new String[] { CONFIG, ResourceHelpers.resourceFilePath("config_file.txt"), TOOL, MANUAL_PUBLISH, "--registry", - Registry.DOCKER_HUB.name(), Registry.DOCKER_HUB.toString(), "--namespace", "dockstoretestuser", "--name", "dockerhubandgithub", - "--git-url", "git@github.com:dockstoretestuser/dockstore-whalesay.git", "--git-reference", "master", "--toolname", "regular", - SCRIPT_FLAG }); - Client.main(new String[] { CONFIG, ResourceHelpers.resourceFilePath("config_file.txt"), TOOL, REFRESH, ENTRY, - "registry.hub.docker.com/dockstoretestuser/dockerhubandgithub/regular", SCRIPT_FLAG }); - } - - /** - * Ensures that one cannot register an existing Quay/Bitbucket entry if you don't give it an alternate toolname - */ - @Test - void testQuayBitbucketManuallyRegisterDuplicate() throws Exception { - int exitCode = catchSystemExit(() -> Client.main( - new String[] { CONFIG, ResourceHelpers.resourceFilePath("config_file.txt"), TOOL, MANUAL_PUBLISH, "--registry", - Registry.QUAY_IO.name(), Registry.QUAY_IO.toString(), "--namespace", "dockstoretestuser", "--name", - "quayandbitbucket", "--git-url", "git@bitbucket.org:DockstoreTestUser/dockstore-whalesay.git", "--git-reference", - "master", SCRIPT_FLAG })); - assertEquals(Client.API_ERROR, exitCode); - } - - /** - * Ensures that you can't publish an automatically added Quay/Bitbucket entry with an alternate structure unless you change the Dockerfile and Dockstore.cwl locations - */ - @Test - void testQuayBitbucketPublishAlternateStructure() throws Exception { - int exitCode = catchSystemExit(() -> Client.main( - new String[] { CONFIG, ResourceHelpers.resourceFilePath("config_file.txt"), TOOL, PUBLISH, ENTRY, - "quay.io/dockstoretestuser/quayandbitbucketalternate", SCRIPT_FLAG })); - assertEquals(Client.API_ERROR, exitCode); - // TODO: change the tag tag locations of Dockerfile and Dockstore.cwl, now should be able to publish - } - - /** - * Checks that you can manually publish and unpublish a Quay/Bitbucket entry with an alternate structure, if the CWL and Dockerfile paths are defined properly - */ - @Test - void testQuayBitbucketManualPublishAndUnpublishAlternateStructure() { - // Manual Publish - Client.main(new String[] { CONFIG, ResourceHelpers.resourceFilePath("config_file.txt"), TOOL, MANUAL_PUBLISH, "--registry", - Registry.QUAY_IO.name(), Registry.QUAY_IO.toString(), "--namespace", "dockstoretestuser", "--name", "quayandbitbucketalternate", - "--git-url", "git@bitbucket.org:DockstoreTestUser/quayandbitbucketalternate.git", "--git-reference", "master", "--toolname", - "alternate", "--cwl-path", "/testDir/Dockstore.cwl", "--dockerfile-path", "/testDir/Dockerfile", SCRIPT_FLAG }); - - final long count = testingPostgres - .runSelectStatement("select count(*) from tool where toolname = 'alternate' and ispublished='t'", long.class); - - assertEquals(1, count, "there should be 1 entries, there are " + count); - - // Unpublish - Client.main(new String[] { CONFIG, ResourceHelpers.resourceFilePath("config_file.txt"), TOOL, PUBLISH, "--unpub", ENTRY, - "quay.io/dockstoretestuser/quayandbitbucketalternate/alternate", SCRIPT_FLAG }); - final long count2 = testingPostgres - .runSelectStatement("select count(*) from tool where toolname = 'alternate' and ispublished='t'", long.class); - - assertEquals(0, count2, "there should be 0 entries, there are " + count2); - - } - - /** - * Will test manually publishing and unpublishing a Dockerhub/Bitbucket entry with an alternate structure - */ - @Test - void testDockerhubBitbucketAlternateStructure() { - Client.main(new String[] { CONFIG, ResourceHelpers.resourceFilePath("config_file.txt"), TOOL, MANUAL_PUBLISH, "--registry", - Registry.DOCKER_HUB.name(), Registry.DOCKER_HUB.toString(), "--namespace", "dockstoretestuser", "--name", - "dockerhubandbitbucket", "--git-url", "git@bitbucket.org:DockstoreTestUser/quayandbitbucketalternate.git", "--git-reference", - "master", "--toolname", "alternate", "--cwl-path", "/testDir/Dockstore.cwl", "--dockerfile-path", "/testDir/Dockerfile", - SCRIPT_FLAG }); - - final long count = testingPostgres - .runSelectStatement("select count(*) from tool where toolname = 'alternate' and ispublished='t'", long.class); - assertEquals(1, count, "there should be 1 entry"); - - // Unpublish - Client.main(new String[] { CONFIG, ResourceHelpers.resourceFilePath("config_file.txt"), TOOL, PUBLISH, "--unpub", ENTRY, - "registry.hub.docker.com/dockstoretestuser/dockerhubandbitbucket/alternate", SCRIPT_FLAG }); - - final long count3 = testingPostgres - .runSelectStatement("select count(*) from tool where toolname = 'alternate' and ispublished='f'", long.class); - assertEquals(1, count3, "there should be 1 entry"); - - } - - - /** - * Will test attempting to manually publish a Dockerhub/Bitbucket entry using incorrect CWL and/or dockerfile locations - */ - @Disabled("probably broken with changes to manual publish") - @Test - void testDockerhubBitbucketWrongStructure() throws Exception { - // Todo : Manual publish entry with wrong cwl and dockerfile locations, should not be able to manual publish - int exitCode = catchSystemExit(() -> Client.main( - new String[] { CONFIG, ResourceHelpers.resourceFilePath("config_file.txt"), TOOL, MANUAL_PUBLISH, "--registry", - Registry.DOCKER_HUB.name(), Registry.DOCKER_HUB.toString(), "--namespace", "dockstoretestuser", "--name", - "dockerhubandbitbucketalternate", "--git-url", "git@bitbucket.org:DockstoreTestUser/quayandbitbucketalterante.git", - "--git-reference", "master", "--toolname", "alternate", "--cwl-path", "/Dockstore.cwl", "--dockerfile-path", - "/Dockerfile", SCRIPT_FLAG })); - assertEquals(Client.GENERIC_ERROR, exitCode); - } - - - /** - * Checks that you can manually publish and unpublish a Dockerhub/Bitbucket duplicate if different toolnames are set (but same Path) - */ - @Test - void testDockerhubBitbucketManualRegistrationDuplicates() { - Client.main(new String[] { CONFIG, ResourceHelpers.resourceFilePath("config_file.txt"), TOOL, MANUAL_PUBLISH, "--registry", - Registry.DOCKER_HUB.name(), Registry.DOCKER_HUB.toString(), "--namespace", "dockstoretestuser", "--name", - "dockerhubandbitbucket", "--git-url", "git@bitbucket.org:DockstoreTestUser/dockstore-whalesay.git", "--git-reference", "master", - "--toolname", "regular", SCRIPT_FLAG }); - - final long count = testingPostgres - .runSelectStatement("select count(*) from tool where toolname = 'regular' and ispublished='t'", long.class); - - assertEquals(1, count, "there should be 1 entry"); - - // Add duplicate entry with different toolname - Client.main(new String[] { CONFIG, ResourceHelpers.resourceFilePath("config_file.txt"), TOOL, MANUAL_PUBLISH, "--registry", - Registry.DOCKER_HUB.name(), Registry.DOCKER_HUB.toString(), "--namespace", "dockstoretestuser", "--name", - "dockerhubandbitbucket", "--git-url", "git@bitbucket.org:DockstoreTestUser/dockstore-whalesay.git", "--git-reference", "master", - "--toolname", "regular2", SCRIPT_FLAG }); - - // Unpublish the duplicate entrys - final long count2 = testingPostgres - .runSelectStatement("select count(*) from tool where toolname like 'regular%' and ispublished='t'", long.class); - assertEquals(2, count2, "there should be 2 entries"); - - Client.main(new String[] { CONFIG, ResourceHelpers.resourceFilePath("config_file.txt"), TOOL, PUBLISH, "--unpub", ENTRY, - "registry.hub.docker.com/dockstoretestuser/dockerhubandbitbucket/regular", SCRIPT_FLAG }); - final long count3 = testingPostgres - .runSelectStatement("select count(*) from tool where toolname = 'regular2' and ispublished='t'", long.class); - - assertEquals(1, count3, "there should be 1 entry"); - - Client.main(new String[] { CONFIG, ResourceHelpers.resourceFilePath("config_file.txt"), TOOL, PUBLISH, "--unpub", ENTRY, - "registry.hub.docker.com/dockstoretestuser/dockerhubandbitbucket/regular2", SCRIPT_FLAG }); - final long count4 = testingPostgres - .runSelectStatement("select count(*) from tool where toolname like 'regular%' and ispublished='t'", long.class); - - assertEquals(0, count4, "there should be 0 entries"); - - } - - /* - * Test dockerhub and bitbucket - - * These tests are focused on testing entrys created from Dockerhub and Bitbucket repositories - */ - - /** - * Tests manual registration and unpublishing of a Dockerhub/Bitbucket entry - */ - @Test - void testDockerhubBitbucketManualRegistration() { - Client.main(new String[] { CONFIG, ResourceHelpers.resourceFilePath("config_file.txt"), TOOL, MANUAL_PUBLISH, "--registry", - Registry.DOCKER_HUB.name(), Registry.DOCKER_HUB.toString(), "--namespace", "dockstoretestuser", "--name", - "dockerhubandbitbucket", "--git-url", "git@bitbucket.org:DockstoreTestUser/dockstore-whalesay.git", "--git-reference", "master", - "--toolname", "regular", SCRIPT_FLAG }); - - final long count = testingPostgres - .runSelectStatement("select count(*) from tool where toolname = 'regular' and ispublished='t'", long.class); - - assertEquals(1, count, "there should be 1 entries, there are " + count); - - // Unpublish - Client.main(new String[] { CONFIG, ResourceHelpers.resourceFilePath("config_file.txt"), TOOL, PUBLISH, "--unpub", ENTRY, - "registry.hub.docker.com/dockstoretestuser/dockerhubandbitbucket/regular", SCRIPT_FLAG }); - final long count2 = testingPostgres - .runSelectStatement("select count(*) from tool where toolname = 'regular' and ispublished='t'", long.class); - - assertEquals(0, count2, "there should be 0 entries, there are " + count2); - } - - /* - * Test Quay and Bitbucket - - * These tests are focused on testing entries created from Quay and Bitbucket repositories - */ - - /** - * Checks that the two Quay/Bitbucket entrys were automatically found - */ - @Test - void testQuayBitbucketAutoRegistration() { - - final long count = testingPostgres.runSelectStatement( - "select count(*) from tool where registry = '" + Registry.QUAY_IO.getDockerPath() + "' and giturl like 'git@bitbucket.org%'", - long.class); - assertEquals(2, count, "there should be 2 registered from Quay and Bitbucket"); - } - -} diff --git a/dockstore-cli-integration-testing/src/test/java/io/dockstore/client/cli/BitBucketWorkflowIT.java b/dockstore-cli-integration-testing/src/test/java/io/dockstore/client/cli/BitBucketWorkflowIT.java deleted file mode 100644 index 0c7d1232f..000000000 --- a/dockstore-cli-integration-testing/src/test/java/io/dockstore/client/cli/BitBucketWorkflowIT.java +++ /dev/null @@ -1,147 +0,0 @@ -package io.dockstore.client.cli; - -import static io.dockstore.client.cli.ArgumentUtility.CONVERT; -import static io.dockstore.client.cli.Client.CONFIG; -import static io.dockstore.client.cli.Client.SCRIPT_FLAG; -import static io.dockstore.client.cli.Client.WORKFLOW; -import static io.dockstore.client.cli.nested.AbstractEntryClient.ENTRY_2_JSON; -import static io.dockstore.client.cli.nested.AbstractEntryClient.MANUAL_PUBLISH; -import static io.dockstore.client.cli.nested.AbstractEntryClient.PUBLISH; -import static io.dockstore.client.cli.nested.AbstractEntryClient.REFRESH; -import static io.dockstore.client.cli.nested.ToolClient.VERSION_TAG; -import static io.dockstore.client.cli.nested.WesCommandParser.ENTRY; -import static io.dockstore.client.cli.nested.WorkflowClient.UPDATE_WORKFLOW; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import io.dockstore.common.BitBucketTest; -import io.dockstore.common.CLICommonTestUtilities; -import io.dockstore.common.CommonTestUtilities; -import io.dockstore.common.SourceControl; -import io.dockstore.webservice.DockstoreWebserviceApplication; -import io.dropwizard.testing.ResourceHelpers; -import org.elasticsearch.common.collect.Set; -import org.hibernate.Session; -import org.hibernate.context.internal.ManagedSessionContext; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Tag; -import org.junit.jupiter.api.Test; -import uk.org.webcompere.systemstubs.jupiter.SystemStub; -import uk.org.webcompere.systemstubs.stream.SystemErr; -import uk.org.webcompere.systemstubs.stream.SystemOut; - -@Tag(BitBucketTest.NAME) -class BitBucketWorkflowIT extends BaseIT { - - @SystemStub - public final SystemOut systemOutRule = new SystemOut(); - - @SystemStub - public final SystemErr systemErrRule = new SystemErr(); - - @BeforeEach - @Override - public void resetDBBetweenTests() throws Exception { - CLICommonTestUtilities.cleanStatePrivate2(SUPPORT, false, testingPostgres, true); - } - - @AfterEach - public void preserveBitBucketTokens() { - // used to allow us to use cacheBitbucketTokens outside of the web service - DockstoreWebserviceApplication application = SUPPORT.getApplication(); - Session session = application.getHibernate().getSessionFactory().openSession(); - ManagedSessionContext.bind(session); - CommonTestUtilities.cacheBitbucketTokens(SUPPORT); - } - - /** - * Tests that convert with valid imports will work (for WDL) - */ - @Test - void testRefreshAndConvertWithImportsWDL() { - refreshByOrganizationReplacement(USER_2_USERNAME, Set.of(SourceControl.BITBUCKET + "/dockstore_testuser2/dockstore-workflow")); - Client.main( - new String[] { CONFIG, ResourceHelpers.resourceFilePath("config_file2.txt"), WORKFLOW, UPDATE_WORKFLOW, ENTRY, - SourceControl.BITBUCKET + "/dockstore_testuser2/dockstore-workflow", "--descriptor-type", "wdl", - "--workflow-path", "/Dockstore.wdl", "--default-test-parameter-path", "/foo.json", SCRIPT_FLAG }); - - Client.main(new String[] { CONFIG, ResourceHelpers.resourceFilePath("config_file2.txt"), WORKFLOW, REFRESH, ENTRY, - SourceControl.BITBUCKET + "/dockstore_testuser2/dockstore-workflow", SCRIPT_FLAG }); - Client.main(new String[] { CONFIG, ResourceHelpers.resourceFilePath("config_file2.txt"), WORKFLOW, PUBLISH, ENTRY, - SourceControl.BITBUCKET + "/dockstore_testuser2/dockstore-workflow", SCRIPT_FLAG }); - - Client.main( - new String[] { CONFIG, ResourceHelpers.resourceFilePath("config_file2.txt"), WORKFLOW, CONVERT, ENTRY_2_JSON, ENTRY, - SourceControl.BITBUCKET + "/dockstore_testuser2/dockstore-workflow:wdl_import", SCRIPT_FLAG }); - assertTrue(systemOutRule.getText().contains("\"three_step.cgrep.pattern\": \"String\"")); - } - - /** - * This tests manually publishing a Bitbucket workflow - */ - @Test - void testManualPublishBitbucket() { - // manual publish - Client.main( - new String[] { CONFIG, ResourceHelpers.resourceFilePath("config_file2.txt"), WORKFLOW, MANUAL_PUBLISH, "--repository", - "dockstore-workflow", "--organization", "dockstore_testuser2", "--git-version-control", "bitbucket", "--workflow-name", - "testname", "--workflow-path", "/Dockstore.wdl", "--descriptor-type", "wdl", SCRIPT_FLAG }); - - // Check for two valid versions (wdl_import and surprisingly, cwl_import) - final long count = testingPostgres - .runSelectStatement("select count(*) from workflowversion where valid='t' and (name='wdl_import' OR name='cwl_import')", - long.class); - assertEquals(2, count, "There should be a valid 'wdl_import' version and a valid 'cwl_import' version"); - - final long count2 = testingPostgres - .runSelectStatement("select count(*) from workflowversion where lastmodified is null", long.class); - assertEquals(0, count2, "All Bitbucket workflow versions should have last modified populated when manual published"); - - // grab wdl file - Client.main(new String[] { CONFIG, ResourceHelpers.resourceFilePath("config_file2.txt"), WORKFLOW, "wdl", ENTRY, - SourceControl.BITBUCKET + "/dockstore_testuser2/dockstore-workflow/testname:wdl_import", SCRIPT_FLAG }); - } - - /** - * This tests the dirty bit attribute for workflow versions with bitbucket - */ - @Test - void testBitbucketDirtyBit() { - refreshByOrganizationReplacement(USER_2_USERNAME, Set.of(SourceControl.BITBUCKET + "/dockstore_testuser2/dockstore-workflow")); - - // refresh individual that is valid - Client.main(new String[] { CONFIG, ResourceHelpers.resourceFilePath("config_file2.txt"), WORKFLOW, REFRESH, ENTRY, - SourceControl.BITBUCKET + "/dockstore_testuser2/dockstore-workflow", SCRIPT_FLAG }); - final long nullLastModifiedWorkflowVersions = testingPostgres - .runSelectStatement("select count(*) from workflowversion where lastmodified is null", long.class); - assertEquals(0, nullLastModifiedWorkflowVersions, - "All Bitbucket workflow versions should have last modified populated after refreshing"); - // Check that no versions have a true dirty bit - final long count = testingPostgres.runSelectStatement("select count(*) from workflowversion where dirtybit = true", long.class); - assertEquals(0, count, "there should be no versions with dirty bit, there are " + count); - - // Edit workflow path for a version - Client.main(new String[] { CONFIG, ResourceHelpers.resourceFilePath("config_file2.txt"), WORKFLOW, VERSION_TAG, ENTRY, - SourceControl.BITBUCKET + "/dockstore_testuser2/dockstore-workflow", "--name", "master", "--workflow-path", - "/Dockstoredirty.cwl", SCRIPT_FLAG }); - - // There should be on dirty bit - final long count1 = testingPostgres.runSelectStatement("select count(*) from workflowversion where dirtybit = true", long.class); - assertEquals(1, count1, "there should be 1 versions with dirty bit, there are " + count1); - - // Update default cwl - Client.main( - new String[] { CONFIG, ResourceHelpers.resourceFilePath("config_file2.txt"), WORKFLOW, UPDATE_WORKFLOW, ENTRY, - SourceControl.BITBUCKET + "/dockstore_testuser2/dockstore-workflow", "--workflow-path", "/Dockstoreclean.cwl", - SCRIPT_FLAG }); - - // There should be 3 versions with new cwl - final long count2 = testingPostgres - .runSelectStatement("select count(*) from workflowversion where workflowpath = '/Dockstoreclean.cwl'", long.class); - assertEquals(4, count2, "there should be 4 versions with workflow path /Dockstoreclean.cwl, there are " + count2); - - } - - -} diff --git a/dockstore-cli-integration-testing/src/test/java/io/dockstore/common/CLICommonTestUtilities.java b/dockstore-cli-integration-testing/src/test/java/io/dockstore/common/CLICommonTestUtilities.java index ab09c08e4..6b88a7554 100644 --- a/dockstore-cli-integration-testing/src/test/java/io/dockstore/common/CLICommonTestUtilities.java +++ b/dockstore-cli-integration-testing/src/test/java/io/dockstore/common/CLICommonTestUtilities.java @@ -16,33 +16,21 @@ package io.dockstore.common; -import com.google.common.hash.Hashing; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; import io.dockstore.openapi.client.ApiClient; import io.dockstore.openapi.client.ApiException; import io.dockstore.openapi.client.model.DockstoreTool; import io.dockstore.openapi.client.model.Tag; -import io.dockstore.webservice.DockstoreWebserviceApplication; import io.dockstore.webservice.DockstoreWebserviceConfiguration; -import io.dockstore.webservice.core.Token; -import io.dockstore.webservice.jdbi.TokenDAO; import io.dropwizard.core.Application; import io.dropwizard.testing.DropwizardTestSupport; import io.dropwizard.testing.ResourceHelpers; import java.io.File; -import java.io.IOException; -import java.io.UncheckedIOException; -import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; import org.apache.commons.configuration2.INIConfiguration; import org.apache.commons.io.FileUtils; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.context.internal.ManagedSessionContext; import org.junit.Assert; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -155,24 +143,13 @@ public static void deleteBitBucketToken(TestingPostgres testingPostgres) { * * @param support reference to testing instance of the dockstore web service * @param testingPostgres reference to the testing instance of Postgres - * @param needBitBucketToken if false the bitbucket token will be deleted * @throws Exception */ public static void cleanStatePrivate1(DropwizardTestSupport support, - TestingPostgres testingPostgres, Boolean needBitBucketToken) throws Exception { + TestingPostgres testingPostgres) throws Exception { LOG.info("Dropping and Recreating the database with confidential 1 test data"); cleanStatePrivate1(support, CONFIDENTIAL_CONFIG_PATH); - handleBitBucketTokens(support, testingPostgres, needBitBucketToken); - } - /** - * Wrapper for dropping and recreating database from migrations for test confidential 1 - * - * @param support reference to testing instance of the dockstore web service - * @param testingPostgres reference to the testing instance of Postgres - * @throws Exception - */ - public static void cleanStatePrivate1(DropwizardTestSupport support, TestingPostgres testingPostgres) throws Exception { - cleanStatePrivate1(support, testingPostgres, false); + handleBitBucketTokens(testingPostgres); } /** @@ -207,39 +184,10 @@ private static void cleanStatePrivate1(DropwizardTestSupport support, TestingPostgres testingPostgres, boolean needBitBucketToken) { - if (!needBitBucketToken) { - deleteBitBucketToken(testingPostgres); - } else { - DockstoreWebserviceApplication application = support.getApplication(); - Session session = application.getHibernate().getSessionFactory().openSession(); - ManagedSessionContext.bind(session); - //TODO restore bitbucket token from disk cache to reduce rate limit from busting cache with new access tokens - SessionFactory sessionFactory = application.getHibernate().getSessionFactory(); - TokenDAO tokenDAO = new TokenDAO(sessionFactory); - final List allBitBucketTokens = tokenDAO.findAllBitBucketTokens(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - - for (Token token : allBitBucketTokens) { - try { - final String cacheCandidate = FileUtils.readFileToString(new File(CommonTestUtilities.BITBUCKET_TOKEN_CACHE + Hashing.sha256().hashString(token.getRefreshToken(), StandardCharsets.UTF_8) + ".json"), - StandardCharsets.UTF_8); - final Token cachedToken = gson.fromJson(cacheCandidate, Token.class); - if (cachedToken != null) { - testingPostgres.runUpdateStatement( - "update token set content = '" + cachedToken.getContent() + "', dbUpdateDate = '" + cachedToken.getDbUpdateDate().toLocalDateTime().toString() + "' where id = " - + cachedToken.getId()); - } - } catch (IOException | UncheckedIOException e) { - // probably ok - LOG.debug("could not read bitbucket token", e); - } - } - } + private static void handleBitBucketTokens(TestingPostgres testingPostgres) { + deleteBitBucketToken(testingPostgres); } private static void runExternalMigration(List migrationList, Application application, @@ -260,22 +208,10 @@ private static void runExternalMigration(List migrationList, Application * @throws Exception */ public static void cleanStatePrivate2(DropwizardTestSupport support, boolean isNewApplication, - TestingPostgres testingPostgres, boolean needBitBucketToken) throws Exception { + TestingPostgres testingPostgres) throws Exception { LOG.info("Dropping and Recreating the database with confidential 2 test data"); cleanStatePrivate2(support, CONFIDENTIAL_CONFIG_PATH, isNewApplication); - handleBitBucketTokens(support, testingPostgres, needBitBucketToken); - } - - /** - * Wrapper for dropping and recreating database from migrations for test confidential 2 - * - * @param support reference to testing instance of the dockstore web service - * @throws Exception - */ - public static void cleanStatePrivate2(DropwizardTestSupport support, boolean isNewApplication, TestingPostgres testingPostgres) - throws Exception { - cleanStatePrivate2(support, isNewApplication, testingPostgres, false); - // TODO: You can uncomment the following line to disable GitLab tool and workflow discovery + handleBitBucketTokens(testingPostgres); // getTestingPostgres(SUPPORT).runUpdateStatement("delete from token where tokensource = 'gitlab.com'"); } diff --git a/legacy.md b/legacy.md index 9fab0d99b..5f3bf035d 100644 --- a/legacy.md +++ b/legacy.md @@ -78,11 +78,6 @@ Setup your copy of Dockstore as a third-party application able to communicate wi 3. Authorize via quay.io using the provided link 4. Browse to [http://localhost:8080/container](http://localhost:8080/container) to list repos that we have tokens for at quay.io -### Demo Integration with Bitbucket - -1. Setup a new application as described in [Integrate another application through OAuth](https://confluence.atlassian.com/bitbucket/integrate-another-application-through-oauth-372605388.html). -2. Use the dockstore-ui to authorize Bitbucket access for your current logged in user. Use the UI refresh controls to refresh your tools. - ### Webservice Demo Demo the webservice and test communication with GitHub and quay.io diff --git a/pom.xml b/pom.xml index 9a8f64dc9..94b44d091 100644 --- a/pom.xml +++ b/pom.xml @@ -728,8 +728,7 @@ io.dockstore.common.SlowTest, io.dockstore.common.BenchmarkTest, io.dockstore.common.ToilOnlyTest, - io.dockstore.client.cli.nested.WesTests, - io.dockstore.common.BitBucketTest + io.dockstore.client.cli.nested.WesTests @@ -784,8 +783,7 @@ io.dockstore.client.cli.nested.SingularityTest, io.dockstore.common.SlowTest, io.dockstore.common.ToilOnlyTest, - io.dockstore.client.cli.nested.WesTests, - io.dockstore.common.BitBucketTest + io.dockstore.client.cli.nested.WesTests @@ -801,8 +799,7 @@ io.dockstore.common.SlowTest, io.dockstore.common.ToilOnlyTest, io.dockstore.common.WorkflowTest, - io.dockstore.client.cli.nested.WesTests, - io.dockstore.common.BitBucketTest + io.dockstore.client.cli.nested.WesTests @@ -818,19 +815,10 @@ io.dockstore.common.SlowTest, io.dockstore.common.ToilOnlyTest, io.dockstore.common.ToolTest, - io.dockstore.client.cli.nested.WesTests, - io.dockstore.common.BitBucketTest + io.dockstore.client.cli.nested.WesTests - - bitbucket-tests - - true - false - io.dockstore.common.BitBucketTest - - non-confidential-tests @@ -842,8 +830,7 @@ io.dockstore.common.SlowTest, io.dockstore.common.ToilOnlyTest, io.dockstore.common.ConfidentialTest, - io.dockstore.client.cli.nested.WesTests, - io.dockstore.common.BitBucketTest + io.dockstore.client.cli.nested.WesTests