mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-12 16:35:45 +01:00
added some permission tests to RepositoryExtendedITCase
This commit is contained in:
@@ -35,7 +35,8 @@ package sonia.scm.it;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
@@ -43,10 +44,11 @@ import org.junit.runners.Parameterized;
|
||||
import sonia.scm.repository.Repository;
|
||||
import sonia.scm.repository.client.RepositoryClient;
|
||||
import sonia.scm.repository.client.RepositoryClientException;
|
||||
import sonia.scm.repository.client.RepositoryClientFactory;
|
||||
import sonia.scm.user.User;
|
||||
import sonia.scm.util.IOUtil;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import static sonia.scm.it.IntegrationTestUtil.*;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
@@ -70,16 +72,68 @@ public class RepositoryExtendedITCase extends RepositoryITCaseBase
|
||||
* @param owner
|
||||
* @param write
|
||||
* @param read
|
||||
* @param noperm
|
||||
* @param password
|
||||
*/
|
||||
public RepositoryExtendedITCase(Repository repository, User owner,
|
||||
User write, User read, String password)
|
||||
User write, User read, User noperm,
|
||||
String password)
|
||||
{
|
||||
super(repository, owner, write, read, password);
|
||||
super(repository, owner, write, read, noperm, password);
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
@After
|
||||
public void cleanupTest() throws IOException
|
||||
{
|
||||
IOUtil.delete(directory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @throws RepositoryClientException
|
||||
*/
|
||||
@Test(expected = RepositoryClientException.class)
|
||||
public void readFailed() throws RepositoryClientException
|
||||
{
|
||||
RepositoryClient rc = createRepositoryClient(nopermUser, directory);
|
||||
|
||||
rc.checkout();
|
||||
|
||||
// ugly workaround
|
||||
if (repository.getType().equals("git"))
|
||||
{
|
||||
for (File f : directory.listFiles())
|
||||
{
|
||||
if (!".git".equals(f.getName()))
|
||||
{
|
||||
fail("checkout works");
|
||||
}
|
||||
}
|
||||
|
||||
throw new RepositoryClientException("checkout failed");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*/
|
||||
@Before
|
||||
public void setupTest()
|
||||
{
|
||||
directory = createTempDirectory();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -90,20 +144,9 @@ public class RepositoryExtendedITCase extends RepositoryITCaseBase
|
||||
@Test
|
||||
public void simpleRead() throws RepositoryClientException, IOException
|
||||
{
|
||||
File directory = createTempDirectory();
|
||||
RepositoryClient rc = createRepositoryClient(readUser, directory);
|
||||
|
||||
try
|
||||
{
|
||||
RepositoryClient rc =
|
||||
RepositoryClientFactory.createClient(repository.getType(), directory,
|
||||
repository.getUrl(), readUser.getName(), password);
|
||||
|
||||
rc.checkout();
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtil.delete(directory);
|
||||
}
|
||||
rc.checkout();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -117,20 +160,31 @@ public class RepositoryExtendedITCase extends RepositoryITCaseBase
|
||||
@Test
|
||||
public void simpleWrite() throws RepositoryClientException, IOException
|
||||
{
|
||||
File directory = createTempDirectory();
|
||||
RepositoryClient rc = createRepositoryClient(writeUser, directory);
|
||||
|
||||
try
|
||||
{
|
||||
RepositoryClient rc =
|
||||
RepositoryClientFactory.createClient(repository.getType(), directory,
|
||||
repository.getUrl(), writeUser.getName(), password);
|
||||
|
||||
rc.checkout();
|
||||
addTestFiles(rc);
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtil.delete(directory);
|
||||
}
|
||||
rc.checkout();
|
||||
addTestFiles(rc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryClientException
|
||||
*/
|
||||
@Test(expected = RepositoryClientException.class)
|
||||
public void writeFailed() throws RepositoryClientException, IOException
|
||||
{
|
||||
RepositoryClient rc = createRepositoryClient(readUser, directory);
|
||||
|
||||
rc.checkout();
|
||||
addTestFiles(rc);
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private File directory;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user