mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-06-17 15:51:37 +02:00
add securityV1Migration-Test
This commit is contained in:
@@ -56,6 +56,13 @@ class XmlSecurityV1UpdateStepTest {
|
||||
copyTestDatabaseFile(configDir, "config.xml");
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
void createSecurityV1XML(@TempDirectory.TempDir Path tempDir) throws IOException {
|
||||
Path configDir = tempDir.resolve("config");
|
||||
Files.createDirectories(configDir);
|
||||
copyTestDatabaseFile(configDir, "securityV1.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldCreatePermissionForUsersConfiguredAsAdmin() throws JAXBException {
|
||||
updateStep.doUpdate();
|
||||
@@ -81,6 +88,19 @@ class XmlSecurityV1UpdateStepTest {
|
||||
.collect(toList());
|
||||
assertThat(assignedPermission).contains("admins", "vogons");
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldMapV1PermissionsFromSecurityV1XML() throws JAXBException {
|
||||
updateStep.doUpdate();
|
||||
List<String> assignedPermission =
|
||||
assignedPermissionStore.getAll().values()
|
||||
.stream()
|
||||
.filter(a -> a.getPermission().getValue().contains("repository:"))
|
||||
.map(AssignedPermission::getName)
|
||||
.collect(toList());
|
||||
assertThat(assignedPermission).contains("scmadmin");
|
||||
assertThat(assignedPermission).contains("test");
|
||||
}
|
||||
}
|
||||
|
||||
private void copyTestDatabaseFile(Path configDir, String fileName) throws IOException {
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" ?>
|
||||
<configuration>
|
||||
<entry>
|
||||
<key>4lRWOA7DH1</key>
|
||||
<value>
|
||||
<group-permission>false</group-permission>
|
||||
<name>scmadmin</name>
|
||||
<permission>repository:*:READ</permission>
|
||||
</value>
|
||||
</entry>
|
||||
<entry>
|
||||
<key>CfRWOAANM2</key>
|
||||
<value>
|
||||
<group-permission>true</group-permission>
|
||||
<name>test</name>
|
||||
<permission>repository:*:OWNER</permission>
|
||||
</value>
|
||||
</entry>
|
||||
</configuration>
|
||||
Reference in New Issue
Block a user