Skip to content

Commit

Permalink
Issue #5824 Return only durable mappings before ConstraintSecurityHan…
Browse files Browse the repository at this point in the history
…dler start

Signed-off-by: Jan Bartel <janb@webtide.com>
  • Loading branch information
janbartel committed Dec 24, 2020
1 parent 9d328ce commit 39d7083
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
Expand Up @@ -262,12 +262,19 @@ public static List<ConstraintMapping> createConstraintsWithMappingsForPath(Strin
}

/**
* @return Returns the constraintMappings.
* @return only the durable mappings if we are not yet started, otherwise
* return both the durables and transients.
*/
@Override
public List<ConstraintMapping> getConstraintMappings()
{
return _constraintMappings;
//if we've started, then we've processed both the durable and
//transient constraint mappings
if (isRunning())
return _constraintMappings;
else
//otherwise, we only have durables
return _durableConstraintMappings;
}

@Override
Expand Down
Expand Up @@ -214,9 +214,6 @@ private List<ConstraintMapping> getConstraintMappings()
@Test
public void testConstraints() throws Exception
{
//constraint mappings are not available until the server is started.
_server.start();

List<ConstraintMapping> mappings = new ArrayList<>(_security.getConstraintMappings());

assertTrue(mappings.get(0).getConstraint().isForbidden());
Expand Down Expand Up @@ -256,10 +253,13 @@ public void testDurableConstraints() throws Exception

_server.stop();

//After a stop, just the durable mappings are left
mappings = _security.getConstraintMappings();
assertThat("after restart", 0, Matchers.equalTo(mappings.size()));
assertThat("after stop", getConstraintMappings().size(), Matchers.equalTo(mappings.size()));

_server.start();

//Verify the constraints are just the durables
mappings = _security.getConstraintMappings();
assertThat("after restart", getConstraintMappings().size(), Matchers.equalTo(mappings.size()));

Expand All @@ -278,6 +278,7 @@ public void testDurableConstraints() throws Exception
_server.stop();
_server.start();

//After a stop, only the durable mappings remain
mappings = _security.getConstraintMappings();
assertThat("after addition", getConstraintMappings().size(), Matchers.equalTo(mappings.size()));
}
Expand Down

0 comments on commit 39d7083

Please sign in to comment.