mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-14 17:26:22 +01:00
added integration tests for modify repositories
This commit is contained in:
@@ -46,8 +46,6 @@ import sonia.scm.user.User;
|
|||||||
|
|
||||||
import com.sun.jersey.api.client.Client;
|
import com.sun.jersey.api.client.Client;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Sebastian Sdorra
|
* @author Sebastian Sdorra
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ public class JerseyRepositoryClientHandler implements RepositoryClientHandler
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
response = resource.post(ClientResponse.class, repository);
|
response = resource.put(ClientResponse.class, repository);
|
||||||
ClientUtil.checkResponse(response, 204);
|
ClientUtil.checkResponse(response, 204);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
|||||||
@@ -177,4 +177,69 @@ public class JerseyClientRepositoryClientHandlerITCase
|
|||||||
session.close();
|
session.close();
|
||||||
setAnonymousAccess(false);
|
setAnonymousAccess(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testEnabledModifyAnonymous()
|
||||||
|
{
|
||||||
|
setAnonymousAccess(true);
|
||||||
|
|
||||||
|
JerseyClientSession session = createAdminSession();
|
||||||
|
Repository rateotu =
|
||||||
|
RepositoryTestData.createRestaurantAtTheEndOfTheUniverse(REPOSITORY_TYPE);
|
||||||
|
|
||||||
|
session.getRepositoryHandler().create(rateotu);
|
||||||
|
session.close();
|
||||||
|
session = createAnonymousSession();
|
||||||
|
rateotu.setDescription("Modify Test");
|
||||||
|
|
||||||
|
boolean notfound = false;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
session.getRepositoryHandler().modify(rateotu);
|
||||||
|
}
|
||||||
|
catch (ScmForbiddenException ex)
|
||||||
|
{
|
||||||
|
notfound = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
setAnonymousAccess(false);
|
||||||
|
session.close();
|
||||||
|
session = createAdminSession();
|
||||||
|
session.getRepositoryHandler().delete(rateotu);
|
||||||
|
session.close();
|
||||||
|
assertTrue(notfound);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testModify()
|
||||||
|
{
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
|
JerseyClientSession session = createAdminSession();
|
||||||
|
Repository rateotu =
|
||||||
|
RepositoryTestData.createRestaurantAtTheEndOfTheUniverse(REPOSITORY_TYPE);
|
||||||
|
RepositoryClientHandler handler = session.getRepositoryHandler();
|
||||||
|
|
||||||
|
handler.create(rateotu);
|
||||||
|
assertNotNull(rateotu.getId());
|
||||||
|
assertNotNull(rateotu.getCreationDate());
|
||||||
|
rateotu.setDescription("Modify Test");
|
||||||
|
handler.modify(rateotu);
|
||||||
|
rateotu = handler.get(rateotu.getId());
|
||||||
|
assertNotNull(rateotu);
|
||||||
|
assertEquals(rateotu.getDescription(), "Modify Test");
|
||||||
|
assertNotNull(rateotu.getLastModified());
|
||||||
|
assertTrue(rateotu.getLastModified() > start);
|
||||||
|
assertTrue(rateotu.getLastModified() < System.currentTimeMillis());
|
||||||
|
handler.delete(rateotu);
|
||||||
|
session.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user