mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-15 17:56:17 +01:00
improve repository tests
This commit is contained in:
@@ -50,6 +50,7 @@ import sonia.scm.repository.client.RepositoryClientFactory;
|
|||||||
import sonia.scm.user.User;
|
import sonia.scm.user.User;
|
||||||
import sonia.scm.user.UserTestData;
|
import sonia.scm.user.UserTestData;
|
||||||
import sonia.scm.util.IOUtil;
|
import sonia.scm.util.IOUtil;
|
||||||
|
import sonia.scm.util.Util;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
@@ -220,36 +221,7 @@ public class RepositoryITCaseBase
|
|||||||
|
|
||||||
for (Type t : state.getRepositoryTypes())
|
for (Type t : state.getRepositoryTypes())
|
||||||
{
|
{
|
||||||
if (t.getName().equals("git"))
|
appendTestParemeter(params, t.getName(), owner, write, read, noperm);
|
||||||
{
|
|
||||||
Repository gitRepository = createTestRepository("git", owner, write,
|
|
||||||
read);
|
|
||||||
|
|
||||||
params.add(new Object[]
|
|
||||||
{
|
|
||||||
gitRepository, owner, write, read, noperm, "secret"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else if (t.getName().equals("svn"))
|
|
||||||
{
|
|
||||||
Repository svnRepository = createTestRepository("svn", owner, write,
|
|
||||||
read);
|
|
||||||
|
|
||||||
params.add(new Object[]
|
|
||||||
{
|
|
||||||
svnRepository, owner, write, read, noperm, "secret"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else if (t.getName().equals("hg"))
|
|
||||||
{
|
|
||||||
Repository hgRepository = createTestRepository("hg", owner, write,
|
|
||||||
read);
|
|
||||||
|
|
||||||
params.add(new Object[]
|
|
||||||
{
|
|
||||||
hgRepository, owner, write, read, noperm, "secret"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return params;
|
return params;
|
||||||
@@ -259,6 +231,40 @@ public class RepositoryITCaseBase
|
|||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
|
* @param params
|
||||||
|
* @param type
|
||||||
|
* @param owner
|
||||||
|
* @param write
|
||||||
|
* @param read
|
||||||
|
* @param noperm
|
||||||
|
*
|
||||||
|
* @throws IOException
|
||||||
|
* @throws RepositoryClientException
|
||||||
|
*/
|
||||||
|
private static void appendTestParemeter(Collection<Object[]> params,
|
||||||
|
String type, User owner, User write, User read, User noperm)
|
||||||
|
throws RepositoryClientException, IOException
|
||||||
|
{
|
||||||
|
Repository repository = createTestRepository(null, type, owner, write,
|
||||||
|
read);
|
||||||
|
|
||||||
|
params.add(new Object[]
|
||||||
|
{
|
||||||
|
repository, owner, write, read, noperm, "secret"
|
||||||
|
});
|
||||||
|
repository = createTestRepository("test", type, owner, write, read);
|
||||||
|
params.add(new Object[]
|
||||||
|
{
|
||||||
|
repository, owner, write, read, noperm, "secret"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param prefix
|
||||||
* @param type
|
* @param type
|
||||||
* @param owner
|
* @param owner
|
||||||
* @param write
|
* @param write
|
||||||
@@ -269,13 +275,18 @@ public class RepositoryITCaseBase
|
|||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws RepositoryClientException
|
* @throws RepositoryClientException
|
||||||
*/
|
*/
|
||||||
private static Repository createTestRepository(String type, User owner,
|
private static Repository createTestRepository(String prefix, String type,
|
||||||
User write, User read)
|
User owner, User write, User read)
|
||||||
throws RepositoryClientException, IOException
|
throws RepositoryClientException, IOException
|
||||||
{
|
{
|
||||||
Client client = createAdminClient();
|
Client client = createAdminClient();
|
||||||
Repository repository = RepositoryTestData.createHeartOfGold(type);
|
Repository repository = RepositoryTestData.createHeartOfGold(type);
|
||||||
|
|
||||||
|
if (Util.isNotEmpty(prefix))
|
||||||
|
{
|
||||||
|
repository.setName(prefix.concat("/").concat(repository.getName()));
|
||||||
|
}
|
||||||
|
|
||||||
//J-
|
//J-
|
||||||
repository.setPermissions(Arrays.asList(
|
repository.setPermissions(Arrays.asList(
|
||||||
new Permission(owner.getName(), PermissionType.OWNER),
|
new Permission(owner.getName(), PermissionType.OWNER),
|
||||||
|
|||||||
Reference in New Issue
Block a user