Skip to content

Commit 0b4fb0d

Browse files
authored
Add test for encryption key upgrade (#7149)
1 parent 03e2c44 commit 0b4fb0d

2 files changed

Lines changed: 92 additions & 2 deletions

File tree

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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+
}

mothership/test/src/org/labkey/test/pages/mothership/EditUpgradeMessagePage.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,17 @@ public EditUpgradeMessagePage setIssuesContainer(String issuesContainerPath)
102102
return this;
103103
}
104104

105+
public String getStatusCakeApiKey()
106+
{
107+
return elementCache().statusCakeApiKeyInput.get();
108+
}
109+
110+
public EditUpgradeMessagePage setStatusCakeApiKey(String apiKey)
111+
{
112+
elementCache().statusCakeApiKeyInput.set(apiKey);
113+
return this;
114+
}
115+
105116
public ShowExceptionsPage save()
106117
{
107118
sleep(1000); // give time for set or clear actions to process
@@ -115,13 +126,14 @@ protected ElementCache newElementCache()
115126
return new ElementCache();
116127
}
117128

118-
protected class ElementCache extends BaseMothershipPage.ElementCache
129+
protected class ElementCache extends BaseMothershipPage<?>.ElementCache
119130
{
120131
Input currentBuildDateInput = new Input(Locator.name("currentBuildDate").findWhenNeeded(this), getDriver());
121132
Input messageTextArea = new Input(Locator.name("message").findWhenNeeded(this), getDriver());
122133
Input createIssueURLInput = new Input(Locator.name("createIssueURL").findWhenNeeded(this), getDriver());
123134
Input issuesContainerInput = new Input(Locator.name("issuesContainer").findWhenNeeded(this), getDriver());
124135
Input marketingMessageTextArea = new Input(Locator.name("marketingMessage").findWhenNeeded(this), getDriver());
125-
WebElement saveButton = Locator.lkButton("Save").findWhenNeeded( this);
136+
Input statusCakeApiKeyInput = new Input(Locator.name("statusCakeApiKey").findWhenNeeded(this), getDriver());
137+
WebElement saveButton = Locator.lkButton("Save").findWhenNeeded(this);
126138
}
127139
}

0 commit comments

Comments
 (0)