|
32 | 32 | import pl.edu.icm.unity.base.attribute.AttributeExt; |
33 | 33 | import pl.edu.icm.unity.base.attribute.AttributeType; |
34 | 34 | import pl.edu.icm.unity.base.entity.Entity; |
| 35 | +import pl.edu.icm.unity.base.entity.EntityInformation; |
35 | 36 | import pl.edu.icm.unity.base.entity.EntityParam; |
| 37 | +import pl.edu.icm.unity.base.entity.EntityState; |
36 | 38 | import pl.edu.icm.unity.base.exceptions.EngineException; |
37 | 39 | import pl.edu.icm.unity.base.group.Group; |
38 | 40 | import pl.edu.icm.unity.base.group.GroupContents; |
@@ -255,7 +257,7 @@ public void shouldGetGroupMembersWithExtraAttrs() throws EngineException |
255 | 257 | .thenReturn(new Entity( |
256 | 258 | Arrays.asList(new Identity(EmailIdentity.ID, "demo@demo.com", 1, |
257 | 259 | new UsernameIdentity().getComparableValue("", "", ""))), |
258 | | - null, null)); |
| 260 | + new EntityInformation(1), null)); |
259 | 261 |
|
260 | 262 | when(mockGroupMan.getContents(any(), anyInt())).thenReturn(con); |
261 | 263 | when(mockGroupMan.getContents(any(), anyInt())).thenReturn(con); |
@@ -289,6 +291,43 @@ public void shouldGetGroupMembersWithExtraAttrs() throws EngineException |
289 | 291 | assertThat(firstMember.attributes.iterator().next().getValues().iterator().next()).isEqualTo("extraValue"); |
290 | 292 |
|
291 | 293 | } |
| 294 | + |
| 295 | + @Test |
| 296 | + public void shouldSkipDisabledEntity() throws EngineException |
| 297 | + { |
| 298 | + |
| 299 | + GroupContents con = getConfiguredGroupContents("/project"); |
| 300 | + GroupMembership member1 = new GroupMembership("/project", 1L, new Date()); |
| 301 | + GroupMembership member2 = new GroupMembership("/project", 2L, new Date()); |
| 302 | + |
| 303 | + con.setMembers(List.of(member1, member2)); |
| 304 | + con.getGroup().setDelegationConfiguration(new GroupDelegationConfiguration(true, false, null, null, null, null, |
| 305 | + Arrays.asList("extraAttr"), List.of())); |
| 306 | + |
| 307 | + EntityInformation disabledEntityInfo = new EntityInformation(1); |
| 308 | + disabledEntityInfo.setState(EntityState.disabled); |
| 309 | + |
| 310 | + when(mockIdMan.getEntity(new EntityParam(1L))) |
| 311 | + .thenReturn(new Entity( |
| 312 | + Arrays.asList(new Identity(EmailIdentity.ID, "demo@demo.com", 1, |
| 313 | + new UsernameIdentity().getComparableValue("", "", ""))), |
| 314 | + disabledEntityInfo, null)); |
| 315 | + |
| 316 | + when(mockIdMan.getEntity(new EntityParam(2L))) |
| 317 | + .thenReturn(new Entity( |
| 318 | + Arrays.asList(new Identity(EmailIdentity.ID, "demo2@demo.com", 2, |
| 319 | + new UsernameIdentity().getComparableValue("", "", ""))), |
| 320 | + new EntityInformation(2L), null)); |
| 321 | + |
| 322 | + when(mockGroupMan.getContents(any(), anyInt())).thenReturn(con); |
| 323 | + when(mockGroupMan.getContents(any(), anyInt())).thenReturn(con); |
| 324 | + |
| 325 | + List<DelegatedGroupMember> delegatedGroupMemebers = dGroupManNoAuthz.getDelegatedGroupMembers("/project", |
| 326 | + "/project"); |
| 327 | + |
| 328 | + assertThat(delegatedGroupMemebers.size()).isEqualTo(1); |
| 329 | + assertThat(delegatedGroupMemebers.iterator().next().entityId).isEqualTo(2L); |
| 330 | + } |
292 | 331 |
|
293 | 332 | @Test |
294 | 333 | public void shouldForbidGetDisplayNameOfNonProjectAttribute() throws EngineException |
@@ -363,7 +402,7 @@ public void shouldForbidRemoveLastManagerInProjectGroup() throws EngineException |
363 | 402 | .thenReturn(new Entity( |
364 | 403 | Arrays.asList(new Identity(UsernameIdentity.ID, "xx", 1, |
365 | 404 | new UsernameIdentity().getComparableValue("", "", ""))), |
366 | | - null, null)); |
| 405 | + new EntityInformation(1), null)); |
367 | 406 |
|
368 | 407 | when(mockGroupMan.getContents(eq("/project"), anyInt())) |
369 | 408 | .thenReturn(getEnabledGroupContentsWithDefaultMember("/project")); |
|
0 commit comments