diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/common/DeletionUtil.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/common/DeletionUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..9bc5910b2d74a5c3447b3d029350737fac2c641c --- /dev/null +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/common/DeletionUtil.java @@ -0,0 +1,73 @@ +/* + * Copyright 2017 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.common; + +import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.CommonAuthorizationSystemTest; +import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.CommonAuthorizationSystemTest.SampleKind; +import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Deletion; +import ch.systemsx.cisd.openbis.generic.shared.dto.ExperimentPE; +import ch.systemsx.cisd.openbis.generic.shared.dto.ProjectPE; +import ch.systemsx.cisd.openbis.generic.shared.dto.SamplePE; +import ch.systemsx.cisd.openbis.generic.shared.dto.SpacePE; + +/** + * @author pkupczyk + */ +public class DeletionUtil +{ + + public static TechId createNonexistentObject(Object param) + { + return new TechId(-1); + } + + public static TechId createObjectWithExperiment(CommonAuthorizationSystemTest test, SpacePE spacePE, ProjectPE projectPE, Object param) + { + ExperimentPE experiment = test.getExperimentEmpty(spacePE, projectPE); + Deletion deletion = test.getCommonService().trashExperiment(experiment); + return new TechId(deletion.getId()); + } + + public static TechId createObjectWithSample(CommonAuthorizationSystemTest test, SpacePE spacePE, ProjectPE projectPE, Object param) + { + SamplePE sample; + + switch ((SampleKind) param) + { + case SHARED_READ: + case SHARED_READ_WRITE: + if (test.getSpace1().equals(spacePE)) + { + sample = test.getSharedSample1(); + } else if (test.getSpace2().equals(spacePE)) + { + sample = test.getSharedSample2(); + } else + { + throw new RuntimeException(); + } + break; + default: + sample = test.getSample(spacePE, projectPE, (SampleKind) param); + } + + Deletion deletion = test.getCommonService().trashSample(sample); + return new TechId(deletion.getId()); + } + +} diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/DeletionTechIdCollectionPredicateSystemTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/DeletionTechIdCollectionPredicateSystemTest.java index 835f58cf9453d54b947179347c48bc80092d0efc..3827984b91c7d7e6f111b48317dea53100ad4860 100644 --- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/DeletionTechIdCollectionPredicateSystemTest.java +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/DeletionTechIdCollectionPredicateSystemTest.java @@ -19,6 +19,7 @@ package ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predi import java.util.List; import ch.systemsx.cisd.common.exceptions.UserFailureException; +import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.common.DeletionUtil; import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.CommonPredicateSystemTest; import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; import ch.systemsx.cisd.openbis.generic.shared.dto.IAuthSessionProvider; @@ -40,7 +41,7 @@ public abstract class DeletionTechIdCollectionPredicateSystemTest extends Common @Override protected TechId createNonexistentObject(Object param) { - return new TechId(-1); + return DeletionUtil.createNonexistentObject(param); } @Override diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/DeletionTechIdCollectionPredicateWithExperimentSystemTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/DeletionTechIdCollectionPredicateWithExperimentSystemTest.java index 996fc1c6ddcd8e202ea3d2a01dbdef49ce8a3383..b6c5a9fe1647f59060bad79237daf0a8d56c0070 100644 --- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/DeletionTechIdCollectionPredicateWithExperimentSystemTest.java +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/DeletionTechIdCollectionPredicateWithExperimentSystemTest.java @@ -16,9 +16,8 @@ package ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.deletion; +import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.common.DeletionUtil; import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Deletion; -import ch.systemsx.cisd.openbis.generic.shared.dto.ExperimentPE; import ch.systemsx.cisd.openbis.generic.shared.dto.ProjectPE; import ch.systemsx.cisd.openbis.generic.shared.dto.SpacePE; @@ -31,9 +30,7 @@ public class DeletionTechIdCollectionPredicateWithExperimentSystemTest extends D @Override protected TechId createObject(SpacePE spacePE, ProjectPE projectPE, Object param) { - ExperimentPE experiment = getExperimentEmpty(spacePE, projectPE); - Deletion deletion = getCommonService().trashExperiment(experiment); - return new TechId(deletion.getId()); + return DeletionUtil.createObjectWithExperiment(this, spacePE, projectPE, param); } } \ No newline at end of file diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/DeletionTechIdCollectionPredicateWithSampleSystemTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/DeletionTechIdCollectionPredicateWithSampleSystemTest.java index b6a5f146727f6bf44db3304ededf35fca5c8223b..cac5eb536619f27a48a50dc2142fa74f5843a91b 100644 --- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/DeletionTechIdCollectionPredicateWithSampleSystemTest.java +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/DeletionTechIdCollectionPredicateWithSampleSystemTest.java @@ -19,13 +19,12 @@ package ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predi import java.util.List; import ch.systemsx.cisd.common.exceptions.UserFailureException; +import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.common.DeletionUtil; import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.CommonSamplePredicateSystemTest; import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Deletion; import ch.systemsx.cisd.openbis.generic.shared.dto.IAuthSessionProvider; import ch.systemsx.cisd.openbis.generic.shared.dto.PersonPE; import ch.systemsx.cisd.openbis.generic.shared.dto.ProjectPE; -import ch.systemsx.cisd.openbis.generic.shared.dto.SamplePE; import ch.systemsx.cisd.openbis.generic.shared.dto.SpacePE; import ch.systemsx.cisd.openbis.systemtest.authorization.predicate.deletion.DeletionPredicateTestService; @@ -44,40 +43,19 @@ public class DeletionTechIdCollectionPredicateWithSampleSystemTest extends Commo @Override protected SampleKind getSharedSampleKind() { - return SampleKind.SHARED_READ; + return SampleKind.SHARED_READ_WRITE; } @Override protected TechId createNonexistentObject(Object param) { - return new TechId(-1); + return DeletionUtil.createNonexistentObject(param); } @Override protected TechId createObject(SpacePE spacePE, ProjectPE projectPE, Object param) { - SamplePE sample; - - switch ((SampleKind) param) - { - case SHARED_READ: - if (getSpace1().equals(spacePE)) - { - sample = getSharedSample1(); - } else if (getSpace2().equals(spacePE)) - { - sample = getSharedSample2(); - } else - { - throw new RuntimeException(); - } - break; - default: - sample = getSample(spacePE, projectPE, (SampleKind) param); - } - - Deletion deletion = getCommonService().trashSample(sample); - return new TechId(deletion.getId()); + return DeletionUtil.createObjectWithSample(this, spacePE, projectPE, param); } @Override diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/RevertDeletionPredicateSystemTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/RevertDeletionPredicateSystemTest.java new file mode 100644 index 0000000000000000000000000000000000000000..4bce8d0d2e61de895ca9fd0cdb502b5df9d01bac --- /dev/null +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/RevertDeletionPredicateSystemTest.java @@ -0,0 +1,92 @@ +/* + * Copyright 2017 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.deletion; + +import java.util.List; + +import ch.systemsx.cisd.common.exceptions.UserFailureException; +import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.common.DeletionUtil; +import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.CommonPredicateSystemTest; +import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; +import ch.systemsx.cisd.openbis.generic.shared.dto.IAuthSessionProvider; +import ch.systemsx.cisd.openbis.generic.shared.dto.PersonPE; +import ch.systemsx.cisd.openbis.systemtest.authorization.predicate.deletion.DeletionPredicateTestService; + +/** + * @author pkupczyk + */ +public abstract class RevertDeletionPredicateSystemTest extends CommonPredicateSystemTest<TechId> +{ + + @Override + protected boolean isCollectionPredicate() + { + return true; + } + + @Override + protected TechId createNonexistentObject(Object param) + { + return DeletionUtil.createNonexistentObject(param); + } + + @Override + protected void evaluateObjects(IAuthSessionProvider sessionProvider, List<TechId> objects, Object param) + { + try + { + getBean(DeletionPredicateTestService.class).testRevertDeletionPredicate(sessionProvider, objects); + } finally + { + if (objects != null) + { + for (TechId object : objects) + { + if (object != null) + { + getCommonService().untrash(object.getId()); + } + } + } + } + } + + @Override + protected void assertWithNull(PersonPE person, Throwable t, Object param) + { + assertException(t, NullPointerException.class, null); + } + + @Override + protected void assertWithNullForInstanceUser(PersonPE person, Throwable t, Object param) + { + assertNoException(t); + } + + @Override + protected void assertWithNullCollection(PersonPE person, Throwable t, Object param) + { + assertException(t, UserFailureException.class, "No revert deletion technical id specified."); + } + + @Override + protected void assertWithNonexistentObject(PersonPE person, Throwable t, Object param) + { + assertNoException(t); + } + +} \ No newline at end of file diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/RevertDeletionPredicateWithExperimentSystemTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/RevertDeletionPredicateWithExperimentSystemTest.java new file mode 100644 index 0000000000000000000000000000000000000000..0f7dd79ef70deb6ff84d5dcb0efb383f18555e3e --- /dev/null +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/RevertDeletionPredicateWithExperimentSystemTest.java @@ -0,0 +1,36 @@ +/* + * Copyright 2017 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.deletion; + +import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.common.DeletionUtil; +import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; +import ch.systemsx.cisd.openbis.generic.shared.dto.ProjectPE; +import ch.systemsx.cisd.openbis.generic.shared.dto.SpacePE; + +/** + * @author pkupczyk + */ +public class RevertDeletionPredicateWithExperimentSystemTest extends RevertDeletionPredicateSystemTest +{ + + @Override + protected TechId createObject(SpacePE spacePE, ProjectPE projectPE, Object param) + { + return DeletionUtil.createObjectWithExperiment(this, spacePE, projectPE, param); + } + +} \ No newline at end of file diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/RevertDeletionPredicateWithSampleSystemTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/RevertDeletionPredicateWithSampleSystemTest.java new file mode 100644 index 0000000000000000000000000000000000000000..7ee0a3c79396be92b06b2f5072902526f70f96fd --- /dev/null +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/RevertDeletionPredicateWithSampleSystemTest.java @@ -0,0 +1,106 @@ +/* + * Copyright 2017 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.deletion; + +import java.util.List; + +import ch.systemsx.cisd.common.exceptions.UserFailureException; +import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.common.DeletionUtil; +import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.CommonSamplePredicateSystemTest; +import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; +import ch.systemsx.cisd.openbis.generic.shared.dto.IAuthSessionProvider; +import ch.systemsx.cisd.openbis.generic.shared.dto.PersonPE; +import ch.systemsx.cisd.openbis.generic.shared.dto.ProjectPE; +import ch.systemsx.cisd.openbis.generic.shared.dto.SpacePE; +import ch.systemsx.cisd.openbis.systemtest.authorization.predicate.deletion.DeletionPredicateTestService; + +/** + * @author pkupczyk + */ +public class RevertDeletionPredicateWithSampleSystemTest extends CommonSamplePredicateSystemTest<TechId> +{ + + @Override + protected boolean isCollectionPredicate() + { + return true; + } + + @Override + protected SampleKind getSharedSampleKind() + { + return SampleKind.SHARED_READ_WRITE; + } + + @Override + protected TechId createNonexistentObject(Object param) + { + return DeletionUtil.createNonexistentObject(param); + } + + @Override + protected TechId createObject(SpacePE spacePE, ProjectPE projectPE, Object param) + { + return DeletionUtil.createObjectWithSample(this, spacePE, projectPE, param); + } + + @Override + protected void evaluateObjects(IAuthSessionProvider sessionProvider, List<TechId> objects, Object param) + { + try + { + getBean(DeletionPredicateTestService.class).testRevertDeletionPredicate(sessionProvider, objects); + } finally + { + if (objects != null) + { + for (TechId object : objects) + { + if (object != null) + { + getCommonService().untrash(object.getId()); + } + } + } + } + } + + @Override + protected void assertWithNull(PersonPE person, Throwable t, Object param) + { + assertException(t, NullPointerException.class, null); + } + + @Override + protected void assertWithNullForInstanceUser(PersonPE person, Throwable t, Object param) + { + assertNoException(t); + } + + @Override + protected void assertWithNullCollection(PersonPE person, Throwable t, Object param) + { + assertException(t, UserFailureException.class, "No revert deletion technical id specified."); + } + + @Override + protected void assertWithNonexistentObject(PersonPE person, Throwable t, Object param) + { + assertNoException(t); + } + +} \ No newline at end of file diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/V3DeletionIdPredicateSystemTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/V3DeletionIdPredicateSystemTest.java new file mode 100644 index 0000000000000000000000000000000000000000..7b524803cb5cbf89779a6b108c803b79b2f4a44c --- /dev/null +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/V3DeletionIdPredicateSystemTest.java @@ -0,0 +1,86 @@ +/* + * Copyright 2017 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.deletion; + +import java.util.List; + +import ch.ethz.sis.openbis.generic.asapi.v3.dto.deletion.id.DeletionTechId; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.deletion.id.IDeletionId; +import ch.systemsx.cisd.common.exceptions.UserFailureException; +import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.CommonPredicateSystemTest; +import ch.systemsx.cisd.openbis.generic.shared.dto.IAuthSessionProvider; +import ch.systemsx.cisd.openbis.generic.shared.dto.PersonPE; +import ch.systemsx.cisd.openbis.systemtest.authorization.predicate.deletion.DeletionPredicateTestService; + +/** + * @author pkupczyk + */ +public abstract class V3DeletionIdPredicateSystemTest extends CommonPredicateSystemTest<IDeletionId> +{ + + @Override + protected boolean isCollectionPredicate() + { + return true; + } + + @Override + protected IDeletionId createNonexistentObject(Object param) + { + return new DeletionTechId(-1L); + } + + @Override + protected void evaluateObjects(IAuthSessionProvider sessionProvider, List<IDeletionId> objects, Object param) + { + try + { + getBean(DeletionPredicateTestService.class).testV3DeletionIdPredicate(sessionProvider, objects); + } finally + { + if (objects != null) + { + for (IDeletionId object : objects) + { + if (object != null) + { + getCommonService().untrash(((DeletionTechId) object).getTechId()); + } + } + } + } + } + + @Override + protected void assertWithNull(PersonPE person, Throwable t, Object param) + { + assertException(t, NullPointerException.class, null); + } + + @Override + protected void assertWithNullCollection(PersonPE person, Throwable t, Object param) + { + assertException(t, UserFailureException.class, "No v3 deletion id object specified."); + } + + @Override + protected void assertWithNonexistentObject(PersonPE person, Throwable t, Object param) + { + assertNoException(t); + } + +} \ No newline at end of file diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/V3DeletionIdPredicateWithExperimentSystemTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/V3DeletionIdPredicateWithExperimentSystemTest.java new file mode 100644 index 0000000000000000000000000000000000000000..528862052927d3a03bfb8c0728150f760cfb1a0d --- /dev/null +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/V3DeletionIdPredicateWithExperimentSystemTest.java @@ -0,0 +1,39 @@ +/* + * Copyright 2017 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.deletion; + +import ch.ethz.sis.openbis.generic.asapi.v3.dto.deletion.id.DeletionTechId; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.deletion.id.IDeletionId; +import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.common.DeletionUtil; +import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; +import ch.systemsx.cisd.openbis.generic.shared.dto.ProjectPE; +import ch.systemsx.cisd.openbis.generic.shared.dto.SpacePE; + +/** + * @author pkupczyk + */ +public class V3DeletionIdPredicateWithExperimentSystemTest extends V3DeletionIdPredicateSystemTest +{ + + @Override + protected IDeletionId createObject(SpacePE spacePE, ProjectPE projectPE, Object param) + { + TechId techId = DeletionUtil.createObjectWithExperiment(this, spacePE, projectPE, param); + return new DeletionTechId(techId.getId()); + } + +} \ No newline at end of file diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/V3DeletionIdPredicateWithSampleSystemTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/V3DeletionIdPredicateWithSampleSystemTest.java new file mode 100644 index 0000000000000000000000000000000000000000..e637507b83570c7087cf3f6ae1ae66bb5db17a1d --- /dev/null +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/V3DeletionIdPredicateWithSampleSystemTest.java @@ -0,0 +1,103 @@ +/* + * Copyright 2017 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.deletion; + +import java.util.List; + +import ch.ethz.sis.openbis.generic.asapi.v3.dto.deletion.id.DeletionTechId; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.deletion.id.IDeletionId; +import ch.systemsx.cisd.common.exceptions.UserFailureException; +import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.common.DeletionUtil; +import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.CommonSamplePredicateSystemTest; +import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; +import ch.systemsx.cisd.openbis.generic.shared.dto.IAuthSessionProvider; +import ch.systemsx.cisd.openbis.generic.shared.dto.PersonPE; +import ch.systemsx.cisd.openbis.generic.shared.dto.ProjectPE; +import ch.systemsx.cisd.openbis.generic.shared.dto.SpacePE; +import ch.systemsx.cisd.openbis.systemtest.authorization.predicate.deletion.DeletionPredicateTestService; + +/** + * @author pkupczyk + */ +public class V3DeletionIdPredicateWithSampleSystemTest extends CommonSamplePredicateSystemTest<IDeletionId> +{ + + @Override + protected boolean isCollectionPredicate() + { + return true; + } + + @Override + protected SampleKind getSharedSampleKind() + { + return SampleKind.SHARED_READ_WRITE; + } + + @Override + protected IDeletionId createNonexistentObject(Object param) + { + return new DeletionTechId(-1L); + } + + @Override + protected IDeletionId createObject(SpacePE spacePE, ProjectPE projectPE, Object param) + { + TechId techId = DeletionUtil.createObjectWithSample(this, spacePE, projectPE, param); + return new DeletionTechId(techId.getId()); + } + + @Override + protected void evaluateObjects(IAuthSessionProvider sessionProvider, List<IDeletionId> objects, Object param) + { + try + { + getBean(DeletionPredicateTestService.class).testV3DeletionIdPredicate(sessionProvider, objects); + } finally + { + if (objects != null) + { + for (IDeletionId object : objects) + { + if (object != null) + { + getCommonService().untrash(((DeletionTechId) object).getTechId()); + } + } + } + } + } + + @Override + protected void assertWithNull(PersonPE person, Throwable t, Object param) + { + assertException(t, NullPointerException.class, null); + } + + @Override + protected void assertWithNullCollection(PersonPE person, Throwable t, Object param) + { + assertException(t, UserFailureException.class, "No v3 deletion id object specified."); + } + + @Override + protected void assertWithNonexistentObject(PersonPE person, Throwable t, Object param) + { + assertNoException(t); + } + +} \ No newline at end of file diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/DeletionTechIdCollectionPredicate.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/DeletionTechIdCollectionPredicate.java index aa83ed7b3d222a959a135e0bb25da6f6e9966315..aee89b20df1aa6daed0490de923cc55c3f58687c 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/DeletionTechIdCollectionPredicate.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/DeletionTechIdCollectionPredicate.java @@ -43,7 +43,7 @@ public class DeletionTechIdCollectionPredicate extends AbstractSpacePredicate<Li public DeletionTechIdCollectionPredicate() { this.experimentAccessPECollectionPredicate = new ExperimentAccessPECollectionPredicate(); - this.sampleAccessPECollectionPredicate = new SampleAccessPECollectionPredicate(); + this.sampleAccessPECollectionPredicate = new SampleAccessPECollectionPredicate(false); } @Override diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/RevertDeletionPredicate.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/RevertDeletionPredicate.java index 5cb787fea8091565bec0fc3799185ad11851c208..9e0034066cb8463b02bfb5ea5780d5ed07d78238 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/RevertDeletionPredicate.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/RevertDeletionPredicate.java @@ -97,7 +97,7 @@ public class RevertDeletionPredicate extends AbstractPredicate<List<TechId>> final Set<RoleAssignmentPE> roleAssignments = person.getAllPersonRoles(); for (final RoleAssignmentPE roleAssignment : roleAssignments) { - if (roleAssignment.getSpace() == null && roleAssignment.getRole().equals(RoleCode.ADMIN)) + if (roleAssignment.getSpace() == null && roleAssignment.getProject() == null && roleAssignment.getRole().equals(RoleCode.ADMIN)) { return true; } diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/authorization/predicate/deletion/DeletionPredicateTestService.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/authorization/predicate/deletion/DeletionPredicateTestService.java index 5bbcf766ef352569164114ea4ecd915121d94b6d..6cdd80f8601c95bd0b509616dc462314e389974f 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/authorization/predicate/deletion/DeletionPredicateTestService.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/authorization/predicate/deletion/DeletionPredicateTestService.java @@ -21,9 +21,12 @@ import java.util.List; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.deletion.id.IDeletionId; import ch.systemsx.cisd.openbis.generic.server.authorization.annotation.AuthorizationGuard; import ch.systemsx.cisd.openbis.generic.server.authorization.annotation.RolesAllowed; import ch.systemsx.cisd.openbis.generic.server.authorization.predicate.DeletionTechIdCollectionPredicate; +import ch.systemsx.cisd.openbis.generic.server.authorization.predicate.RevertDeletionPredicate; +import ch.systemsx.cisd.openbis.generic.server.authorization.predicate.V3DeletionIdPredicate; import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.RoleWithHierarchy; import ch.systemsx.cisd.openbis.generic.shared.dto.IAuthSessionProvider; @@ -42,4 +45,18 @@ public class DeletionPredicateTestService { } + @Transactional + @RolesAllowed(value = { RoleWithHierarchy.PROJECT_OBSERVER }) + public void testRevertDeletionPredicate(IAuthSessionProvider sessionProvider, + @AuthorizationGuard(guardClass = RevertDeletionPredicate.class) List<TechId> deletionTechIds) + { + } + + @Transactional + @RolesAllowed(value = { RoleWithHierarchy.PROJECT_OBSERVER }) + public void testV3DeletionIdPredicate(IAuthSessionProvider sessionProvider, + @AuthorizationGuard(guardClass = V3DeletionIdPredicate.class) List<IDeletionId> deletionIds) + { + } + }