mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-07-15 12:41:41 +02:00
Merge with default
This commit is contained in:
@@ -72,7 +72,13 @@
|
||||
|
||||
<dependency>
|
||||
<groupId>org.jboss.resteasy</groupId>
|
||||
<artifactId>resteasy-jaxrs</artifactId>
|
||||
<artifactId>resteasy-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.jboss.resteasy</groupId>
|
||||
<artifactId>resteasy-core-spi</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
@@ -70,6 +70,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import static java.util.Optional.empty;
|
||||
import static sonia.scm.ContextEntry.ContextBuilder.entity;
|
||||
import static sonia.scm.NotFoundException.notFound;
|
||||
|
||||
@@ -209,7 +210,7 @@ public class GitBrowseCommand extends AbstractGitCommand
|
||||
logger.trace("fetch last commit for {} at {}", path, revId.getName());
|
||||
RevCommit commit = getLatestCommit(repo, revId, path);
|
||||
|
||||
Optional<LfsPointer> lfsPointer = GitUtil.getLfsPointer(repo, path, commit, treeWalk);
|
||||
Optional<LfsPointer> lfsPointer = commit == null? empty(): GitUtil.getLfsPointer(repo, path, commit, treeWalk);
|
||||
|
||||
if (lfsPointer.isPresent()) {
|
||||
BlobStore lfsBlobStore = lfsBlobStoreFactory.getLfsBlobStore(repository);
|
||||
|
||||
@@ -2,14 +2,11 @@ package sonia.scm.api.v2.resources;
|
||||
|
||||
import com.github.sdorra.shiro.ShiroRule;
|
||||
import com.github.sdorra.shiro.SubjectAware;
|
||||
import org.jboss.resteasy.core.Dispatcher;
|
||||
import org.jboss.resteasy.mock.MockDispatcherFactory;
|
||||
import org.jboss.resteasy.mock.MockHttpRequest;
|
||||
import org.jboss.resteasy.mock.MockHttpResponse;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Answers;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
@@ -27,6 +24,7 @@ import sonia.scm.repository.RepositoryManager;
|
||||
import sonia.scm.store.ConfigurationStore;
|
||||
import sonia.scm.store.ConfigurationStoreFactory;
|
||||
import sonia.scm.web.GitVndMediaType;
|
||||
import sonia.scm.web.RestDispatcher;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
@@ -52,10 +50,7 @@ public class GitConfigResourceTest {
|
||||
@Rule
|
||||
public ShiroRule shiro = new ShiroRule();
|
||||
|
||||
@Rule
|
||||
public ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
private Dispatcher dispatcher = MockDispatcherFactory.createDispatcher();
|
||||
private RestDispatcher dispatcher = new RestDispatcher();
|
||||
|
||||
private final URI baseUri = URI.create("/");
|
||||
|
||||
@@ -89,7 +84,7 @@ public class GitConfigResourceTest {
|
||||
when(repositoryHandler.getConfig()).thenReturn(gitConfig);
|
||||
GitRepositoryConfigResource gitRepositoryConfigResource = new GitRepositoryConfigResource(repositoryConfigMapper, repositoryManager, new GitRepositoryConfigStoreProvider(configurationStoreFactory));
|
||||
GitConfigResource gitConfigResource = new GitConfigResource(dtoToConfigMapper, configToDtoMapper, repositoryHandler, of(gitRepositoryConfigResource));
|
||||
dispatcher.getRegistry().addSingletonResource(gitConfigResource);
|
||||
dispatcher.addSingletonResource(gitConfigResource);
|
||||
when(scmPathInfoStore.get().getApiRestUri()).thenReturn(baseUri);
|
||||
}
|
||||
|
||||
@@ -137,10 +132,11 @@ public class GitConfigResourceTest {
|
||||
|
||||
@Test
|
||||
@SubjectAware(username = "writeOnly")
|
||||
public void shouldNotGetConfigWhenNotAuthorized() throws URISyntaxException {
|
||||
thrown.expectMessage("Subject does not have permission [configuration:read:git]");
|
||||
public void shouldNotGetConfigWhenNotAuthorized() throws URISyntaxException, UnsupportedEncodingException {
|
||||
MockHttpResponse response = get();
|
||||
|
||||
get();
|
||||
assertEquals("Subject does not have permission [configuration:read:git]", response.getContentAsString());
|
||||
assertEquals(HttpServletResponse.SC_FORBIDDEN, response.getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -152,10 +148,11 @@ public class GitConfigResourceTest {
|
||||
|
||||
@Test
|
||||
@SubjectAware(username = "readOnly")
|
||||
public void shouldNotUpdateConfigWhenNotAuthorized() throws URISyntaxException {
|
||||
thrown.expectMessage("Subject does not have permission [configuration:write:git]");
|
||||
public void shouldNotUpdateConfigWhenNotAuthorized() throws URISyntaxException, UnsupportedEncodingException {
|
||||
MockHttpResponse response = put();
|
||||
|
||||
put();
|
||||
assertEquals("Subject does not have permission [configuration:write:git]", response.getContentAsString());
|
||||
assertEquals(HttpServletResponse.SC_FORBIDDEN, response.getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -2,14 +2,11 @@ package sonia.scm.api.v2.resources;
|
||||
|
||||
import com.github.sdorra.shiro.ShiroRule;
|
||||
import com.github.sdorra.shiro.SubjectAware;
|
||||
import org.jboss.resteasy.core.Dispatcher;
|
||||
import org.jboss.resteasy.mock.MockDispatcherFactory;
|
||||
import org.jboss.resteasy.mock.MockHttpRequest;
|
||||
import org.jboss.resteasy.mock.MockHttpResponse;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.InjectMocks;
|
||||
@@ -18,12 +15,15 @@ import org.mockito.junit.MockitoJUnitRunner;
|
||||
import sonia.scm.repository.HgConfig;
|
||||
import sonia.scm.repository.HgRepositoryHandler;
|
||||
import sonia.scm.web.HgVndMediaType;
|
||||
import sonia.scm.web.RestDispatcher;
|
||||
|
||||
import javax.inject.Provider;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@@ -37,10 +37,7 @@ public class HgConfigAutoConfigurationResourceTest {
|
||||
@Rule
|
||||
public ShiroRule shiro = new ShiroRule();
|
||||
|
||||
@Rule
|
||||
public ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
private Dispatcher dispatcher = MockDispatcherFactory.createDispatcher();
|
||||
private RestDispatcher dispatcher = new RestDispatcher();
|
||||
|
||||
@InjectMocks
|
||||
private HgConfigDtoToHgConfigMapperImpl dtoToConfigMapper;
|
||||
@@ -57,7 +54,7 @@ public class HgConfigAutoConfigurationResourceTest {
|
||||
new HgConfigAutoConfigurationResource(dtoToConfigMapper, repositoryHandler);
|
||||
|
||||
when(resourceProvider.get()).thenReturn(resource);
|
||||
dispatcher.getRegistry().addSingletonResource(
|
||||
dispatcher.addSingletonResource(
|
||||
new HgConfigResource(null, null, null, null,
|
||||
resourceProvider, null));
|
||||
}
|
||||
@@ -76,9 +73,10 @@ public class HgConfigAutoConfigurationResourceTest {
|
||||
@Test
|
||||
@SubjectAware(username = "readOnly")
|
||||
public void shouldNotSetDefaultConfigAndInstallHgWhenNotAuthorized() throws Exception {
|
||||
thrown.expectMessage("Subject does not have permission [configuration:write:hg]");
|
||||
MockHttpResponse response = put(null);
|
||||
|
||||
put(null);
|
||||
assertEquals("Subject does not have permission [configuration:write:hg]", response.getContentAsString());
|
||||
assertEquals(HttpServletResponse.SC_FORBIDDEN, response.getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -95,9 +93,10 @@ public class HgConfigAutoConfigurationResourceTest {
|
||||
@Test
|
||||
@SubjectAware(username = "readOnly")
|
||||
public void shouldNotUpdateConfigAndInstallHgWhenNotAuthorized() throws Exception {
|
||||
thrown.expectMessage("Subject does not have permission [configuration:write:hg]");
|
||||
MockHttpResponse response = put("{\"disabled\":true}");
|
||||
|
||||
put("{\"disabled\":true}");
|
||||
assertEquals("Subject does not have permission [configuration:write:hg]", response.getContentAsString());
|
||||
assertEquals(HttpServletResponse.SC_FORBIDDEN, response.getStatus());
|
||||
}
|
||||
|
||||
private MockHttpResponse put(String content) throws URISyntaxException {
|
||||
|
||||
@@ -2,19 +2,17 @@ package sonia.scm.api.v2.resources;
|
||||
|
||||
import com.github.sdorra.shiro.ShiroRule;
|
||||
import com.github.sdorra.shiro.SubjectAware;
|
||||
import org.jboss.resteasy.core.Dispatcher;
|
||||
import org.jboss.resteasy.mock.MockDispatcherFactory;
|
||||
import org.jboss.resteasy.mock.MockHttpRequest;
|
||||
import org.jboss.resteasy.mock.MockHttpResponse;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Answers;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import sonia.scm.web.RestDispatcher;
|
||||
|
||||
import javax.inject.Provider;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@@ -35,10 +33,7 @@ public class HgConfigInstallationsResourceTest {
|
||||
@Rule
|
||||
public ShiroRule shiro = new ShiroRule();
|
||||
|
||||
@Rule
|
||||
public ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
private Dispatcher dispatcher = MockDispatcherFactory.createDispatcher();
|
||||
private RestDispatcher dispatcher = new RestDispatcher();
|
||||
|
||||
private final URI baseUri = URI.create("/");
|
||||
|
||||
@@ -57,7 +52,7 @@ public class HgConfigInstallationsResourceTest {
|
||||
HgConfigInstallationsResource resource = new HgConfigInstallationsResource(mapper);
|
||||
|
||||
when(resourceProvider.get()).thenReturn(resource);
|
||||
dispatcher.getRegistry().addSingletonResource(
|
||||
dispatcher.addSingletonResource(
|
||||
new HgConfigResource(null, null, null, null,
|
||||
null, resourceProvider));
|
||||
|
||||
@@ -82,9 +77,10 @@ public class HgConfigInstallationsResourceTest {
|
||||
@Test
|
||||
@SubjectAware(username = "writeOnly")
|
||||
public void shouldNotGetHgInstallationsWhenNotAuthorized() throws Exception {
|
||||
thrown.expectMessage("Subject does not have permission [configuration:read:hg]");
|
||||
MockHttpResponse response = get("hg");
|
||||
|
||||
get("hg");
|
||||
assertEquals("Subject does not have permission [configuration:read:hg]", response.getContentAsString());
|
||||
assertEquals(HttpServletResponse.SC_FORBIDDEN, response.getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -104,9 +100,10 @@ public class HgConfigInstallationsResourceTest {
|
||||
@Test
|
||||
@SubjectAware(username = "writeOnly")
|
||||
public void shouldNotGetPythonInstallationsWhenNotAuthorized() throws Exception {
|
||||
thrown.expectMessage("Subject does not have permission [configuration:read:hg]");
|
||||
MockHttpResponse response = get("python");
|
||||
|
||||
get("python");
|
||||
assertEquals("Subject does not have permission [configuration:read:hg]", response.getContentAsString());
|
||||
assertEquals(HttpServletResponse.SC_FORBIDDEN, response.getStatus());
|
||||
}
|
||||
|
||||
private MockHttpResponse get(String path) throws URISyntaxException {
|
||||
|
||||
@@ -5,14 +5,11 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import com.github.sdorra.shiro.ShiroRule;
|
||||
import com.github.sdorra.shiro.SubjectAware;
|
||||
import org.jboss.resteasy.core.Dispatcher;
|
||||
import org.jboss.resteasy.mock.MockDispatcherFactory;
|
||||
import org.jboss.resteasy.mock.MockHttpRequest;
|
||||
import org.jboss.resteasy.mock.MockHttpResponse;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Answers;
|
||||
import org.mockito.InjectMocks;
|
||||
@@ -23,6 +20,7 @@ import sonia.scm.installer.HgPackageReader;
|
||||
import sonia.scm.net.ahc.AdvancedHttpClient;
|
||||
import sonia.scm.repository.HgConfig;
|
||||
import sonia.scm.repository.HgRepositoryHandler;
|
||||
import sonia.scm.web.RestDispatcher;
|
||||
|
||||
import javax.inject.Provider;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@@ -49,10 +47,7 @@ public class HgConfigPackageResourceTest {
|
||||
@Rule
|
||||
public ShiroRule shiro = new ShiroRule();
|
||||
|
||||
@Rule
|
||||
public ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
private Dispatcher dispatcher = MockDispatcherFactory.createDispatcher();
|
||||
private RestDispatcher dispatcher = new RestDispatcher();
|
||||
|
||||
private final URI baseUri = java.net.URI.create("/");
|
||||
|
||||
@@ -113,9 +108,10 @@ public class HgConfigPackageResourceTest {
|
||||
@Test
|
||||
@SubjectAware(username = "writeOnly")
|
||||
public void shouldNotGetPackagesWhenNotAuthorized() throws Exception {
|
||||
thrown.expectMessage("Subject does not have permission [configuration:read:hg]");
|
||||
MockHttpResponse response = get();
|
||||
|
||||
get();
|
||||
assertEquals("Subject does not have permission [configuration:read:hg]", response.getContentAsString());
|
||||
assertEquals(HttpServletResponse.SC_FORBIDDEN, response.getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -158,9 +154,10 @@ public class HgConfigPackageResourceTest {
|
||||
@Test
|
||||
@SubjectAware(username = "readOnly")
|
||||
public void shouldNotInstallPackageWhenNotAuthorized() throws Exception {
|
||||
thrown.expectMessage("Subject does not have permission [configuration:write:hg]");
|
||||
MockHttpResponse response = put("don-t-care");
|
||||
|
||||
put("don-t-care");
|
||||
assertEquals("Subject does not have permission [configuration:write:hg]", response.getContentAsString());
|
||||
assertEquals(HttpServletResponse.SC_FORBIDDEN, response.getStatus());
|
||||
}
|
||||
|
||||
private List<HgPackage> createPackages() {
|
||||
@@ -191,7 +188,7 @@ public class HgConfigPackageResourceTest {
|
||||
new HgConfigPackageResource(hgPackageReader, advancedHttpClient, repositoryHandler, mapper);
|
||||
|
||||
when(hgConfigPackageResourceProvider.get()).thenReturn(hgConfigPackageResource);
|
||||
dispatcher.getRegistry().addSingletonResource(
|
||||
dispatcher.addSingletonResource(
|
||||
new HgConfigResource(null, null, null,
|
||||
hgConfigPackageResourceProvider, null, null));
|
||||
}
|
||||
|
||||
@@ -4,14 +4,11 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import com.github.sdorra.shiro.ShiroRule;
|
||||
import com.github.sdorra.shiro.SubjectAware;
|
||||
import org.jboss.resteasy.core.Dispatcher;
|
||||
import org.jboss.resteasy.mock.MockDispatcherFactory;
|
||||
import org.jboss.resteasy.mock.MockHttpRequest;
|
||||
import org.jboss.resteasy.mock.MockHttpResponse;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Answers;
|
||||
import org.mockito.InjectMocks;
|
||||
@@ -20,6 +17,7 @@ import org.mockito.junit.MockitoJUnitRunner;
|
||||
import sonia.scm.repository.HgConfig;
|
||||
import sonia.scm.repository.HgRepositoryHandler;
|
||||
import sonia.scm.web.HgVndMediaType;
|
||||
import sonia.scm.web.RestDispatcher;
|
||||
|
||||
import javax.inject.Provider;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@@ -43,10 +41,7 @@ public class HgConfigResourceTest {
|
||||
@Rule
|
||||
public ShiroRule shiro = new ShiroRule();
|
||||
|
||||
@Rule
|
||||
public ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
private Dispatcher dispatcher = MockDispatcherFactory.createDispatcher();
|
||||
private RestDispatcher dispatcher = new RestDispatcher();
|
||||
|
||||
private final URI baseUri = URI.create("/");
|
||||
|
||||
@@ -78,7 +73,7 @@ public class HgConfigResourceTest {
|
||||
HgConfigResource gitConfigResource =
|
||||
new HgConfigResource(dtoToConfigMapper, configToDtoMapper, repositoryHandler, packagesResource,
|
||||
autoconfigResource, installationsResource);
|
||||
dispatcher.getRegistry().addSingletonResource(gitConfigResource);
|
||||
dispatcher.addSingletonResource(gitConfigResource);
|
||||
when(scmPathInfoStore.get().getApiRestUri()).thenReturn(baseUri);
|
||||
}
|
||||
|
||||
@@ -120,10 +115,11 @@ public class HgConfigResourceTest {
|
||||
|
||||
@Test
|
||||
@SubjectAware(username = "writeOnly")
|
||||
public void shouldNotGetConfigWhenNotAuthorized() throws URISyntaxException {
|
||||
thrown.expectMessage("Subject does not have permission [configuration:read:hg]");
|
||||
public void shouldNotGetConfigWhenNotAuthorized() throws URISyntaxException, UnsupportedEncodingException {
|
||||
MockHttpResponse response = get();
|
||||
|
||||
get();
|
||||
assertEquals("Subject does not have permission [configuration:read:hg]", response.getContentAsString());
|
||||
assertEquals(HttpServletResponse.SC_FORBIDDEN, response.getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -135,10 +131,11 @@ public class HgConfigResourceTest {
|
||||
|
||||
@Test
|
||||
@SubjectAware(username = "readOnly")
|
||||
public void shouldNotUpdateConfigWhenNotAuthorized() throws URISyntaxException {
|
||||
thrown.expectMessage("Subject does not have permission [configuration:write:hg]");
|
||||
public void shouldNotUpdateConfigWhenNotAuthorized() throws URISyntaxException, UnsupportedEncodingException {
|
||||
MockHttpResponse response = put();
|
||||
|
||||
put();
|
||||
assertEquals("Subject does not have permission [configuration:write:hg]", response.getContentAsString());
|
||||
assertEquals(HttpServletResponse.SC_FORBIDDEN, response.getStatus());
|
||||
}
|
||||
|
||||
private MockHttpResponse get() throws URISyntaxException {
|
||||
|
||||
@@ -4,14 +4,11 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import com.github.sdorra.shiro.ShiroRule;
|
||||
import com.github.sdorra.shiro.SubjectAware;
|
||||
import org.jboss.resteasy.core.Dispatcher;
|
||||
import org.jboss.resteasy.mock.MockDispatcherFactory;
|
||||
import org.jboss.resteasy.mock.MockHttpRequest;
|
||||
import org.jboss.resteasy.mock.MockHttpResponse;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Answers;
|
||||
import org.mockito.InjectMocks;
|
||||
@@ -19,6 +16,7 @@ import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import sonia.scm.repository.SvnConfig;
|
||||
import sonia.scm.repository.SvnRepositoryHandler;
|
||||
import sonia.scm.web.RestDispatcher;
|
||||
import sonia.scm.web.SvnVndMediaType;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@@ -42,10 +40,7 @@ public class SvnConfigResourceTest {
|
||||
@Rule
|
||||
public ShiroRule shiro = new ShiroRule();
|
||||
|
||||
@Rule
|
||||
public ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
private Dispatcher dispatcher = MockDispatcherFactory.createDispatcher();
|
||||
private RestDispatcher dispatcher = new RestDispatcher();
|
||||
|
||||
private final URI baseUri = URI.create("/");
|
||||
|
||||
@@ -66,7 +61,7 @@ public class SvnConfigResourceTest {
|
||||
SvnConfig gitConfig = createConfiguration();
|
||||
when(repositoryHandler.getConfig()).thenReturn(gitConfig);
|
||||
SvnConfigResource gitConfigResource = new SvnConfigResource(dtoToConfigMapper, configToDtoMapper, repositoryHandler);
|
||||
dispatcher.getRegistry().addSingletonResource(gitConfigResource);
|
||||
dispatcher.addSingletonResource(gitConfigResource);
|
||||
when(scmPathInfoStore.get().getApiRestUri()).thenReturn(baseUri);
|
||||
}
|
||||
|
||||
@@ -108,10 +103,11 @@ public class SvnConfigResourceTest {
|
||||
|
||||
@Test
|
||||
@SubjectAware(username = "writeOnly")
|
||||
public void shouldNotGetConfigWhenNotAuthorized() throws URISyntaxException {
|
||||
thrown.expectMessage("Subject does not have permission [configuration:read:svn]");
|
||||
public void shouldNotGetConfigWhenNotAuthorized() throws URISyntaxException, UnsupportedEncodingException {
|
||||
MockHttpResponse response = get();
|
||||
|
||||
get();
|
||||
assertEquals("Subject does not have permission [configuration:read:svn]", response.getContentAsString());
|
||||
assertEquals(HttpServletResponse.SC_FORBIDDEN, response.getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -123,10 +119,11 @@ public class SvnConfigResourceTest {
|
||||
|
||||
@Test
|
||||
@SubjectAware(username = "readOnly")
|
||||
public void shouldNotUpdateConfigWhenNotAuthorized() throws URISyntaxException {
|
||||
thrown.expectMessage("Subject does not have permission [configuration:write:svn]");
|
||||
public void shouldNotUpdateConfigWhenNotAuthorized() throws URISyntaxException, UnsupportedEncodingException {
|
||||
MockHttpResponse response = put();
|
||||
|
||||
put();
|
||||
assertEquals("Subject does not have permission [configuration:write:svn]", response.getContentAsString());
|
||||
assertEquals(HttpServletResponse.SC_FORBIDDEN, response.getStatus());
|
||||
}
|
||||
|
||||
private MockHttpResponse get() throws URISyntaxException {
|
||||
|
||||
Reference in New Issue
Block a user