Ejemplo n.º 1
0
  @Test
  public void should_remove_group_permission_with_null_name() throws Exception {
    setupData("removeNullGroupPermissionFromTemplate");
    permissionDao.removeGroupPermission(1L, null, "permission_to_remove");

    checkTable(
        "removeNullGroupPermissionFromTemplate",
        "permission_templates",
        "id",
        "name",
        "description");
    checkTable(
        "removeNullGroupPermissionFromTemplate",
        "perm_templates_users",
        "id",
        "template_id",
        "user_id",
        "permission_reference");
    checkTable(
        "removeNullGroupPermissionFromTemplate",
        "perm_templates_groups",
        "id",
        "template_id",
        "group_id",
        "permission_reference");
  }
Ejemplo n.º 2
0
  @Test
  public void should_update_permission_template() throws Exception {
    setupData("updatePermissionTemplate");

    permissionDao.updatePermissionTemplate(1L, "new_name", "new_description");

    checkTable(
        "updatePermissionTemplate", "permission_templates", "id", "name", "kee", "description");
  }
Ejemplo n.º 3
0
 @Test
 public void should_create_permission_template() throws Exception {
   setupData("createPermissionTemplate");
   PermissionTemplateDto permissionTemplate =
       permissionDao.createPermissionTemplate("my template", "my description");
   assertThat(permissionTemplate).isNotNull();
   assertThat(permissionTemplate.getId()).isEqualTo(1L);
   checkTable(
       "createPermissionTemplate", "permission_templates", "id", "name", "kee", "description");
 }
Ejemplo n.º 4
0
  @Test
  public void should_add_group_permission_to_template() throws Exception {
    setupData("addGroupPermissionToTemplate");
    permissionDao.addGroupPermission(1L, 1L, "new_permission");

    checkTable("addGroupPermissionToTemplate", "permission_templates", "id", "name", "description");
    checkTable(
        "addGroupPermissionToTemplate",
        "perm_templates_users",
        "id",
        "template_id",
        "user_id",
        "permission_reference");
    checkTable(
        "addGroupPermissionToTemplate",
        "perm_templates_groups",
        "id",
        "template_id",
        "group_id",
        "permission_reference");
  }
Ejemplo n.º 5
0
  @Test
  public void should_remove_user_permission_from_template() throws Exception {
    setupData("removeUserPermissionFromTemplate");
    permissionDao.removeUserPermission(1L, 2L, "permission_to_remove");

    checkTable(
        "removeUserPermissionFromTemplate", "permission_templates", "id", "name", "description");
    checkTable(
        "removeUserPermissionFromTemplate",
        "perm_templates_users",
        "id",
        "template_id",
        "user_id",
        "permission_reference");
    checkTable(
        "removeUserPermissionFromTemplate",
        "perm_templates_groups",
        "id",
        "template_id",
        "group_id",
        "permission_reference");
  }
Ejemplo n.º 6
0
  @Test
  public void should_delete_permission_template() throws Exception {
    setupData("deletePermissionTemplate");

    permissionDao.deletePermissionTemplate(1L);

    checkTable("deletePermissionTemplate", "permission_templates", "id", "name", "description");
    checkTable(
        "deletePermissionTemplate",
        "perm_templates_users",
        "id",
        "template_id",
        "user_id",
        "permission_reference");
    checkTable(
        "deletePermissionTemplate",
        "perm_templates_groups",
        "id",
        "template_id",
        "group_id",
        "permission_reference");
  }
Ejemplo n.º 7
0
 @Test
 public void should_normalize_kee_on_template_creation() throws Exception {
   setupData("createNonAsciiPermissionTemplate");
   PermissionTemplateDto permissionTemplate =
       permissionDao.createPermissionTemplate("Môü Gnô Gnèçàß", "my description");
   assertThat(permissionTemplate).isNotNull();
   assertThat(permissionTemplate.getId()).isEqualTo(1L);
   checkTable(
       "createNonAsciiPermissionTemplate",
       "permission_templates",
       "id",
       "name",
       "kee",
       "description");
 }