-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add field impersonationAllowedFor to autoCreateTestUsers (#738)
This closes #723
- Loading branch information
Showing
6 changed files
with
111 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
...c/test/java/biz/netcentric/cq/tools/actool/configmodel/AutoCreateTestUsersConfigTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package biz.netcentric.cq.tools.actool.configmodel; | ||
|
||
/*- | ||
* #%L | ||
* Access Control Tool Bundle | ||
* %% | ||
* Copyright (C) 2015 - 2024 Cognizant Netcentric | ||
* %% | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* #L% | ||
*/ | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.*; | ||
|
||
import static biz.netcentric.cq.tools.actool.configmodel.AutoCreateTestUsersConfig.*; | ||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class AutoCreateTestUsersConfigTest { | ||
|
||
@Test | ||
void shouldNotContainImpersonalizationAllowedFor() { | ||
Map<String, Object> configMap = initializeConfigMap(null); | ||
assertEquals(new ArrayList<>(), (new AutoCreateTestUsersConfig(configMap)).getImpersonationAllowedFor()); | ||
} | ||
|
||
@Test() | ||
void shouldNotContainImpersonalizationAllowedFor2() { | ||
Map<String, Object> configMap = initializeConfigMap("invalidValue"); | ||
Exception exception = assertThrows(IllegalArgumentException.class, () -> { | ||
new AutoCreateTestUsersConfig(configMap); | ||
}); | ||
assertEquals("Property \"" + KEY_IMPERSONATION_ALLOWED_FOR + "\" must be a list", exception.getMessage()); | ||
} | ||
@Test | ||
void shouldNotImpersonalizationAllowedFor() { | ||
Map<String, Object> map = initializeConfigMap(Arrays.asList("user1")); | ||
assertEquals(Arrays.asList("user1"), (new AutoCreateTestUsersConfig(map)).getImpersonationAllowedFor()); | ||
} | ||
|
||
@NotNull | ||
private static Map<String, Object> initializeConfigMap(Object allowedFor) { | ||
Map<String, Object> map = new HashMap<>(); | ||
map.put(KEY_PATH, "/"); | ||
map.put(KEY_PREFIX, "prefix"); | ||
map.put(KEY_CREATE_FOR_GROUP_NAMES_REG_EX, ""); | ||
map.put(KEY_IMPERSONATION_ALLOWED_FOR, allowedFor); | ||
return map; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters