This repository was archived by the owner on Sep 16, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +38
-2
lines changed
main/java/com/marklogic/mgmt/api/security
java/com/marklogic/appdeployer/command/security
resources/sample-app/roles-with-circular-dependencies/security/roles Expand file tree Collapse file tree 4 files changed +38
-2
lines changed Original file line number Diff line number Diff line change @@ -78,7 +78,15 @@ else if (index > -1) {
7878 }
7979 }
8080
81- String [] sortedRoleNames = sorter .sort ();
81+ String [] sortedRoleNames ;
82+ try {
83+ sortedRoleNames = sorter .sort ();
84+ } catch (IllegalStateException ex ) {
85+ throw new IllegalArgumentException ("Unable to deploy roles due to circular dependencies " +
86+ "between two or more roles; please remove these circular dependencies in order to deploy" +
87+ " your roles" );
88+ }
89+
8290 roles = new ArrayList <>();
8391 for (String name : sortedRoleNames ) {
8492 roles .add (map .get (name ));
Original file line number Diff line number Diff line change 66
77import java .io .File ;
88
9- import static org .junit .jupiter .api .Assertions .assertTrue ;
9+ import static org .junit .jupiter .api .Assertions .* ;
1010
1111/**
1212 * Each of these tests verifies that the roles in the given config dir can be deployed successfully based on their
@@ -73,6 +73,22 @@ public void anotherSortingTest() {
7373 }
7474 }
7575
76+ @ Test
77+ void circularDependencies () {
78+ appConfig .getFirstConfigDir ().setBaseDir (new File ("src/test/resources/sample-app/roles-with-circular-dependencies" ));
79+ initializeAppDeployer (new DeployRolesCommand ());
80+ try {
81+ deploySampleApp ();
82+ fail ("Expected an error due to a circular dependency between the two roles" );
83+ } catch (IllegalArgumentException ex ) {
84+ assertEquals ("Unable to deploy roles due to circular dependencies between two or more roles; " +
85+ "please remove these circular dependencies in order to deploy your roles" ,
86+ ex .getMessage ());
87+ } finally {
88+ undeploySampleApp ();
89+ }
90+ }
91+
7692 @ Test
7793 public void test () {
7894 appConfig .getFirstConfigDir ().setBaseDir (new File ("src/test/resources/sample-app/roles-with-dependencies" ));
Original file line number Diff line number Diff line change 1+ {
2+ "role-name" : " sample-app-role0" ,
3+ "role" : [
4+ " sample-app-role1"
5+ ]
6+ }
Original file line number Diff line number Diff line change 1+ {
2+ "role-name" : " sample-app-role1" ,
3+ "role" : [
4+ " sample-app-role0"
5+ ]
6+ }
You can’t perform that action at this time.
0 commit comments