public void testNotAuthenticated()
{
{
// assuming @RolesAllowed is on class level. Too lazy to test it all!
String newUser = "{ \"user\" : { \"username\" : \"wburke\", \"name\" : \"Bill Burke\", \"email\" : \"bburke@redhat.com\", \"enabled\" : true, \"credentials\" : { \"password\" : \"geheim\" }} }";
ResteasyClient client = new ResteasyClientBuilder().providerFactory(deployment.getProviderFactory()).build();
Response response = client.target(generateURL("/users")).request().post(Entity.json(newUser));
Assert.assertEquals(response.getStatus(), 403);
response.close();
client.close();
}
{
String newRole = "{ \"role\" : { \"name\" : \"admin\"} }";
ResteasyClient client = new ResteasyClientBuilder().providerFactory(deployment.getProviderFactory()).build();
Response response = client.target(generateURL("/roles")).request().post(Entity.json(newRole));
Assert.assertEquals(response.getStatus(), 403);
response.close();
client.close();
}
{
String newProject = "{ \"project\" : { \"id\" : \"5\", \"name\" : \"Resteasy\", \"description\" : \"The Best of REST\", \"enabled\" : true } }";
ResteasyClient client = new ResteasyClientBuilder().providerFactory(deployment.getProviderFactory()).build();
Response response = client.target(generateURL("/projects")).request().post(Entity.json(newProject));
Assert.assertEquals(response.getStatus(), 403);
response.close();
client.close();
}