Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Commit d212436

Browse files
committed
#432 Amps are now deployed right before modules
1 parent 80b6410 commit d212436

File tree

5 files changed

+48
-10
lines changed

5 files changed

+48
-10
lines changed

src/main/java/com/marklogic/appdeployer/command/SortOrderConstants.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,15 @@ public abstract class SortOrderConstants {
4141
// Module code may depend on schemas, but not vice-versa.
4242
public static Integer LOAD_SCHEMAS = 350;
4343

44+
// The modules database must exist before we deploy amps, but in the event that loading modules depends
45+
// on an amp (will be true in DHF 5.5), amps should be deployed before modules are loaded.
46+
public static Integer DEPLOY_AMPS = 390;
47+
4448
// Modules have to be loaded after the REST API server has been updated, for if the deployer is expecting to load
4549
// modules via SSL, then the REST API server must already be configured with a certificate template
4650
public static Integer LOAD_MODULES = 400;
4751
public static Integer DELETE_TEST_MODULES = 410;
4852

49-
// The modules database must exist before we deploy amps
50-
public static Integer DEPLOY_AMPS = 450;
51-
5253
public static Integer DEPLOY_TRIGGERS = 700;
5354

5455
public static Integer DEPLOY_TEMPORAL_AXIS = 750;

src/test/java/com/marklogic/appdeployer/command/security/ManageAmpsTest.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,43 @@
22

33
import com.marklogic.appdeployer.command.AbstractManageResourceTest;
44
import com.marklogic.appdeployer.command.Command;
5+
import com.marklogic.appdeployer.command.modules.LoadModulesCommand;
6+
import com.marklogic.appdeployer.command.restapis.DeployRestApiServersCommand;
7+
import com.marklogic.client.DatabaseClient;
8+
import com.marklogic.client.DatabaseClientFactory;
59
import com.marklogic.mgmt.ManageClient;
10+
import com.marklogic.mgmt.ManageConfig;
611
import com.marklogic.mgmt.resource.ResourceManager;
712
import com.marklogic.mgmt.resource.security.AmpManager;
813
import org.junit.Test;
914

1015
public class ManageAmpsTest extends AbstractManageResourceTest {
1116

17+
@Test
18+
public void ampLoadedBeforeModules() {
19+
initializeAppDeployer(new DeployUsersCommand(), new DeployRestApiServersCommand(true),
20+
new DeployAmpsCommand(), new LoadModulesCommand());
21+
appConfig.setModuleTimestampsPath(null);
22+
23+
try {
24+
deploySampleApp();
25+
26+
// Create a client for a user that does not have the status privilege, which is required
27+
// by the get-host-status function
28+
DatabaseClient client = DatabaseClientFactory.newClient(super.manageConfig.getHost(), appConfig.getRestPort(),
29+
new DatabaseClientFactory.DigestAuthContext("sample-app-jane", "password"));
30+
31+
String output = client.newServerEval().xquery(
32+
"import module namespace sample = 'urn:sampleapp' at '/ext/sample-lib.xqy'; " +
33+
"sample:get-host-status()").evalAs(String.class);
34+
35+
assertNotNull("The amp is loaded before the module, but it should still apply and allow the user " +
36+
"to invoke the function that requires the status-builtins privilege", output);
37+
} finally {
38+
undeploySampleApp();
39+
}
40+
}
41+
1242
/**
1343
* This test verifies that AmpManager can correctly handle two amps that have the same local-name, document-uri,
1444
* and namespace, but with a different modules-database.
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"namespace": "http://example.com/uri",
3-
"local-name": "ml-app-deployer-test-1",
4-
"document-uri": "/module/path/name",
5-
"modules-database": "Modules",
6-
"role": ["app-user"]
2+
"namespace": "urn:sampleapp",
3+
"local-name": "get-host-status",
4+
"document-uri": "/ext/sample-lib.xqy",
5+
"modules-database": "%%MODULES_DATABASE%%",
6+
"role": ["admin"]
77
}
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
{
2-
"user-name":"sample-app-jane",
3-
"password": "password"
2+
"user-name":"sample-app-jane",
3+
"password": "password",
4+
"description": "temporal-admin is granted so the user can hit /v1/eval, as that grants the xdbc-eval privilege",
5+
"role": ["rest-reader", "rest-extension-user", "temporal-admin"]
46
}

src/test/resources/sample-app/src/main/ml-modules/ext/sample-lib.xqy

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,8 @@ declare function echo($str as xs:string?) as xs:string
66
{
77
"You said: " || $str
88
};
9+
10+
declare function get-host-status()
11+
{
12+
xdmp:host-status(xdmp:host())
13+
};

0 commit comments

Comments
 (0)