Allon Mureinik has uploaded a new change for review. Change subject: core: Fix GetConfigurationValueQueryTest ......................................................................
core: Fix GetConfigurationValueQueryTest Fixed GetConfigurationValueQueryTest to allow easier development in this area. This patch includes: 1. Fixed tests for a non-admin user attempting to execute a non-filtered query. These attempts should obviously fail, regardless of the type of configuration value. Before this patch, the test checked that executeQuery() actually returned a value albeit that this is an invalid test, as executeQuery() should never have been called, due to validatePermissions() returning false. For additional details, see (2). 2. Called getQuery().execute() instead of getQuery().executeQuery(). executeQuery() is an internal implementation detail, and should not be relied upon to handle security concerns (in fact, this reliance is indeed removed in a subsequent patch). 3. Improve the assertion message in case the test fails so that includes more details on the failure. Change-Id: I358944b915764f58b2f756f857df4aef0ce1580d Signed-off-by: Allon Mureinik <amure...@redhat.com> --- M backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/GetConfigurationValueQueryTest.java 1 file changed, 5 insertions(+), 5 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/99/22999/1 diff --git a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/GetConfigurationValueQueryTest.java b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/GetConfigurationValueQueryTest.java index df60e15..34751ce 100644 --- a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/GetConfigurationValueQueryTest.java +++ b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/GetConfigurationValueQueryTest.java @@ -25,7 +25,7 @@ @Test public void testExecuteQueryUserConfigNotFiltered() { - assertQueryExecution(ConfigurationValues.MaxVmsInPool, false, true); + assertQueryExecution(ConfigurationValues.MaxVmsInPool, false, false); } @Test @@ -35,7 +35,7 @@ @Test public void testExecuteQueryAdminConfigNotFiltered() { - assertQueryExecution(ConfigurationValues.AdUserName, false, true); + assertQueryExecution(ConfigurationValues.AdUserName, false, false); } private void assertQueryExecution(ConfigurationValues configValue, boolean isFiltered, boolean shouldSucceed) { @@ -48,14 +48,14 @@ // Mock the config String expected = mockConfig(version, configValue); - getQuery().executeQueryCommand(); + getQuery().execute(); Object actual = getQuery().getQueryReturnValue().getReturnValue(); if (shouldSucceed) { - assertEquals("Got wrong expected value for " + configValue, expected, actual); + assertEquals("Got wrong value for " + configValue, expected, actual); } else { - assertNull("Should get null result for " + configValue, actual); + assertNull("Should get null result for " + configValue + " but got " + actual, actual); } } -- To view, visit http://gerrit.ovirt.org/22999 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I358944b915764f58b2f756f857df4aef0ce1580d Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Allon Mureinik <amure...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches