diff --git a/accesscontroltool-bundle/src/test/java/biz/netcentric/cq/tools/actool/helper/runtime/RuntimeHelperTest.java b/accesscontroltool-bundle/src/test/java/biz/netcentric/cq/tools/actool/helper/runtime/RuntimeHelperTest.java new file mode 100644 index 00000000..02b5f179 --- /dev/null +++ b/accesscontroltool-bundle/src/test/java/biz/netcentric/cq/tools/actool/helper/runtime/RuntimeHelperTest.java @@ -0,0 +1,44 @@ +package biz.netcentric.cq.tools.actool.helper.runtime; + +/*- + * #%L + * Access Control Tool Bundle + * %% + * Copyright (C) 2015 - 2024 Cognizant Netcentric + * %% + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * #L% + */ + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +import javax.jcr.RepositoryException; +import javax.jcr.Session; + +import static org.mockito.Mockito.when; + +@ExtendWith(MockitoExtension.class) +class RuntimeHelperTest { + + @Mock + Session session; + + @Test + void shouldBeReadonlyIfRootWritable() throws RepositoryException { + when(session.hasPermission("/", Session.ACTION_SET_PROPERTY)).thenReturn(true); + Assertions.assertTrue(RuntimeHelper.isAppsReadOnly(session)); + } + + @Test + void shouldNotBeReadonlyIfRootNotWritable() throws RepositoryException { + when(session.hasPermission("/", Session.ACTION_SET_PROPERTY)).thenReturn(false); + Assertions.assertFalse(RuntimeHelper.isAppsReadOnly(session)); + } +} \ No newline at end of file diff --git a/accesscontroltool-startuphook-bundle/src/test/java/biz/netcentric/cq/tools/actool/startuphook/impl/AcToolStartupHookServiceImplTest.java b/accesscontroltool-startuphook-bundle/src/test/java/biz/netcentric/cq/tools/actool/startuphook/impl/AcToolStartupHookServiceImplTest.java index 5d4a22ed..98ee7efb 100644 --- a/accesscontroltool-startuphook-bundle/src/test/java/biz/netcentric/cq/tools/actool/startuphook/impl/AcToolStartupHookServiceImplTest.java +++ b/accesscontroltool-startuphook-bundle/src/test/java/biz/netcentric/cq/tools/actool/startuphook/impl/AcToolStartupHookServiceImplTest.java @@ -112,7 +112,7 @@ void setup(boolean canSetPropertiesOnRootNode, boolean runAsyncForMutableContent when(noChildren.hasNext()).thenReturn(false); when(rootNode.getNodes()).thenReturn(noChildren); when(session.getRootNode()).thenReturn(rootNode); - } else if (!canSetPropertiesOnRootNode && !cloudOnly){ + } else if (!canSetPropertiesOnRootNode && !cloudOnly) { when(session.hasPermission("/", Session.ACTION_SET_PROPERTY)).thenReturn(false); } if (!cloudOnly) {