diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/CommonPredicateSystemTestAssertionsDefault.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/CommonPredicateSystemTestAssertionsDefault.java index 9723cbc752d00f1e1db556c4e47210ceed01a695..926819bbe223fc28aad74300786f217898542561 100644 --- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/CommonPredicateSystemTestAssertionsDefault.java +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/CommonPredicateSystemTestAssertionsDefault.java @@ -63,7 +63,7 @@ public class CommonPredicateSystemTestAssertionsDefault<O> extends CommonPredica CommonAuthorizationSystemTest.assertAuthorizationFailureExceptionThatNoRoles(t); } else { - CommonAuthorizationSystemTest.assertAuthorizationFailureExceptionThatNotEnoughPrivileges(t); + CommonAuthorizationSystemTest.assertNoException(t); } } diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/dataset/DataSetCodeCollectionPredicateSystemTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/dataset/DataSetCodeCollectionPredicateSystemTest.java index c818a8038b9a8e91682edd9b4ddc2c23c4fede8d..a9d3dfc4b1356326ecb54cd0bcd8df7c415fd870 100644 --- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/dataset/DataSetCodeCollectionPredicateSystemTest.java +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/dataset/DataSetCodeCollectionPredicateSystemTest.java @@ -92,18 +92,6 @@ public class DataSetCodeCollectionPredicateSystemTest extends CommonPredicateSys assertException(t, UserFailureException.class, "No data set codes specified."); } } - - @Override - public void assertWithNonexistentObject(ProjectAuthorizationUser user, Throwable t, Object param) - { - if (user.isDisabledProjectUser()) - { - assertAuthorizationFailureExceptionThatNoRoles(t); - } else - { - assertNoException(t); - } - } }; } diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/dataset/DataSetCodePredicateSystemTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/dataset/DataSetCodePredicateSystemTest.java index a0fa84667e69ce05b82a97f9380447e1bc2b3bdf..39d000fe4b667c37a0655d1150246dced36c9ccc 100644 --- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/dataset/DataSetCodePredicateSystemTest.java +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/dataset/DataSetCodePredicateSystemTest.java @@ -74,18 +74,6 @@ public class DataSetCodePredicateSystemTest extends CommonPredicateSystemTest<St assertException(t, UserFailureException.class, "No data set code specified."); } } - - @Override - public void assertWithNonexistentObject(ProjectAuthorizationUser user, Throwable t, Object param) - { - if (user.isDisabledProjectUser()) - { - assertAuthorizationFailureExceptionThatNoRoles(t); - } else - { - assertNoException(t); - } - } }; } diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/dataset/DataSetTechIdCollectionPredicateSystemTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/dataset/DataSetTechIdCollectionPredicateSystemTest.java index c14226dc42eb8f33791b658c7bcdf019aa1f0c64..f911300d4d80e8756c0d3ace314ce58738cd1a69 100644 --- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/dataset/DataSetTechIdCollectionPredicateSystemTest.java +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/dataset/DataSetTechIdCollectionPredicateSystemTest.java @@ -94,17 +94,6 @@ public class DataSetTechIdCollectionPredicateSystemTest extends CommonPredicateS } } - @Override - public void assertWithNonexistentObject(ProjectAuthorizationUser user, Throwable t, Object param) - { - if (user.isDisabledProjectUser()) - { - assertAuthorizationFailureExceptionThatNoRoles(t); - } else - { - assertNoException(t); - } - } }; } diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/dataset/DataSetTechIdPredicateSystemTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/dataset/DataSetTechIdPredicateSystemTest.java index 14640377672cbf3c6be9b04b26e5f49e19af9d5b..b8e3fd561fd6dbeabc044280fd81009f748a7ffc 100644 --- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/dataset/DataSetTechIdPredicateSystemTest.java +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/dataset/DataSetTechIdPredicateSystemTest.java @@ -75,18 +75,6 @@ public class DataSetTechIdPredicateSystemTest extends CommonPredicateSystemTest< assertException(t, UserFailureException.class, "No data set technical id specified."); } } - - @Override - public void assertWithNonexistentObject(ProjectAuthorizationUser user, Throwable t, Object param) - { - if (user.isDisabledProjectUser()) - { - assertAuthorizationFailureExceptionThatNoRoles(t); - } else - { - assertNoException(t); - } - } }; } diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/dataset/DataSetUpdatesCollectionPredicateWithDataSetTechIdSystemTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/dataset/DataSetUpdatesCollectionPredicateWithDataSetTechIdSystemTest.java index 2302c8b298b301e6dc614ee9855a35e6b19c187b..814e3d1d8ac7865ae0a30f0186471c6a8bf24ab7 100644 --- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/dataset/DataSetUpdatesCollectionPredicateWithDataSetTechIdSystemTest.java +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/dataset/DataSetUpdatesCollectionPredicateWithDataSetTechIdSystemTest.java @@ -16,7 +16,6 @@ package ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.dataset; -import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.ProjectAuthorizationUser; import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.common.DataSetTechIdUtil; import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.CommonPredicateSystemTestAssertions; import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.CommonPredicateSystemTestDataSetAssertions; @@ -55,20 +54,7 @@ public class DataSetUpdatesCollectionPredicateWithDataSetTechIdSystemTest extend @Override protected CommonPredicateSystemTestAssertions<DataSetUpdatesDTO> getAssertions() { - return new CommonPredicateSystemTestDataSetAssertions<DataSetUpdatesDTO>(super.getAssertions()) - { - @Override - public void assertWithNonexistentObject(ProjectAuthorizationUser user, Throwable t, Object param) - { - if (user.isDisabledProjectUser()) - { - assertAuthorizationFailureExceptionThatNoRoles(t); - } else - { - assertNoException(t); - } - } - }; + return new CommonPredicateSystemTestDataSetAssertions<DataSetUpdatesDTO>(super.getAssertions()); } } diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/dataset/DataSetUpdatesPredicateWithDataSetTechIdSystemTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/dataset/DataSetUpdatesPredicateWithDataSetTechIdSystemTest.java index f697f52fc61a84e10fa35eebcc3b2c1a4b605d95..5ff10fed68c06dee459170b98669649936fe7fdf 100644 --- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/dataset/DataSetUpdatesPredicateWithDataSetTechIdSystemTest.java +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/dataset/DataSetUpdatesPredicateWithDataSetTechIdSystemTest.java @@ -16,10 +16,9 @@ package ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.dataset; -import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.ProjectAuthorizationUser; import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.common.DataSetTechIdUtil; -import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.CommonPredicateSystemTestDataSetAssertions; import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.CommonPredicateSystemTestAssertions; +import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.CommonPredicateSystemTestDataSetAssertions; import ch.systemsx.cisd.openbis.generic.shared.dto.DataSetUpdatesDTO; import ch.systemsx.cisd.openbis.generic.shared.dto.ProjectPE; import ch.systemsx.cisd.openbis.generic.shared.dto.SpacePE; @@ -55,20 +54,7 @@ public class DataSetUpdatesPredicateWithDataSetTechIdSystemTest extends DataSetU @Override protected CommonPredicateSystemTestAssertions<DataSetUpdatesDTO> getAssertions() { - return new CommonPredicateSystemTestDataSetAssertions<DataSetUpdatesDTO>(super.getAssertions()) - { - @Override - public void assertWithNonexistentObject(ProjectAuthorizationUser user, Throwable t, Object param) - { - if (user.isDisabledProjectUser()) - { - assertAuthorizationFailureExceptionThatNoRoles(t); - } else - { - assertNoException(t); - } - } - }; + return new CommonPredicateSystemTestDataSetAssertions<DataSetUpdatesDTO>(super.getAssertions()); } } diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/dataset/NewDataSetsWithTypePredicateSystemTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/dataset/NewDataSetsWithTypePredicateSystemTest.java index d1206eda1d5586af479fb61f9e05c606c55a74fd..b37251b6f9ea63c4e030b5d9917d7a8d8ea3d8e7 100644 --- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/dataset/NewDataSetsWithTypePredicateSystemTest.java +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/dataset/NewDataSetsWithTypePredicateSystemTest.java @@ -97,18 +97,6 @@ public abstract class NewDataSetsWithTypePredicateSystemTest<O> extends CommonPr assertNoException(t); } } - - @Override - public void assertWithNonexistentObject(ProjectAuthorizationUser user, Throwable t, Object param) - { - if (user.isDisabledProjectUser()) - { - assertAuthorizationFailureExceptionThatNoRoles(t); - } else - { - assertNoException(t); - } - } }; } diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/dataset/NewExternalDataPredicateSystemTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/dataset/NewExternalDataPredicateSystemTest.java index d1620dde845cdbc23459f161bf2252464762a964..c5b6ad1ce40365c72dc0d208ab26daca419e6053 100644 --- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/dataset/NewExternalDataPredicateSystemTest.java +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/dataset/NewExternalDataPredicateSystemTest.java @@ -56,19 +56,6 @@ public abstract class NewExternalDataPredicateSystemTest<O> extends CommonPredic assertNoException(t); } } - - @Override - public void assertWithNonexistentObject(ProjectAuthorizationUser user, Throwable t, Object param) - { - if (user.isDisabledProjectUser()) - { - assertAuthorizationFailureExceptionThatNoRoles(t); - } else - { - assertNoException(t); - } - } - }; } 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 bd90af6115190d42223bbee1e8c2949fcab2ad90..47cc6abc3d30fa5513844014213217489dd654f6 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 @@ -94,18 +94,6 @@ public abstract class DeletionTechIdCollectionPredicateSystemTest extends Common assertException(t, UserFailureException.class, "No deletion technical id specified."); } } - - @Override - public void assertWithNonexistentObject(ProjectAuthorizationUser user, Throwable t, Object param) - { - if (user.isDisabledProjectUser()) - { - assertAuthorizationFailureExceptionThatNoRoles(t); - } else - { - assertNoException(t); - } - } }; } 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 index 584117de94b3b78a2045b9cb62dc882302b93454..56690c6e381244795ca636ed93a043f13f3ca200 100644 --- 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 @@ -98,17 +98,6 @@ public abstract class RevertDeletionPredicateSystemTest extends CommonPredicateS } } - @Override - public void assertWithNonexistentObject(ProjectAuthorizationUser user, Throwable t, Object param) - { - if (user.isDisabledProjectUser()) - { - assertAuthorizationFailureExceptionThatNoRoles(t); - } else - { - assertNoException(t); - } - } }; } 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 index 08c7cd41649c056d923b8810cdd31ca3dc4c86e1..b959af3f8df4957bbe66dfe717529c0bd12b0747 100644 --- 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 @@ -95,17 +95,6 @@ public abstract class V3DeletionIdPredicateSystemTest extends CommonPredicateSys } } - @Override - public void assertWithNonexistentObject(ProjectAuthorizationUser user, Throwable t, Object param) - { - if (user.isDisabledProjectUser()) - { - assertAuthorizationFailureExceptionThatNoRoles(t); - } else - { - assertNoException(t); - } - } }; } diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/entity/BasicEntityDescriptionPredicateSystemTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/entity/BasicEntityDescriptionPredicateSystemTest.java new file mode 100644 index 0000000000000000000000000000000000000000..f91b540750770bdc3c3201c776f2e59ae67860df --- /dev/null +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/entity/BasicEntityDescriptionPredicateSystemTest.java @@ -0,0 +1,60 @@ +/* + * 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.entity; + +import java.util.List; + +import ch.systemsx.cisd.common.exceptions.UserFailureException; +import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.ProjectAuthorizationUser; +import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.CommonPredicateSystemTest; +import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.CommonPredicateSystemTestAssertions; +import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.CommonPredicateSystemTestAssertionsDelegate; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.BasicEntityDescription; +import ch.systemsx.cisd.openbis.systemtest.authorization.predicate.entity.EntityPredicateTestService; + +/** + * @author pkupczyk + */ +public abstract class BasicEntityDescriptionPredicateSystemTest extends CommonPredicateSystemTest<BasicEntityDescription> +{ + + @Override + protected void evaluateObjects(ProjectAuthorizationUser user, List<BasicEntityDescription> objects, Object param) + { + getBean(EntityPredicateTestService.class).testBasicEntityDescriptionPredicate(user.getSessionProvider(), objects.get(0)); + } + + @Override + protected CommonPredicateSystemTestAssertions<BasicEntityDescription> getAssertions() + { + return new CommonPredicateSystemTestAssertionsDelegate<BasicEntityDescription>(super.getAssertions()) + { + @Override + public void assertWithNullObject(ProjectAuthorizationUser user, Throwable t, Object param) + { + if (user.isDisabledProjectUser()) + { + assertAuthorizationFailureExceptionThatNoRoles(t); + } else + { + assertException(t, UserFailureException.class, "No basic entity description specified."); + } + } + }; + } + +} diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/entity/BasicEntityDescriptionPredicateWithDataSetSystemTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/entity/BasicEntityDescriptionPredicateWithDataSetSystemTest.java new file mode 100644 index 0000000000000000000000000000000000000000..f111fbdf8fae810fdedca50717414eb5247443a6 --- /dev/null +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/entity/BasicEntityDescriptionPredicateWithDataSetSystemTest.java @@ -0,0 +1,60 @@ +/* + * 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.entity; + +import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.common.DataSetCodeUtil; +import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.CommonPredicateSystemTestAssertions; +import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.CommonPredicateSystemTestDataSetAssertions; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.BasicEntityDescription; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.EntityKind; +import ch.systemsx.cisd.openbis.generic.shared.dto.DataPE; +import ch.systemsx.cisd.openbis.generic.shared.dto.ProjectPE; +import ch.systemsx.cisd.openbis.generic.shared.dto.SpacePE; + +/** + * @author pkupczyk + */ +public class BasicEntityDescriptionPredicateWithDataSetSystemTest extends BasicEntityDescriptionPredicateSystemTest +{ + + @Override + public Object[] getParams() + { + return getDataSetKinds(); + } + + @Override + protected BasicEntityDescription createNonexistentObject(Object param) + { + String code = DataSetCodeUtil.createNonexistentObject(param); + return new BasicEntityDescription(EntityKind.DATA_SET, code); + } + + @Override + protected BasicEntityDescription createObject(SpacePE spacePE, ProjectPE projectPE, Object param) + { + DataPE dataSetPE = getDataSet(spacePE, projectPE, (DataSetKind) param); + return new BasicEntityDescription(EntityKind.DATA_SET, dataSetPE.getCode()); + } + + @Override + protected CommonPredicateSystemTestAssertions<BasicEntityDescription> getAssertions() + { + return new CommonPredicateSystemTestDataSetAssertions<BasicEntityDescription>(super.getAssertions()); + } + +} diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/entity/BasicEntityDescriptionPredicateWithExperimentSystemTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/entity/BasicEntityDescriptionPredicateWithExperimentSystemTest.java new file mode 100644 index 0000000000000000000000000000000000000000..12a7b7a15ea413cdaf560d8391f67e315abc751c --- /dev/null +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/entity/BasicEntityDescriptionPredicateWithExperimentSystemTest.java @@ -0,0 +1,72 @@ +/* + * 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.entity; + +import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.ProjectAuthorizationUser; +import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.common.ExperimentIdentifierUtil; +import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.CommonPredicateSystemTestAssertions; +import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.CommonPredicateSystemTestAssertionsDelegate; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.BasicEntityDescription; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.EntityKind; +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; +import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.ExperimentIdentifier; + +/** + * @author pkupczyk + */ +public class BasicEntityDescriptionPredicateWithExperimentSystemTest extends BasicEntityDescriptionPredicateSystemTest +{ + + @Override + protected BasicEntityDescription createNonexistentObject(Object param) + { + ExperimentIdentifier identifier = ExperimentIdentifierUtil.createNonexistentObject(param); + return new BasicEntityDescription(EntityKind.EXPERIMENT, identifier.toString()); + } + + @Override + protected BasicEntityDescription createObject(SpacePE spacePE, ProjectPE projectPE, Object param) + { + ExperimentPE experimentPE = getExperiment(spacePE, projectPE); + return new BasicEntityDescription(EntityKind.EXPERIMENT, experimentPE.getIdentifier()); + } + + @Override + protected CommonPredicateSystemTestAssertions<BasicEntityDescription> getAssertions() + { + return new CommonPredicateSystemTestAssertionsDelegate<BasicEntityDescription>(super.getAssertions()) + { + @Override + public void assertWithNonexistentObject(ProjectAuthorizationUser user, Throwable t, Object param) + { + if (user.isDisabledProjectUser()) + { + assertAuthorizationFailureExceptionThatNoRoles(t); + } else if (user.isInstanceUser()) + { + assertNoException(t); + } else + { + assertAuthorizationFailureExceptionThatNotEnoughPrivileges(t); + } + } + }; + } + +} diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/entity/BasicEntityDescriptionPredicateWithSampleSystemTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/entity/BasicEntityDescriptionPredicateWithSampleSystemTest.java new file mode 100644 index 0000000000000000000000000000000000000000..180b7ea96959f527e1c71a5a8286a94a98d7beb4 --- /dev/null +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/entity/BasicEntityDescriptionPredicateWithSampleSystemTest.java @@ -0,0 +1,77 @@ +/* + * 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.entity; + +import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.ProjectAuthorizationUser; +import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.common.SampleIdentifierUtil; +import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.CommonPredicateSystemTestAssertions; +import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.CommonPredicateSystemTestSampleAssertions; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.BasicEntityDescription; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.EntityKind; +import ch.systemsx.cisd.openbis.generic.shared.dto.ProjectPE; +import ch.systemsx.cisd.openbis.generic.shared.dto.SpacePE; +import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.SampleIdentifier; + +/** + * @author pkupczyk + */ +public class BasicEntityDescriptionPredicateWithSampleSystemTest extends BasicEntityDescriptionPredicateSystemTest +{ + + @Override + public Object[] getParams() + { + return getSampleKinds(SampleKind.SHARED_READ); + } + + @Override + protected BasicEntityDescription createNonexistentObject(Object param) + { + SampleIdentifier identifier = SampleIdentifierUtil.createNonexistentObject(param); + return new BasicEntityDescription(EntityKind.SAMPLE, identifier.toString()); + } + + @Override + protected BasicEntityDescription createObject(SpacePE spacePE, ProjectPE projectPE, Object param) + { + SampleIdentifier identifier = SampleIdentifierUtil.createObject(this, spacePE, projectPE, param); + return new BasicEntityDescription(EntityKind.SAMPLE, identifier.toString()); + } + + @Override + protected CommonPredicateSystemTestAssertions<BasicEntityDescription> getAssertions() + { + return new CommonPredicateSystemTestSampleAssertions<BasicEntityDescription>(super.getAssertions()) + { + @Override + public void assertWithNonexistentObject(ProjectAuthorizationUser user, Throwable t, Object param) + { + if (user.isDisabledProjectUser()) + { + assertAuthorizationFailureExceptionThatNoRoles(t); + } else if (user.isInstanceUser() || SampleKind.SHARED_READ.equals(param)) + { + assertNoException(t); + } else + { + assertAuthorizationFailureExceptionThatNotEnoughPrivileges(t); + } + } + }; + } + +} diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/experiment/ExperimentIdPredicateWithPermIdSystemTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/experiment/ExperimentIdPredicateWithPermIdSystemTest.java index 765e175be2030a8d361a9feb93312f61fa782182..08fa832272c81a76842bd2732d3b527162143e00 100644 --- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/experiment/ExperimentIdPredicateWithPermIdSystemTest.java +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/experiment/ExperimentIdPredicateWithPermIdSystemTest.java @@ -16,9 +16,6 @@ package ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.experiment; -import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.ProjectAuthorizationUser; -import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.CommonPredicateSystemTestAssertions; -import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.CommonPredicateSystemTestAssertionsDelegate; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.id.experiment.ExperimentPermIdId; import ch.systemsx.cisd.openbis.generic.shared.dto.ExperimentPE; import ch.systemsx.cisd.openbis.generic.shared.dto.ProjectPE; @@ -43,23 +40,4 @@ public class ExperimentIdPredicateWithPermIdSystemTest extends ExperimentIdPredi return new ExperimentPermIdId(experimentPE.getPermId()); } - @Override - protected CommonPredicateSystemTestAssertions<ExperimentPermIdId> getAssertions() - { - return new CommonPredicateSystemTestAssertionsDelegate<ExperimentPermIdId>(super.getAssertions()) - { - @Override - public void assertWithNonexistentObject(ProjectAuthorizationUser user, Throwable t, Object param) - { - if (user.isDisabledProjectUser()) - { - assertAuthorizationFailureExceptionThatNoRoles(t); - } else - { - assertNoException(t); - } - } - }; - } - } diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/experiment/ExperimentListPredicateSystemTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/experiment/ExperimentListPredicateSystemTest.java index cac493d95395108287cd054403e5cab165a449a1..52f5b71aa9495408b1b0542d32147d9609db21ed 100644 --- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/experiment/ExperimentListPredicateSystemTest.java +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/experiment/ExperimentListPredicateSystemTest.java @@ -106,6 +106,19 @@ public class ExperimentListPredicateSystemTest extends CommonPredicateSystemTest assertException(t, UserFailureException.class, "No experiment specified."); } } + + @Override + public void assertWithNonexistentObject(ProjectAuthorizationUser user, Throwable t, Object param) + { + if (user.isDisabledProjectUser()) + { + assertAuthorizationFailureExceptionThatNoRoles(t); + } else + { + assertAuthorizationFailureExceptionThatNotEnoughPrivileges(t); + } + } + }; } diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/experiment/ExperimentPermIdPredicateSystemTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/experiment/ExperimentPermIdPredicateSystemTest.java index 48c25ddc30ad7ac2c65241c6673391bf156bab37..f5f736bdefb8f2142452dd3eb55a08040425f401 100644 --- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/experiment/ExperimentPermIdPredicateSystemTest.java +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/experiment/ExperimentPermIdPredicateSystemTest.java @@ -70,18 +70,6 @@ public class ExperimentPermIdPredicateSystemTest extends CommonPredicateSystemTe assertException(t, UserFailureException.class, "No experiment perm id specified."); } } - - @Override - public void assertWithNonexistentObject(ProjectAuthorizationUser user, Throwable t, Object param) - { - if (user.isDisabledProjectUser()) - { - assertAuthorizationFailureExceptionThatNoRoles(t); - } else - { - assertNoException(t); - } - } }; } diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/experiment/ExperimentTechIdCollectionPredicateSystemTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/experiment/ExperimentTechIdCollectionPredicateSystemTest.java index 5acd8e07ea8fe28f2d1d5f58a095f6c3e64564a6..e6cbd15e17934e16ecf5e2de109df4ddbd0fb21d 100644 --- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/experiment/ExperimentTechIdCollectionPredicateSystemTest.java +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/experiment/ExperimentTechIdCollectionPredicateSystemTest.java @@ -88,18 +88,6 @@ public class ExperimentTechIdCollectionPredicateSystemTest extends CommonPredica assertException(t, UserFailureException.class, "No EXPERIMENT technical id collection specified."); } } - - @Override - public void assertWithNonexistentObject(ProjectAuthorizationUser user, Throwable t, Object param) - { - if (user.isDisabledProjectUser()) - { - assertAuthorizationFailureExceptionThatNoRoles(t); - } else - { - assertNoException(t); - } - } }; } diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/experiment/NewExperimentPredicateSystemTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/experiment/NewExperimentPredicateSystemTest.java index 604b94ab7ae51d179250291482cc3df825e2f4d9..f28ac501f669c7ae983ab54903b60a092bfd7478 100644 --- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/experiment/NewExperimentPredicateSystemTest.java +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/experiment/NewExperimentPredicateSystemTest.java @@ -68,18 +68,6 @@ public class NewExperimentPredicateSystemTest extends CommonPredicateSystemTest< assertException(t, UserFailureException.class, "No new experiment specified."); } } - - @Override - public void assertWithNonexistentObject(ProjectAuthorizationUser user, Throwable t, Object param) - { - if (user.isDisabledProjectUser()) - { - assertAuthorizationFailureExceptionThatNoRoles(t); - } else - { - assertNoException(t); - } - } }; } diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/project/NewProjectPredicateSystemTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/project/NewProjectPredicateSystemTest.java index 39bedd3dc208641eef0f92fb52c615c0b4d7fbdc..43c45aff1132a41c21413afd170e071f2f2cc6b7 100644 --- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/project/NewProjectPredicateSystemTest.java +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/project/NewProjectPredicateSystemTest.java @@ -68,18 +68,6 @@ public class NewProjectPredicateSystemTest extends CommonPredicateSystemTest<New assertException(t, UserFailureException.class, "No new project specified."); } } - - @Override - public void assertWithNonexistentObject(ProjectAuthorizationUser user, Throwable t, Object param) - { - if (user.isDisabledProjectUser()) - { - assertAuthorizationFailureExceptionThatNoRoles(t); - } else - { - assertNoException(t); - } - } }; } diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/project/ProjectIdPredicateWithPermIdSystemTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/project/ProjectIdPredicateWithPermIdSystemTest.java index 50e360313c7aa685af2e5a00bd7cdf03ccd80937..ee242b446d1f430c2993a831a926b74d4d16aa5c 100644 --- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/project/ProjectIdPredicateWithPermIdSystemTest.java +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/project/ProjectIdPredicateWithPermIdSystemTest.java @@ -68,18 +68,6 @@ public class ProjectIdPredicateWithPermIdSystemTest extends CommonPredicateSyste assertException(t, UserFailureException.class, "No project id specified."); } } - - @Override - public void assertWithNonexistentObject(ProjectAuthorizationUser user, Throwable t, Object param) - { - if (user.isDisabledProjectUser()) - { - assertAuthorizationFailureExceptionThatNoRoles(t); - } else - { - assertNoException(t); - } - } }; } diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/project/ProjectIdentifierExistingSpacePredicateSystemTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/project/ProjectIdentifierExistingSpacePredicateSystemTest.java index afbd04c0a95cd19a416ce0d8b05743b590a0d0df..65e397ac27f79f85e57020f976d25810710c7985 100644 --- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/project/ProjectIdentifierExistingSpacePredicateSystemTest.java +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/project/ProjectIdentifierExistingSpacePredicateSystemTest.java @@ -68,18 +68,6 @@ public class ProjectIdentifierExistingSpacePredicateSystemTest extends CommonPre assertException(t, UserFailureException.class, "No project specified."); } } - - @Override - public void assertWithNonexistentObject(ProjectAuthorizationUser user, Throwable t, Object param) - { - if (user.isDisabledProjectUser()) - { - assertAuthorizationFailureExceptionThatNoRoles(t); - } else - { - assertNoException(t); - } - } }; } diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/project/ProjectPermIdPredicateSystemTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/project/ProjectPermIdPredicateSystemTest.java index 99b70128db7e9a8db574f317fb653cb898869baf..d691ab16b3f3f2a5fcf108a6a6a495bd1cc30bbb 100644 --- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/project/ProjectPermIdPredicateSystemTest.java +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/project/ProjectPermIdPredicateSystemTest.java @@ -68,18 +68,6 @@ public class ProjectPermIdPredicateSystemTest extends CommonPredicateSystemTest< assertException(t, UserFailureException.class, "No project perm id specified."); } } - - @Override - public void assertWithNonexistentObject(ProjectAuthorizationUser user, Throwable t, Object param) - { - if (user.isDisabledProjectUser()) - { - assertAuthorizationFailureExceptionThatNoRoles(t); - } else - { - assertNoException(t); - } - } }; } diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/project/ProjectPermIdStringPredicateSystemTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/project/ProjectPermIdStringPredicateSystemTest.java index 3cf21bb59dea68544a3a8a4574d34fb412848b96..4bde9d121a1a3c88e1ddb9c35feb8ddf37ba6715 100644 --- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/project/ProjectPermIdStringPredicateSystemTest.java +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/project/ProjectPermIdStringPredicateSystemTest.java @@ -67,18 +67,6 @@ public class ProjectPermIdStringPredicateSystemTest extends CommonPredicateSyste assertException(t, UserFailureException.class, "No project perm id specified."); } } - - @Override - public void assertWithNonexistentObject(ProjectAuthorizationUser user, Throwable t, Object param) - { - if (user.isDisabledProjectUser()) - { - assertAuthorizationFailureExceptionThatNoRoles(t); - } else - { - assertNoException(t); - } - } }; } diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/project/ProjectTechIdCollectionPredicateSystemTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/project/ProjectTechIdCollectionPredicateSystemTest.java index c8b7a592e6f6df252369b371ee189ac665821593..551dbb849a4b8d63f4784dfe3c7137e90661fa07 100644 --- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/project/ProjectTechIdCollectionPredicateSystemTest.java +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/project/ProjectTechIdCollectionPredicateSystemTest.java @@ -86,18 +86,6 @@ public class ProjectTechIdCollectionPredicateSystemTest extends CommonPredicateS assertException(t, UserFailureException.class, "No PROJECT technical id collection specified."); } } - - @Override - public void assertWithNonexistentObject(ProjectAuthorizationUser user, Throwable t, Object param) - { - if (user.isDisabledProjectUser()) - { - assertAuthorizationFailureExceptionThatNoRoles(t); - } else - { - assertNoException(t); - } - } }; } diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/project/ProjectUpdatesPredicateWithPermIdSystemTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/project/ProjectUpdatesPredicateWithPermIdSystemTest.java index 7fc6ff4ff6bf5730a85183f6047a329119876f9b..6eae9601490ea53a28b50d87de64c9572a2253ac 100644 --- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/project/ProjectUpdatesPredicateWithPermIdSystemTest.java +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/project/ProjectUpdatesPredicateWithPermIdSystemTest.java @@ -72,18 +72,6 @@ public class ProjectUpdatesPredicateWithPermIdSystemTest extends CommonPredicate assertException(t, UserFailureException.class, "No project updates specified."); } } - - @Override - public void assertWithNonexistentObject(ProjectAuthorizationUser user, Throwable t, Object param) - { - if (user.isDisabledProjectUser()) - { - assertAuthorizationFailureExceptionThatNoRoles(t); - } else - { - assertNoException(t); - } - } }; } diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/sample/ListSampleCriteriaPredicateWithSampleSystemTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/sample/ListSampleCriteriaPredicateWithSampleSystemTest.java index afa1a5178f491271db94c8278ea09043bba495e9..af78946284d5ab6243ef75287f7e4085f774d0df 100644 --- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/sample/ListSampleCriteriaPredicateWithSampleSystemTest.java +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/sample/ListSampleCriteriaPredicateWithSampleSystemTest.java @@ -64,20 +64,7 @@ public abstract class ListSampleCriteriaPredicateWithSampleSystemTest extends Li @Override protected CommonPredicateSystemTestAssertions<ListSampleCriteria> getAssertions() { - return new CommonPredicateSystemTestSampleAssertions<ListSampleCriteria>(super.getAssertions()) - { - @Override - public void assertWithNonexistentObject(ProjectAuthorizationUser user, Throwable t, Object param) - { - if (user.isDisabledProjectUser()) - { - assertAuthorizationFailureExceptionThatNoRoles(t); - } else - { - assertNoException(t); - } - } - }; + return new CommonPredicateSystemTestSampleAssertions<ListSampleCriteria>(super.getAssertions()); } } diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/sample/ListSampleCriteriaPredicateWithSpaceSystemTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/sample/ListSampleCriteriaPredicateWithSpaceSystemTest.java index e1de513cc35122fc6e0dcd36a13fae8c2fecc28c..677481db05d105e5e7458db1340910c4a7c5a876 100644 --- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/sample/ListSampleCriteriaPredicateWithSpaceSystemTest.java +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/sample/ListSampleCriteriaPredicateWithSpaceSystemTest.java @@ -16,9 +16,6 @@ package ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.sample; -import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.ProjectAuthorizationUser; -import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.CommonPredicateSystemTestAssertions; -import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.CommonPredicateSystemTestAssertionsDelegate; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ListSampleCriteria; import ch.systemsx.cisd.openbis.generic.shared.dto.ProjectPE; import ch.systemsx.cisd.openbis.generic.shared.dto.SpacePE; @@ -47,23 +44,4 @@ public class ListSampleCriteriaPredicateWithSpaceSystemTest extends ListSampleCr return criteria; } - @Override - protected CommonPredicateSystemTestAssertions<ListSampleCriteria> getAssertions() - { - return new CommonPredicateSystemTestAssertionsDelegate<ListSampleCriteria>(super.getAssertions()) - { - @Override - public void assertWithNonexistentObject(ProjectAuthorizationUser user, Throwable t, Object param) - { - if (user.isDisabledProjectUser()) - { - assertAuthorizationFailureExceptionThatNoRoles(t); - } else - { - assertNoException(t); - } - } - }; - } - } diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/sample/NewSamplePredicateWithExperimentIdentifierSystemTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/sample/NewSamplePredicateWithExperimentIdentifierSystemTest.java index f527aacf73cdd850aa61dc0c4ced9070e75e5e66..6376c5f3fffeb21f762d1d87c17e1ea1717373eb 100644 --- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/sample/NewSamplePredicateWithExperimentIdentifierSystemTest.java +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/sample/NewSamplePredicateWithExperimentIdentifierSystemTest.java @@ -16,9 +16,6 @@ package ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.sample; -import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.ProjectAuthorizationUser; -import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.CommonPredicateSystemTestAssertions; -import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.CommonPredicateSystemTestAssertionsDelegate; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.NewSample; import ch.systemsx.cisd.openbis.generic.shared.dto.ExperimentPE; import ch.systemsx.cisd.openbis.generic.shared.dto.ProjectPE; @@ -48,23 +45,4 @@ public class NewSamplePredicateWithExperimentIdentifierSystemTest extends NewSam return newSample; } - @Override - protected CommonPredicateSystemTestAssertions<NewSample> getAssertions() - { - return new CommonPredicateSystemTestAssertionsDelegate<NewSample>(super.getAssertions()) - { - @Override - public void assertWithNonexistentObject(ProjectAuthorizationUser user, Throwable t, Object param) - { - if (user.isDisabledProjectUser()) - { - assertAuthorizationFailureExceptionThatNoRoles(t); - } else - { - assertNoException(t); - } - } - }; - } - } diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/sample/NewSamplePredicateWithProjectIdentifierSystemTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/sample/NewSamplePredicateWithProjectIdentifierSystemTest.java index a9e86898c644187a4b43cc76591dfbc6796445e1..fda6f6fc47961f0a66490e7d257678b41df0cfa7 100644 --- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/sample/NewSamplePredicateWithProjectIdentifierSystemTest.java +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/sample/NewSamplePredicateWithProjectIdentifierSystemTest.java @@ -16,9 +16,6 @@ package ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.sample; -import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.ProjectAuthorizationUser; -import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.CommonPredicateSystemTestAssertions; -import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.CommonPredicateSystemTestAssertionsDelegate; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.NewSample; import ch.systemsx.cisd.openbis.generic.shared.dto.ProjectPE; import ch.systemsx.cisd.openbis.generic.shared.dto.SpacePE; @@ -45,23 +42,4 @@ public class NewSamplePredicateWithProjectIdentifierSystemTest extends NewSample return newSample; } - @Override - protected CommonPredicateSystemTestAssertions<NewSample> getAssertions() - { - return new CommonPredicateSystemTestAssertionsDelegate<NewSample>(super.getAssertions()) - { - @Override - public void assertWithNonexistentObject(ProjectAuthorizationUser user, Throwable t, Object param) - { - if (user.isDisabledProjectUser()) - { - assertAuthorizationFailureExceptionThatNoRoles(t); - } else - { - assertNoException(t); - } - } - }; - } - } diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/sample/SampleAugmentedCodePredicateSystemTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/sample/SampleAugmentedCodePredicateSystemTest.java index 28a94df1ec79900e1bb2a625052539a6c3a24e57..6bcb5c02c9e1121410dc93cf177504bff0ed85f6 100644 --- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/sample/SampleAugmentedCodePredicateSystemTest.java +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/sample/SampleAugmentedCodePredicateSystemTest.java @@ -20,12 +20,13 @@ import java.util.List; import ch.systemsx.cisd.common.exceptions.UserFailureException; import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.ProjectAuthorizationUser; +import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.common.SampleIdentifierUtil; import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.CommonPredicateSystemTest; import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.CommonPredicateSystemTestAssertions; import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.CommonPredicateSystemTestSampleAssertions; 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.generic.shared.dto.identifier.SampleIdentifier; import ch.systemsx.cisd.openbis.systemtest.authorization.predicate.sample.SamplePredicateTestService; /** @@ -43,43 +44,15 @@ public class SampleAugmentedCodePredicateSystemTest extends CommonPredicateSyste @Override protected String createNonexistentObject(Object param) { - switch ((SampleKind) param) - { - case SHARED_READ: - return "/IDONTEXIST"; - case SPACE: - return "/IDONTEXIST/IDONTEXIST"; - case SPACE_CONTAINED: - return "/IDONTEXIST/IDONTEXIST:IDONTEXIST"; - case PROJECT: - return "/IDONTEXIST/IDONTEXIST/IDONTEXIST"; - case EXPERIMENT: - return "/IDONTEXIST/IDONTEXIST"; - default: - throw new RuntimeException(); - } + SampleIdentifier identifier = SampleIdentifierUtil.createNonexistentObject(param); + return identifier.toString(); } @Override protected String createObject(SpacePE spacePE, ProjectPE projectPE, Object param) { - SamplePE samplePE = getSample(spacePE, projectPE, (SampleKind) param); - - switch ((SampleKind) param) - { - case SHARED_READ: - return "/" + samplePE.getCode(); - case SPACE: - return "/" + spacePE.getCode() + "/" + samplePE.getCode(); - case SPACE_CONTAINED: - return "/" + spacePE.getCode() + "/" + samplePE.getContainer().getCode() + ":" + samplePE.getCode(); - case PROJECT: - return "/" + spacePE.getCode() + "/" + projectPE.getCode() + "/" + samplePE.getCode(); - case EXPERIMENT: - return "/" + spacePE.getCode() + "/" + samplePE.getCode(); - default: - throw new RuntimeException(); - } + SampleIdentifier identifier = SampleIdentifierUtil.createObject(this, spacePE, projectPE, param); + return identifier.toString(); } @Override diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/sample/SampleIdPredicateWithSampleTechIdSystemTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/sample/SampleIdPredicateWithSampleTechIdSystemTest.java index 91b3f706721123c6932f28314c4fe07676abe08d..63647a2adf7ccadf144ac92ef2ef27b1aaf9cbf7 100644 --- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/sample/SampleIdPredicateWithSampleTechIdSystemTest.java +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/sample/SampleIdPredicateWithSampleTechIdSystemTest.java @@ -16,10 +16,7 @@ package ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.sample; -import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.ProjectAuthorizationUser; import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.common.SampleTechIdUtil; -import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.CommonPredicateSystemTestAssertions; -import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.CommonPredicateSystemTestAssertionsDelegate; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.id.sample.ISampleId; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.id.sample.SampleTechIdId; import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; @@ -46,23 +43,4 @@ public class SampleIdPredicateWithSampleTechIdSystemTest extends SampleIdPredica return new SampleTechIdId(techId.getId()); } - @Override - protected CommonPredicateSystemTestAssertions<ISampleId> getAssertions() - { - return new CommonPredicateSystemTestAssertionsDelegate<ISampleId>(super.getAssertions()) - { - @Override - public void assertWithNonexistentObject(ProjectAuthorizationUser user, Throwable t, Object param) - { - if (user.isDisabledProjectUser()) - { - assertAuthorizationFailureExceptionThatNoRoles(t); - } else - { - assertNoException(t); - } - } - }; - } - } diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/sample/SampleTechIdCollectionPredicateSystemTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/sample/SampleTechIdCollectionPredicateSystemTest.java index 60ddf7dfebb1916d4432c9789591b2548f2d304e..9cb3723dd196c4582dc50cdc000787704dbac445 100644 --- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/sample/SampleTechIdCollectionPredicateSystemTest.java +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/sample/SampleTechIdCollectionPredicateSystemTest.java @@ -93,18 +93,6 @@ public class SampleTechIdCollectionPredicateSystemTest extends CommonPredicateSy assertException(t, UserFailureException.class, "No sample technical ids specified."); } } - - @Override - public void assertWithNonexistentObject(ProjectAuthorizationUser user, Throwable t, Object param) - { - if (user.isDisabledProjectUser()) - { - assertAuthorizationFailureExceptionThatNoRoles(t); - } else - { - assertNoException(t); - } - } }; } diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/sample/SampleTechIdPredicateSystemTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/sample/SampleTechIdPredicateSystemTest.java index 2225ff49f6decb4ae24ac94b1f93d29d260349b7..08e177462b864987f7917b744d9e535ffb703e37 100644 --- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/sample/SampleTechIdPredicateSystemTest.java +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/sample/SampleTechIdPredicateSystemTest.java @@ -75,18 +75,6 @@ public class SampleTechIdPredicateSystemTest extends CommonPredicateSystemTest<T assertException(t, UserFailureException.class, "No sample technical id specified."); } } - - @Override - public void assertWithNonexistentObject(ProjectAuthorizationUser user, Throwable t, Object param) - { - if (user.isDisabledProjectUser()) - { - assertAuthorizationFailureExceptionThatNoRoles(t); - } else - { - assertNoException(t); - } - } }; } diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/sample/SampleUpdatesPredicateWithSampleTechIdSystemTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/sample/SampleUpdatesPredicateWithSampleTechIdSystemTest.java index 82b3b99e84197821a3072fe88527e3dde9f75c02..378893a0f22b75a38741eac674ed1bd7c68871f1 100644 --- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/sample/SampleUpdatesPredicateWithSampleTechIdSystemTest.java +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/sample/SampleUpdatesPredicateWithSampleTechIdSystemTest.java @@ -16,10 +16,7 @@ package ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.sample; -import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.ProjectAuthorizationUser; import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.common.SampleTechIdUtil; -import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.CommonPredicateSystemTestAssertions; -import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.CommonPredicateSystemTestAssertionsDelegate; 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.SampleUpdatesDTO; @@ -45,23 +42,4 @@ public class SampleUpdatesPredicateWithSampleTechIdSystemTest extends SampleUpda return new SampleUpdatesDTO(techId, null, null, null, null, 0, null, null, null); } - @Override - protected CommonPredicateSystemTestAssertions<SampleUpdatesDTO> getAssertions() - { - return new CommonPredicateSystemTestAssertionsDelegate<SampleUpdatesDTO>(super.getAssertions()) - { - @Override - public void assertWithNonexistentObject(ProjectAuthorizationUser user, Throwable t, Object param) - { - if (user.isDisabledProjectUser()) - { - assertAuthorizationFailureExceptionThatNoRoles(t); - } else - { - assertNoException(t); - } - } - }; - } - } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/CommonServer.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/CommonServer.java index 97db5241bc1206844677e64adb8e5df6ec22fb58..aa3b83f67fa56481bd7554aa00bf37760a9ebec9 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/CommonServer.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/CommonServer.java @@ -3585,7 +3585,7 @@ public final class CommonServer extends AbstractCommonServer<ICommonServerForInt } @Override - @RolesAllowed(RoleWithHierarchy.SPACE_OBSERVER) + @RolesAllowed(RoleWithHierarchy.PROJECT_OBSERVER) public IEntityInformationHolderWithPermId getEntityInformationHolder(String sessionToken, @AuthorizationGuard(guardClass = BasicEntityDescriptionPredicate.class) BasicEntityDescription info) { diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/api/v1/GeneralInformationService.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/api/v1/GeneralInformationService.java index 41680409840f81763fd6b5fc99633b591785220d..fbddb097e39838ac9ca53496a3965360ac7f8dd1 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/api/v1/GeneralInformationService.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/api/v1/GeneralInformationService.java @@ -975,7 +975,7 @@ public class GeneralInformationService extends AbstractServer<IGeneralInformatio @Override @Transactional(readOnly = true) - @RolesAllowed(RoleWithHierarchy.SPACE_OBSERVER) + @RolesAllowed(RoleWithHierarchy.PROJECT_OBSERVER) // There is no @ReturnValueFilter because commonServer.searchForDataSetsWithSequences() does already the filtering. public List<SearchDomainSearchResult> searchOnSearchDomain(String sessionToken, String preferredSearchDomainOrNull, String searchString, Map<String, String> optionalParametersOrNull) @@ -994,7 +994,7 @@ public class GeneralInformationService extends AbstractServer<IGeneralInformatio @Override @Transactional(readOnly = true) - @RolesAllowed(RoleWithHierarchy.SPACE_OBSERVER) + @RolesAllowed(RoleWithHierarchy.PROJECT_OBSERVER) public List<SearchDomain> listAvailableSearchDomains(String sessionToken) { checkSession(sessionToken); diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/CommonServerTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/CommonServerTest.java index 17779ab96afee6d877e02bce0a63e69700d58eaa..c4f20e504eacba848561665146f546ce9e9dc7e5 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/CommonServerTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/CommonServerTest.java @@ -55,6 +55,7 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.AbstractExternalData; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Attachment; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.AttachmentWithContent; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.AuthorizationGroup; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.BasicEntityDescription; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ContainerDataSet; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetRelatedEntities; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetRelationshipRole; @@ -3047,7 +3048,7 @@ public class CommonServerTest extends SystemTestCase } @Test(dataProviderClass = ProjectAuthorizationUser.class, dataProvider = ProjectAuthorizationUser.PROVIDER) - public void testGetEntityInformationHolderWithProjectAuthorization(ProjectAuthorizationUser user) + public void testGetEntityInformationHolderByPermIdWithProjectAuthorization(ProjectAuthorizationUser user) { SessionContextDTO session = commonServer.tryAuthenticate(user.getUserId(), PASSWORD); @@ -3071,6 +3072,32 @@ public class CommonServerTest extends SystemTestCase } } + @Test(dataProviderClass = ProjectAuthorizationUser.class, dataProvider = ProjectAuthorizationUser.PROVIDER) + public void testGetEntityInformationHolderByDescriptionWithProjectAuthorization(ProjectAuthorizationUser user) + { + SessionContextDTO session = commonServer.tryAuthenticate(user.getUserId(), PASSWORD); + + BasicEntityDescription description = new BasicEntityDescription(); + description.setEntityIdentifier("/TEST-SPACE/TEST-PROJECT/EXP-SPACE-TEST"); + description.setEntityKind(EntityKind.EXPERIMENT); + + if (user.isInstanceUserOrTestSpaceUserOrEnabledTestProjectUser()) + { + IEntityInformationHolderWithPermId entity = commonServer.getEntityInformationHolder(session.getSessionToken(), description); + assertEquals(entity.getCode(), "EXP-SPACE-TEST"); + } else + { + try + { + commonServer.getEntityInformationHolder(session.getSessionToken(), description); + fail(); + } catch (AuthorizationFailureException e) + { + // expected + } + } + } + private void assertAssignedPropertyTypes(String expected, EntityType entityType) { List<? extends EntityTypePropertyType<?>> propTypes = entityType.getAssignedPropertyTypes(); diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/authorization/predicate/entity/EntityPredicateTestService.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/authorization/predicate/entity/EntityPredicateTestService.java new file mode 100644 index 0000000000000000000000000000000000000000..382401d176123ef0d50ef37c5fdda7d225c8a23d --- /dev/null +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/authorization/predicate/entity/EntityPredicateTestService.java @@ -0,0 +1,43 @@ +/* + * 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.systemtest.authorization.predicate.entity; + +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +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.BasicEntityDescriptionPredicate; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.BasicEntityDescription; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.RoleWithHierarchy; +import ch.systemsx.cisd.openbis.generic.shared.dto.IAuthSessionProvider; + +/** + * @author pkupczyk + */ +@Component +public class EntityPredicateTestService +{ + + @Transactional + @RolesAllowed(value = { RoleWithHierarchy.PROJECT_OBSERVER }) + public void testBasicEntityDescriptionPredicate(IAuthSessionProvider sessionProvider, + @AuthorizationGuard(guardClass = BasicEntityDescriptionPredicate.class) BasicEntityDescription description) + { + } + +} diff --git a/screening/sourceTest/java/ch/systemsx/cisd/openbis/screening/systemtests/authorization/predicate/dataset/DataSetReferencePredicateSystemTest.java b/screening/sourceTest/java/ch/systemsx/cisd/openbis/screening/systemtests/authorization/predicate/dataset/DataSetReferencePredicateSystemTest.java index 72ecc5b6f1e8df23e7decb271ea4a80fb64ed107..29696c5ba7db8945400976a4831c593481960204 100644 --- a/screening/sourceTest/java/ch/systemsx/cisd/openbis/screening/systemtests/authorization/predicate/dataset/DataSetReferencePredicateSystemTest.java +++ b/screening/sourceTest/java/ch/systemsx/cisd/openbis/screening/systemtests/authorization/predicate/dataset/DataSetReferencePredicateSystemTest.java @@ -21,8 +21,8 @@ import java.util.List; import ch.systemsx.cisd.common.exceptions.UserFailureException; import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.ProjectAuthorizationUser; import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.common.DataSetCodeUtil; -import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.CommonPredicateSystemTestDataSetAssertions; import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.CommonPredicateSystemTestAssertions; +import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.CommonPredicateSystemTestDataSetAssertions; import ch.systemsx.cisd.openbis.generic.shared.dto.ProjectPE; import ch.systemsx.cisd.openbis.generic.shared.dto.SpacePE; import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.DatasetReference; @@ -76,18 +76,6 @@ public class DataSetReferencePredicateSystemTest extends CommonPredicateScreenin assertException(t, UserFailureException.class, "No data set reference specified."); } } - - @Override - public void assertWithNonexistentObject(ProjectAuthorizationUser user, Throwable t, Object param) - { - if (user.isDisabledProjectUser()) - { - assertAuthorizationFailureExceptionThatNoRoles(t); - } else - { - assertNoException(t); - } - } }; } diff --git a/screening/sourceTest/java/ch/systemsx/cisd/openbis/screening/systemtests/authorization/predicate/sample/ScreeningPlateListReadOnlyPredicateWithPermIdSystemTest.java b/screening/sourceTest/java/ch/systemsx/cisd/openbis/screening/systemtests/authorization/predicate/sample/ScreeningPlateListReadOnlyPredicateWithPermIdSystemTest.java index c6406989f02ed258d0db647f9a21ca56f028e39d..0a18272c7b050ad5b9021ac64fcd1e460d81881b 100644 --- a/screening/sourceTest/java/ch/systemsx/cisd/openbis/screening/systemtests/authorization/predicate/sample/ScreeningPlateListReadOnlyPredicateWithPermIdSystemTest.java +++ b/screening/sourceTest/java/ch/systemsx/cisd/openbis/screening/systemtests/authorization/predicate/sample/ScreeningPlateListReadOnlyPredicateWithPermIdSystemTest.java @@ -16,9 +16,6 @@ package ch.systemsx.cisd.openbis.screening.systemtests.authorization.predicate.sample; -import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.ProjectAuthorizationUser; -import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.CommonPredicateSystemTestAssertions; -import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.CommonPredicateSystemTestAssertionsDelegate; import ch.systemsx.cisd.openbis.generic.shared.dto.ProjectPE; import ch.systemsx.cisd.openbis.generic.shared.dto.SpacePE; import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.PlateIdentifier; @@ -41,23 +38,4 @@ public class ScreeningPlateListReadOnlyPredicateWithPermIdSystemTest extends Scr return PlateIdentifierUtil.createObjectWithPermId(this, spacePE, projectPE, param); } - @Override - protected CommonPredicateSystemTestAssertions<PlateIdentifier> getAssertions() - { - return new CommonPredicateSystemTestAssertionsDelegate<PlateIdentifier>(super.getAssertions()) - { - @Override - public void assertWithNonexistentObject(ProjectAuthorizationUser user, Throwable t, Object param) - { - if (user.isDisabledProjectUser()) - { - assertAuthorizationFailureExceptionThatNoRoles(t); - } else - { - assertNoException(t); - } - } - }; - } - }