From f3d289546ecc4a422b34a748d2898244a3a8d5a3 Mon Sep 17 00:00:00 2001 From: Eduard Heimbuch Date: Tue, 5 May 2020 11:15:26 +0200 Subject: [PATCH] update CHANGELOG.md // adjust unit tests to changed permission --- CHANGELOG.md | 1 + .../api/v2/resources/PendingPluginResourceTest.java | 4 ++-- .../v2/resources/PluginDtoCollectionMapperTest.java | 10 +++++----- .../scm/api/v2/resources/PluginDtoMapperTest.java | 8 ++++---- .../sonia/scm/plugin/DefaultPluginManagerTest.java | 4 ++-- 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2747e98d3a..f5c3c2da29 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fix usage of invalid cipher algorith on newer java versions ([#1110](https://github.com/scm-manager/scm-manager/issues/1110),[#1112](https://github.com/scm-manager/scm-manager/pull/1112)) - Handle obscure line breaks in diff viewer ([#1129](https://github.com/scm-manager/scm-manager/pull/1129)) - Validate subversion client checksum ([#1113](https://github.com/scm-manager/scm-manager/issues/1113)) +- Fix plugin manage permission ([#1135](https://github.com/scm-manager/scm-manager/pull/1135)) ## [2.0.0-rc7] - 2020-04-09 ### Added diff --git a/scm-webapp/src/test/java/sonia/scm/api/v2/resources/PendingPluginResourceTest.java b/scm-webapp/src/test/java/sonia/scm/api/v2/resources/PendingPluginResourceTest.java index 2f545761b7..00c4191dd7 100644 --- a/scm-webapp/src/test/java/sonia/scm/api/v2/resources/PendingPluginResourceTest.java +++ b/scm-webapp/src/test/java/sonia/scm/api/v2/resources/PendingPluginResourceTest.java @@ -114,7 +114,7 @@ class PendingPluginResourceTest { @BeforeEach void bindSubject() { ThreadContext.bind(subject); - lenient().when(subject.isPermitted("plugin:manage")).thenReturn(true); + lenient().when(subject.isPermitted("plugin:write")).thenReturn(true); lenient().when(restarter.isSupported()).thenReturn(true); } @@ -228,7 +228,7 @@ class PendingPluginResourceTest { @BeforeEach void bindSubject() { ThreadContext.bind(subject); - when(subject.isPermitted("plugin:manage")).thenReturn(false); + when(subject.isPermitted("plugin:write")).thenReturn(false); } @AfterEach diff --git a/scm-webapp/src/test/java/sonia/scm/api/v2/resources/PluginDtoCollectionMapperTest.java b/scm-webapp/src/test/java/sonia/scm/api/v2/resources/PluginDtoCollectionMapperTest.java index a3fa801a22..f91c7b08b9 100644 --- a/scm-webapp/src/test/java/sonia/scm/api/v2/resources/PluginDtoCollectionMapperTest.java +++ b/scm-webapp/src/test/java/sonia/scm/api/v2/resources/PluginDtoCollectionMapperTest.java @@ -119,7 +119,7 @@ class PluginDtoCollectionMapperTest { @Test void shouldNotAddInstallLinkForNewVersionWhenNotPermitted() { - when(subject.isPermitted("plugin:manage")).thenReturn(false); + when(subject.isPermitted("plugin:write")).thenReturn(false); PluginDtoCollectionMapper mapper = new PluginDtoCollectionMapper(resourceLinks, pluginDtoMapper, manager); HalRepresentation result = mapper.mapInstalled( @@ -132,7 +132,7 @@ class PluginDtoCollectionMapperTest { @Test void shouldNotAddInstallLinkForNewVersionWhenInstallationIsPending() { - when(subject.isPermitted("plugin:manage")).thenReturn(true); + when(subject.isPermitted("plugin:write")).thenReturn(true); PluginDtoCollectionMapper mapper = new PluginDtoCollectionMapper(resourceLinks, pluginDtoMapper, manager); AvailablePlugin availablePlugin = createAvailablePlugin("scm-some-plugin", "2"); @@ -147,7 +147,7 @@ class PluginDtoCollectionMapperTest { @Test void shouldAddUpdateLinkForNewVersionWhenPermitted() { - when(subject.isPermitted("plugin:manage")).thenReturn(true); + when(subject.isPermitted("plugin:write")).thenReturn(true); PluginDtoCollectionMapper mapper = new PluginDtoCollectionMapper(resourceLinks, pluginDtoMapper, manager); HalRepresentation result = mapper.mapInstalled( @@ -161,7 +161,7 @@ class PluginDtoCollectionMapperTest { @Test void shouldAddUpdateWithRestartLinkForNewVersionWhenPermitted() { when(restarter.isSupported()).thenReturn(true); - when(subject.isPermitted("plugin:manage")).thenReturn(true); + when(subject.isPermitted("plugin:write")).thenReturn(true); PluginDtoCollectionMapper mapper = new PluginDtoCollectionMapper(resourceLinks, pluginDtoMapper, manager); HalRepresentation result = mapper.mapInstalled( @@ -175,7 +175,7 @@ class PluginDtoCollectionMapperTest { @Test void shouldSetInstalledPluginPendingWhenCorrespondingAvailablePluginIsPending() { - when(subject.isPermitted("plugin:manage")).thenReturn(true); + when(subject.isPermitted("plugin:write")).thenReturn(true); PluginDtoCollectionMapper mapper = new PluginDtoCollectionMapper(resourceLinks, pluginDtoMapper, manager); AvailablePlugin availablePlugin = createAvailablePlugin("scm-some-plugin", "2"); diff --git a/scm-webapp/src/test/java/sonia/scm/api/v2/resources/PluginDtoMapperTest.java b/scm-webapp/src/test/java/sonia/scm/api/v2/resources/PluginDtoMapperTest.java index 8301e6fb76..7c3c3975c0 100644 --- a/scm-webapp/src/test/java/sonia/scm/api/v2/resources/PluginDtoMapperTest.java +++ b/scm-webapp/src/test/java/sonia/scm/api/v2/resources/PluginDtoMapperTest.java @@ -127,7 +127,7 @@ class PluginDtoMapperTest { @Test void shouldAppendInstallLink() { - when(subject.isPermitted("plugin:manage")).thenReturn(true); + when(subject.isPermitted("plugin:write")).thenReturn(true); AvailablePlugin plugin = createAvailable(createPluginInformation()); PluginDto dto = mapper.mapAvailable(plugin); @@ -138,7 +138,7 @@ class PluginDtoMapperTest { @Test void shouldAppendInstallWithRestartLink() { when(restarter.isSupported()).thenReturn(true); - when(subject.isPermitted("plugin:manage")).thenReturn(true); + when(subject.isPermitted("plugin:write")).thenReturn(true); AvailablePlugin plugin = createAvailable(createPluginInformation()); PluginDto dto = mapper.mapAvailable(plugin); @@ -166,7 +166,7 @@ class PluginDtoMapperTest { @Test void shouldAppendUninstallLink() { - when(subject.isPermitted("plugin:manage")).thenReturn(true); + when(subject.isPermitted("plugin:write")).thenReturn(true); InstalledPlugin plugin = createInstalled(createPluginInformation()); when(plugin.isUninstallable()).thenReturn(true); @@ -178,7 +178,7 @@ class PluginDtoMapperTest { @Test void shouldAppendUninstallWithRestartLink() { when(restarter.isSupported()).thenReturn(true); - when(subject.isPermitted("plugin:manage")).thenReturn(true); + when(subject.isPermitted("plugin:write")).thenReturn(true); InstalledPlugin plugin = createInstalled(createPluginInformation()); when(plugin.isUninstallable()).thenReturn(true); diff --git a/scm-webapp/src/test/java/sonia/scm/plugin/DefaultPluginManagerTest.java b/scm-webapp/src/test/java/sonia/scm/plugin/DefaultPluginManagerTest.java index 03b12f92cf..da7fce6527 100644 --- a/scm-webapp/src/test/java/sonia/scm/plugin/DefaultPluginManagerTest.java +++ b/scm-webapp/src/test/java/sonia/scm/plugin/DefaultPluginManagerTest.java @@ -602,12 +602,12 @@ class DefaultPluginManagerTest { } @Nested - class WithoutManagePermissions { + class WithoutWritePermissions { @BeforeEach void setUpSubject() { ThreadContext.bind(subject); - doThrow(AuthorizationException.class).when(subject).checkPermission("plugin:manage"); + doThrow(AuthorizationException.class).when(subject).checkPermission("plugin:write"); } @AfterEach