Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package org.labkey.test.tests.upgrade;

import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.labkey.test.Locators;
import org.labkey.test.pages.ConfigureReportsAndScriptsPage;
import org.labkey.test.pages.ConfigureReportsAndScriptsPage.EngineType;
import org.labkey.test.pages.admin.RConfigurationPage;
import org.labkey.test.pages.mothership.EditUpgradeMessagePage;
import org.labkey.test.pages.query.ExecuteQueryPage;
import org.labkey.test.util.RReportHelper;

import java.util.List;

import static org.junit.Assert.assertEquals;

@Category({})
public class EncryptionKeyUpgradeTest extends BaseUpgradeTest
{
private static final String DUMMY_R_SERVE = "Dummy RServe";

@Override
protected void doCleanup(boolean afterTest)
{
_containerHelper.deleteProject(getProjectName(), afterTest);
}

@Override
protected void doSetup()
{
ConfigureReportsAndScriptsPage configureReportsAndScriptsPage = ConfigureReportsAndScriptsPage.beginAt(this);
configureReportsAndScriptsPage.deleteEnginesFromList(List.of(DUMMY_R_SERVE));

// Create an R engine with a password (which will be encrypted)
ConfigureReportsAndScriptsPage.EngineConfig config = new ConfigureReportsAndScriptsPage.RServeEngineConfig()
.setPassword("password")
.setName(DUMMY_R_SERVE);
configureReportsAndScriptsPage.addEngine(EngineType.REMOTE_R, config);

_containerHelper.createProject(getProjectName(), null);
RConfigurationPage.beginAt(this, getProjectName())
.setEngineOverrides(DUMMY_R_SERVE, DUMMY_R_SERVE)
.save();

// Set StatusCake api key
EditUpgradeMessagePage.beginAt(this)
.setStatusCakeApiKey("password")
.save();
}

@Test
public void testDummyRemoteREngine()
{
// Trying to contact the R server will trigger an error if there is a problem with password encryption
ExecuteQueryPage.beginAt(this, getProjectName(), "core", "containers").getDataRegion()
.goToReport("Create R Report");
new RReportHelper(this).clickReportTab();

waitForElement(Locators.labkeyError.withText("Error executing command"));
assertTextPresent("Could not connect to: 127.0.0.1:6311");

}

@Test
public void testStatusCakeApiKey()
{
// Just loading this page can trigger an error if there was a problem with the encryption
assertEquals("StatusCake API key input should be present but blank",
"", EditUpgradeMessagePage.beginAt(this).getStatusCakeApiKey());
}

@Override
protected String getProjectName()
{
return "EncryptionKeyUpgradeTest Project";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,17 @@ public EditUpgradeMessagePage setIssuesContainer(String issuesContainerPath)
return this;
}

public String getStatusCakeApiKey()
{
return elementCache().statusCakeApiKeyInput.get();
}

public EditUpgradeMessagePage setStatusCakeApiKey(String apiKey)
{
elementCache().statusCakeApiKeyInput.set(apiKey);
return this;
}

public ShowExceptionsPage save()
{
sleep(1000); // give time for set or clear actions to process
Expand All @@ -115,13 +126,14 @@ protected ElementCache newElementCache()
return new ElementCache();
}

protected class ElementCache extends BaseMothershipPage.ElementCache
protected class ElementCache extends BaseMothershipPage<?>.ElementCache
{
Input currentBuildDateInput = new Input(Locator.name("currentBuildDate").findWhenNeeded(this), getDriver());
Input messageTextArea = new Input(Locator.name("message").findWhenNeeded(this), getDriver());
Input createIssueURLInput = new Input(Locator.name("createIssueURL").findWhenNeeded(this), getDriver());
Input issuesContainerInput = new Input(Locator.name("issuesContainer").findWhenNeeded(this), getDriver());
Input marketingMessageTextArea = new Input(Locator.name("marketingMessage").findWhenNeeded(this), getDriver());
WebElement saveButton = Locator.lkButton("Save").findWhenNeeded( this);
Input statusCakeApiKeyInput = new Input(Locator.name("statusCakeApiKey").findWhenNeeded(this), getDriver());
WebElement saveButton = Locator.lkButton("Save").findWhenNeeded(this);
}
}