From 343dc05f82be31cff5e4a2689a77e265cd2c5afe Mon Sep 17 00:00:00 2001 From: Pedro Igor Date: Wed, 16 May 2018 10:38:56 -0300 Subject: [PATCH] [KEYCLOAK-7360] - Both time and rules policy not showing number fields --- .../TimePolicyManagementTest.java | 28 +++++++++++++------ .../resources/js/authz/authz-controller.js | 2 +- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/authorization/TimePolicyManagementTest.java b/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/authorization/TimePolicyManagementTest.java index ed0165d72f..9abc570546 100644 --- a/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/authorization/TimePolicyManagementTest.java +++ b/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/authorization/TimePolicyManagementTest.java @@ -20,10 +20,8 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import org.junit.Test; -import org.keycloak.representations.idm.authorization.JSPolicyRepresentation; import org.keycloak.representations.idm.authorization.Logic; import org.keycloak.representations.idm.authorization.TimePolicyRepresentation; -import org.keycloak.testsuite.console.page.clients.authorization.policy.JSPolicy; import org.keycloak.testsuite.console.page.clients.authorization.policy.TimePolicy; /** @@ -32,14 +30,14 @@ import org.keycloak.testsuite.console.page.clients.authorization.policy.TimePoli public class TimePolicyManagementTest extends AbstractAuthorizationSettingsTest { @Test - public void testUpdate() throws InterruptedException { + public void testUpdate() { authorizationPage.navigateTo(); TimePolicyRepresentation expected = new TimePolicyRepresentation(); expected.setName("Test Time Policy"); expected.setDescription("description"); expected.setNotBefore("2017-01-01 00:00:00"); - expected.setNotBefore("2018-01-01 00:00:00"); + expected.setNotOnOrAfter("2018-01-01 00:00:00"); expected.setDayMonth("1"); expected.setDayMonthEnd("2"); expected.setMonth("3"); @@ -59,7 +57,7 @@ public class TimePolicyManagementTest extends AbstractAuthorizationSettingsTest expected.setDescription("Changed description"); expected.setLogic(Logic.NEGATIVE); expected.setNotBefore("2018-01-01 00:00:00"); - expected.setNotBefore("2019-01-01 00:00:00"); + expected.setNotOnOrAfter("2019-01-01 00:00:00"); expected.setDayMonth("23"); expected.setDayMonthEnd("25"); expected.setMonth("11"); @@ -82,14 +80,14 @@ public class TimePolicyManagementTest extends AbstractAuthorizationSettingsTest } @Test - public void testDelete() throws InterruptedException { + public void testDelete() { authorizationPage.navigateTo(); TimePolicyRepresentation expected = new TimePolicyRepresentation(); expected.setName("Test Time Policy"); expected.setDescription("description"); expected.setNotBefore("2017-01-01 00:00:00"); - expected.setNotBefore("2018-01-01 00:00:00"); + expected.setNotOnOrAfter("2018-01-01 00:00:00"); expected.setDayMonth("1"); expected.setDayMonthEnd("2"); expected.setMonth("3"); @@ -110,14 +108,14 @@ public class TimePolicyManagementTest extends AbstractAuthorizationSettingsTest } @Test - public void testDeleteFromList() throws InterruptedException { + public void testDeleteFromList() { authorizationPage.navigateTo(); TimePolicyRepresentation expected = new TimePolicyRepresentation(); expected.setName("Test Time Policy"); expected.setDescription("description"); expected.setNotBefore("2017-01-01 00:00:00"); - expected.setNotBefore("2018-01-01 00:00:00"); + expected.setNotOnOrAfter("2018-01-01 00:00:00"); expected.setDayMonth("1"); expected.setDayMonthEnd("2"); expected.setMonth("3"); @@ -148,6 +146,18 @@ public class TimePolicyManagementTest extends AbstractAuthorizationSettingsTest assertEquals(expected.getName(), actual.getName()); assertEquals(expected.getDescription(), actual.getDescription()); assertEquals(expected.getLogic(), actual.getLogic()); + assertEquals(expected.getNotBefore(), actual.getNotBefore()); + assertEquals(expected.getNotOnOrAfter(), actual.getNotOnOrAfter()); + assertEquals(expected.getDayMonth(), actual.getDayMonth()); + assertEquals(expected.getDayMonthEnd(), actual.getDayMonthEnd()); + assertEquals(expected.getHour(), actual.getHour()); + assertEquals(expected.getHourEnd(), actual.getHourEnd()); + assertEquals(expected.getMinute(), actual.getMinute()); + assertEquals(expected.getMinuteEnd(), actual.getMinuteEnd()); + assertEquals(expected.getMonth(), actual.getMonth()); + assertEquals(expected.getMonthEnd(), actual.getMonthEnd()); + assertEquals(expected.getYear(), actual.getYear()); + assertEquals(expected.getYearEnd(), actual.getYearEnd()); return actual; } diff --git a/themes/src/main/resources/theme/base/admin/resources/js/authz/authz-controller.js b/themes/src/main/resources/theme/base/admin/resources/js/authz/authz-controller.js index 8636410f65..228ce84fa7 100644 --- a/themes/src/main/resources/theme/base/admin/resources/js/authz/authz-controller.js +++ b/themes/src/main/resources/theme/base/admin/resources/js/authz/authz-controller.js @@ -2321,7 +2321,7 @@ module.service("PolicyController", function($http, $route, $location, ResourceSe } $instance.restoreState($scope); } else if (delegate.onInitUpdate) { - delegate.onInitUpdate(policy); + delegate.onInitUpdate($scope.policy); } $scope.$watch('policy', function() {