Skip to content
Snippets Groups Projects
Commit 286d680d authored by pkupczyk's avatar pkupczyk
Browse files

SSDM-1771 : V3 AS API - create tests to verify whether the capabilities work in the new API

SVN: 34372
parent cbc2604d
No related branches found
No related tags found
No related merge requests found
Showing
with 227 additions and 23 deletions
......@@ -16,17 +16,10 @@
package ch.ethz.sis.openbis.generic.server.api.v3.executor.property;
import java.util.Map;
import ch.ethz.sis.openbis.generic.server.api.v3.executor.IOperationContext;
import ch.systemsx.cisd.openbis.generic.shared.dto.IEntityPropertiesHolder;
/**
* @author pkupczyk
*/
public interface IUpdateEntityPropertyExecutor
public interface IUpdateEntityPropertyExecutor extends IAbstractUpdateEntityPropertyExecutor
{
public void update(IOperationContext context, Map<IEntityPropertiesHolder, Map<String, String>> entityToPropertiesMap);
}
/*
* Copyright 2015 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.ethz.sis.openbis.generic.server.api.v3.executor.sample;
import ch.ethz.sis.openbis.generic.server.api.v3.executor.attachment.IAbstractUpdateAttachmentForEntityExecutor;
/**
* @author pkupczyk
*/
public interface IUpdateSampleAttachmentExecutor extends IAbstractUpdateAttachmentForEntityExecutor
{
}
/*
* Copyright 2015 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.ethz.sis.openbis.generic.server.api.v3.executor.sample;
import ch.ethz.sis.openbis.generic.server.api.v3.executor.property.IAbstractUpdateEntityPropertyExecutor;
/**
* @author pkupczyk
*/
public interface IUpdateSamplePropertyExecutor extends IAbstractUpdateEntityPropertyExecutor
{
}
/*
* Copyright 2015 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.ethz.sis.openbis.generic.server.api.v3.executor.sample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import ch.ethz.sis.openbis.generic.server.api.v3.executor.IOperationContext;
import ch.ethz.sis.openbis.generic.server.api.v3.executor.attachment.IUpdateAttachmentForEntityExecutor;
import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.AttachmentListUpdateValue;
import ch.systemsx.cisd.openbis.generic.server.authorization.annotation.Capability;
import ch.systemsx.cisd.openbis.generic.server.authorization.annotation.RolesAllowed;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.RoleWithHierarchy;
import ch.systemsx.cisd.openbis.generic.shared.dto.AttachmentHolderPE;
/**
* @author pkupczyk
*/
@Component
public class UpdateSampleAttachmentExecutor implements IUpdateSampleAttachmentExecutor
{
@Autowired
private IUpdateAttachmentForEntityExecutor executor;
@Override
@RolesAllowed({ RoleWithHierarchy.SPACE_USER, RoleWithHierarchy.SPACE_ETL_SERVER })
@Capability("UPDATE_SAMPLE_ATTACHMENT")
public void update(IOperationContext context, AttachmentHolderPE attachmentHolder, AttachmentListUpdateValue updates)
{
executor.update(context, attachmentHolder, updates);
}
}
......@@ -26,9 +26,7 @@ import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Component;
import ch.ethz.sis.openbis.generic.server.api.v3.executor.IOperationContext;
import ch.ethz.sis.openbis.generic.server.api.v3.executor.attachment.IUpdateAttachmentForEntityExecutor;
import ch.ethz.sis.openbis.generic.server.api.v3.executor.entity.AbstractUpdateEntityExecutor;
import ch.ethz.sis.openbis.generic.server.api.v3.executor.property.IUpdateEntityPropertyExecutor;
import ch.ethz.sis.openbis.generic.server.api.v3.executor.tag.IUpdateTagForEntityExecutor;
import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.sample.SampleUpdate;
import ch.ethz.sis.openbis.generic.shared.api.v3.dto.id.sample.ISampleId;
......@@ -65,13 +63,13 @@ public class UpdateSampleExecutor extends AbstractUpdateEntityExecutor<SampleUpd
private IUpdateSampleRelatedSamplesExecutor updateSampleRelatedSamplesExecutor;
@Autowired
private IUpdateEntityPropertyExecutor updateEntityPropertyExecutor;
private IUpdateSamplePropertyExecutor updateSamplePropertyExecutor;
@Autowired
private IUpdateTagForEntityExecutor updateTagForEntityExecutor;
@Autowired
private IUpdateAttachmentForEntityExecutor updateAttachmentForEntityExecutor;
private IUpdateSampleAttachmentExecutor updateSampleAttachmentExecutor;
@Autowired
private IVerifySampleExecutor verifySampleExecutor;
......@@ -120,11 +118,22 @@ public class UpdateSampleExecutor extends AbstractUpdateEntityExecutor<SampleUpd
RelationshipUtils.updateModificationDateAndModifier(entity, context.getSession().tryGetPerson());
updateTagForEntityExecutor.update(context, entity, update.getTagIds());
updateAttachmentForEntityExecutor.update(context, entity, update.getAttachments());
propertyMap.put(entity, update.getProperties());
if (update.getAttachments() != null && update.getAttachments().hasActions())
{
updateSampleAttachmentExecutor.update(context, entity, update.getAttachments());
}
if (update.getProperties() != null && false == update.getProperties().isEmpty())
{
propertyMap.put(entity, update.getProperties());
}
}
updateEntityPropertyExecutor.update(context, propertyMap);
if (false == propertyMap.isEmpty())
{
updateSamplePropertyExecutor.update(context, propertyMap);
}
}
@Override
......
/*
* Copyright 2015 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.ethz.sis.openbis.generic.server.api.v3.executor.sample;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import ch.ethz.sis.openbis.generic.server.api.v3.executor.IOperationContext;
import ch.ethz.sis.openbis.generic.server.api.v3.executor.property.IUpdateEntityPropertyExecutor;
import ch.systemsx.cisd.openbis.generic.server.authorization.annotation.Capability;
import ch.systemsx.cisd.openbis.generic.server.authorization.annotation.RolesAllowed;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.RoleWithHierarchy;
import ch.systemsx.cisd.openbis.generic.shared.dto.IEntityPropertiesHolder;
/**
* @author pkupczyk
*/
@Component
public class UpdateSamplePropertyExecutor implements IUpdateSamplePropertyExecutor
{
@Autowired
private IUpdateEntityPropertyExecutor executor;
@Override
@RolesAllowed({ RoleWithHierarchy.SPACE_USER, RoleWithHierarchy.SPACE_ETL_SERVER })
@Capability("UPDATE_SAMPLE_PROPERTY")
public void update(IOperationContext context, Map<IEntityPropertiesHolder, Map<String, String>> entityToPropertiesMap)
{
executor.update(context, entityToPropertiesMap);
}
}
......@@ -44,6 +44,7 @@ import ch.systemsx.cisd.openbis.generic.server.authorization.annotation.RolesAll
import ch.systemsx.cisd.openbis.generic.server.util.MethodInvocationUtils;
import ch.systemsx.cisd.openbis.generic.shared.ISessionProvider;
import ch.systemsx.cisd.openbis.generic.shared.dto.IAuthSession;
import ch.systemsx.cisd.openbis.generic.shared.dto.IAuthSessionProvider;
/**
* The <i>openBIS</i> authorization {@link Advisor}.
......@@ -122,7 +123,7 @@ public final class AuthorizationAdvisor extends DefaultPointcutAdvisor
}
@SuppressWarnings(
{ "unchecked", "rawtypes" })
{ "unchecked", "rawtypes" })
private final static Argument<?> toArgument(final Parameter<AuthorizationGuard> parameter,
final Object[] args)
{
......@@ -178,6 +179,11 @@ public final class AuthorizationAdvisor extends DefaultPointcutAdvisor
IAuthSession session = (IAuthSession) firstObject;
return session;
}
if (firstObject instanceof IAuthSessionProvider)
{
IAuthSessionProvider sessionProvider = (IAuthSessionProvider) firstObject;
return sessionProvider.getSession();
}
if (firstObject instanceof String)
{
String sessionToken = (String) firstObject;
......
/*
* Copyright 2015 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.generic.shared.dto;
/**
* @author pkupczyk
*/
public interface IAuthSessionProvider
{
IAuthSession getSession();
}
......@@ -181,6 +181,19 @@ public class CreateProjectTest extends AbstractTest
}, leaderId);
}
@Test
public void testCreateWithCapabilitySet()
{
final String sessionToken = v3api.login(TEST_GROUP_OBSERVER, PASSWORD);
final ISpaceId spaceId = new SpacePermId("TESTGROUP");
final ProjectCreation project = new ProjectCreation();
project.setCode("CAN_I_DO_THIS");
project.setSpaceId(spaceId);
v3api.createProjects(sessionToken, Arrays.asList(project));
}
@Test
public void testCreateWithMultipleProjects()
{
......
<suite name="v3" verbose="2" >
<test name="unit" annotations="JDK">
<packages>
<package name="ch.ethz.sis.openbis.generic.server.api.v3.*" />
<package name="ch.ethz.sis.openbis.systemtest.api.v3.*" />
</packages>
</test>
<suite name="v3" verbose="2">
<test name="unit" annotations="JDK">
<groups>
<run>
<exclude name="system-cleandb" />
</run>
</groups>
<packages>
<package name="ch.ethz.sis.openbis.generic.server.api.v3.*" />
<package name="ch.ethz.sis.openbis.systemtest.api.v3.*" />
</packages>
</test>
</suite>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment