|
| 1 | +package org.labkey.test.tests.upgrade; |
| 2 | + |
| 3 | +import org.junit.Test; |
| 4 | +import org.junit.experimental.categories.Category; |
| 5 | +import org.labkey.test.Locators; |
| 6 | +import org.labkey.test.pages.ConfigureReportsAndScriptsPage; |
| 7 | +import org.labkey.test.pages.ConfigureReportsAndScriptsPage.EngineType; |
| 8 | +import org.labkey.test.pages.admin.RConfigurationPage; |
| 9 | +import org.labkey.test.pages.mothership.EditUpgradeMessagePage; |
| 10 | +import org.labkey.test.pages.query.ExecuteQueryPage; |
| 11 | +import org.labkey.test.util.RReportHelper; |
| 12 | + |
| 13 | +import java.util.List; |
| 14 | + |
| 15 | +import static org.junit.Assert.assertEquals; |
| 16 | + |
| 17 | +@Category({}) |
| 18 | +public class EncryptionKeyUpgradeTest extends BaseUpgradeTest |
| 19 | +{ |
| 20 | + private static final String DUMMY_R_SERVE = "Dummy RServe"; |
| 21 | + |
| 22 | + @Override |
| 23 | + protected void doCleanup(boolean afterTest) |
| 24 | + { |
| 25 | + _containerHelper.deleteProject(getProjectName(), afterTest); |
| 26 | + } |
| 27 | + |
| 28 | + @Override |
| 29 | + protected void doSetup() |
| 30 | + { |
| 31 | + ConfigureReportsAndScriptsPage configureReportsAndScriptsPage = ConfigureReportsAndScriptsPage.beginAt(this); |
| 32 | + configureReportsAndScriptsPage.deleteEnginesFromList(List.of(DUMMY_R_SERVE)); |
| 33 | + |
| 34 | + // Create an R engine with a password (which will be encrypted) |
| 35 | + ConfigureReportsAndScriptsPage.EngineConfig config = new ConfigureReportsAndScriptsPage.RServeEngineConfig() |
| 36 | + .setPassword("password") |
| 37 | + .setName(DUMMY_R_SERVE); |
| 38 | + configureReportsAndScriptsPage.addEngine(EngineType.REMOTE_R, config); |
| 39 | + |
| 40 | + _containerHelper.createProject(getProjectName(), null); |
| 41 | + RConfigurationPage.beginAt(this, getProjectName()) |
| 42 | + .setEngineOverrides(DUMMY_R_SERVE, DUMMY_R_SERVE) |
| 43 | + .save(); |
| 44 | + |
| 45 | + // Set StatusCake api key |
| 46 | + EditUpgradeMessagePage.beginAt(this) |
| 47 | + .setStatusCakeApiKey("password") |
| 48 | + .save(); |
| 49 | + } |
| 50 | + |
| 51 | + @Test |
| 52 | + public void testDummyRemoteREngine() |
| 53 | + { |
| 54 | + // Trying to contact the R server will trigger an error if there is a problem with password encryption |
| 55 | + ExecuteQueryPage.beginAt(this, getProjectName(), "core", "containers").getDataRegion() |
| 56 | + .goToReport("Create R Report"); |
| 57 | + new RReportHelper(this).clickReportTab(); |
| 58 | + |
| 59 | + waitForElement(Locators.labkeyError.withText("Error executing command")); |
| 60 | + assertTextPresent("Could not connect to: 127.0.0.1:6311"); |
| 61 | + |
| 62 | + } |
| 63 | + |
| 64 | + @Test |
| 65 | + public void testStatusCakeApiKey() |
| 66 | + { |
| 67 | + // Just loading this page can trigger an error if there was a problem with the encryption |
| 68 | + assertEquals("StatusCake API key input should be present but blank", |
| 69 | + "", EditUpgradeMessagePage.beginAt(this).getStatusCakeApiKey()); |
| 70 | + } |
| 71 | + |
| 72 | + @Override |
| 73 | + protected String getProjectName() |
| 74 | + { |
| 75 | + return "EncryptionKeyUpgradeTest Project"; |
| 76 | + } |
| 77 | + |
| 78 | +} |
0 commit comments