Skip to content

Commit

Permalink
Add 'assign role' notification test
Browse files Browse the repository at this point in the history
The idea is to catch "Target: approvalroletest1 (dummy) [owner]"
style texts but unfortunately they do not occur in usual cases.
  • Loading branch information
mederly committed Apr 10, 2018
1 parent 23d4d58 commit 6445476
Showing 1 changed file with 54 additions and 0 deletions.
Expand Up @@ -364,6 +364,60 @@ public void test131ModifyUserJackAssignAccount() throws Exception {

}

@Test
public void test135ModifyUserJackAssignRole() throws Exception {
final String TEST_NAME = "test135ModifyUserJackAssignRole";
TestUtil.displayTestTitle(this, TEST_NAME);

// GIVEN
Task task = taskManager.createTaskInstance(TestNotifications.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
preTestCleanup(AssignmentPolicyEnforcementType.FULL);

// WHEN
TestUtil.displayWhen(TEST_NAME);
assignRole(USER_JACK_OID, ROLE_SUPERUSER_OID, task, result);

// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess("executeChanges result", result);

PrismObject<UserType> userJack = getUser(USER_JACK_OID);
display("User after change execution", userJack);
assertUserJack(userJack);
assertAssignedRole(userJack, ROLE_SUPERUSER_OID);
assertAssignments(userJack, 2);

// Check notifications
display("Notifications", dummyTransport);

notificationManager.setDisabled(true);
checkDummyTransportMessages("accountPasswordNotifier", 0);
checkDummyTransportMessages("userPasswordNotifier", 0);
checkDummyTransportMessages("simpleAccountNotifier-SUCCESS", 0);
checkDummyTransportMessages("simpleAccountNotifier-FAILURE", 0);
checkDummyTransportMessages("simpleAccountNotifier-ADD-SUCCESS", 0);
checkDummyTransportMessages("simpleAccountNotifier-DELETE-SUCCESS", 0);
checkDummyTransportMessages("simpleUserNotifier", 1);
checkDummyTransportMessages("simpleUserNotifier-ADD", 0);

assertSteadyResources();

String expected = "Notification about user-related operation (status: SUCCESS)\n"
+ "\n"
+ "User: Jack Sparrow (jack, oid c0c010c0-d34d-b33f-f00d-111111111111)\n"
+ "\n"
+ "The user record was modified. Modified attributes are:\n"
+ " - Assignment:\n"
+ " - ADD: \n"
+ " - Target: Superuser (role)\n"
+ "\n"
+ "Channel: ";
assertEquals("Wrong message body", expected, dummyTransport.getMessages("dummy:simpleUserNotifier").get(0).getBody());

}

@Test
public void test200SendSmsUsingGet() {
final String TEST_NAME = "test200SendSmsUsingGet";
Expand Down

0 comments on commit 6445476

Please sign in to comment.