Merge branch 'maint-rel-1.6' into develop

This commit is contained in:
j2blake 2013-10-26 18:02:59 -04:00
commit f11d9ef100
2 changed files with 29 additions and 34 deletions

View file

@ -1,6 +1,8 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */ /* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators; package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators;
import static edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestActionConstants.SOME_LITERAL;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -335,7 +337,7 @@ public class ManageLabelsForPersonGenerator extends BaseEditConfigurationGenerat
Individual individual = EditConfigurationUtils.getIndividual(vreq, config.getSubjectUri()); Individual individual = EditConfigurationUtils.getIndividual(vreq, config.getSubjectUri());
AddDataPropertyStatement adps = new AddDataPropertyStatement( AddDataPropertyStatement adps = new AddDataPropertyStatement(
vreq.getJenaOntModel(), individual.getURI(), vreq.getJenaOntModel(), individual.getURI(),
RequestActionConstants.SOME_URI); RequestActionConstants.SOME_URI, SOME_LITERAL);
AddObjectPropertyStatement aops = new AddObjectPropertyStatement( AddObjectPropertyStatement aops = new AddObjectPropertyStatement(
vreq.getJenaOntModel(), individual.getURI(), vreq.getJenaOntModel(), individual.getURI(),

View file

@ -4,6 +4,7 @@ package edu.cornell.mannlib.vivo.auth.policy;
import static edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.Authorization.AUTHORIZED; import static edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.Authorization.AUTHORIZED;
import static edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.Authorization.INCONCLUSIVE; import static edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.Authorization.INCONCLUSIVE;
import static edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestActionConstants.SOME_LITERAL;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
@ -44,10 +45,9 @@ import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
/** /**
* Check the relationships in the SelfEditorRelationshipPolicy. * Check the relationships in the SelfEditorRelationshipPolicy.
* *
* This only checks the relationships that deal with InfoContentEntitys. * This only checks the relationships that deal with InfoContentEntitys. Testing
* Testing the others seems too redundant. If we generalize this to use * the others seems too redundant. If we generalize this to use configurable
* configurable relationships, then we'll be able to make more general tests as * relationships, then we'll be able to make more general tests as well.
* well.
*/ */
public class SelfEditorRelationshipPolicyTest extends AbstractTestClass { public class SelfEditorRelationshipPolicyTest extends AbstractTestClass {
private static final Log log = LogFactory private static final Log log = LogFactory
@ -69,12 +69,12 @@ public class SelfEditorRelationshipPolicyTest extends AbstractTestClass {
private static final String URI_PERMITTED_PREDICATE = NS_PERMITTED private static final String URI_PERMITTED_PREDICATE = NS_PERMITTED
+ "permittedPredicate"; + "permittedPredicate";
private static final Property PERMITTED_PREDICATE = new Property( private static final Property PERMITTED_PREDICATE = new Property(
URI_PERMITTED_PREDICATE); URI_PERMITTED_PREDICATE);
private static final String URI_RESTRICTED_PREDICATE = NS_RESTRICTED private static final String URI_RESTRICTED_PREDICATE = NS_RESTRICTED
+ "restrictedPredicate"; + "restrictedPredicate";
private static final Property RESTRICTED_PREDICATE = new Property( private static final Property RESTRICTED_PREDICATE = new Property(
URI_RESTRICTED_PREDICATE); URI_RESTRICTED_PREDICATE);
/** /**
* Where the model statements are stored for this test. * Where the model statements are stored for this test.
@ -185,30 +185,28 @@ public class SelfEditorRelationshipPolicyTest extends AbstractTestClass {
@Test @Test
public void dataPropSubjectIsRestricted() { public void dataPropSubjectIsRestricted() {
action = new AddDataPropertyStatement(ontModel, action = new AddDataPropertyStatement(ontModel,
URI_RESTRICTED_RESOURCE, URI_PERMITTED_PREDICATE); URI_RESTRICTED_RESOURCE, URI_PERMITTED_PREDICATE, SOME_LITERAL);
assertDecision(INCONCLUSIVE, policy.isAuthorized(idJoe, action)); assertDecision(INCONCLUSIVE, policy.isAuthorized(idJoe, action));
} }
@Test @Test
public void dataPropPredicateIsRestricted() { public void dataPropPredicateIsRestricted() {
action = new AddDataPropertyStatement(ontModel, URI_JOE_EDITED_IT, action = new AddDataPropertyStatement(ontModel, URI_JOE_EDITED_IT,
URI_RESTRICTED_PREDICATE); URI_RESTRICTED_PREDICATE, SOME_LITERAL);
assertDecision(INCONCLUSIVE, policy.isAuthorized(idJoe, action)); assertDecision(INCONCLUSIVE, policy.isAuthorized(idJoe, action));
} }
@Test @Test
public void objectPropSubjectIsRestricted() { public void objectPropSubjectIsRestricted() {
action = new AddObjectPropertyStatement(ontModel, action = new AddObjectPropertyStatement(ontModel,
URI_RESTRICTED_RESOURCE, PERMITTED_PREDICATE, URI_RESTRICTED_RESOURCE, PERMITTED_PREDICATE, URI_JOE_EDITED_IT);
URI_JOE_EDITED_IT);
assertDecision(INCONCLUSIVE, policy.isAuthorized(idJoe, action)); assertDecision(INCONCLUSIVE, policy.isAuthorized(idJoe, action));
} }
@Test @Test
public void objectPropPredicateIsRestricted() { public void objectPropPredicateIsRestricted() {
action = new AddObjectPropertyStatement(ontModel, action = new AddObjectPropertyStatement(ontModel,
URI_PERMITTED_RESOURCE, RESTRICTED_PREDICATE, URI_PERMITTED_RESOURCE, RESTRICTED_PREDICATE, URI_JOE_EDITED_IT);
URI_JOE_EDITED_IT);
assertDecision(INCONCLUSIVE, policy.isAuthorized(idJoe, action)); assertDecision(INCONCLUSIVE, policy.isAuthorized(idJoe, action));
} }
@ -226,14 +224,14 @@ public class SelfEditorRelationshipPolicyTest extends AbstractTestClass {
@Test @Test
public void dataPropSubjectIsIceButNobodyIsSelfEditing() { public void dataPropSubjectIsIceButNobodyIsSelfEditing() {
action = new AddDataPropertyStatement(ontModel, URI_JOE_WROTE_IT, action = new AddDataPropertyStatement(ontModel, URI_JOE_WROTE_IT,
URI_PERMITTED_PREDICATE); URI_PERMITTED_PREDICATE, SOME_LITERAL);
assertDecision(INCONCLUSIVE, policy.isAuthorized(idNobody, action)); assertDecision(INCONCLUSIVE, policy.isAuthorized(idNobody, action));
} }
@Test @Test
public void dataPropSubjectIsIceButNoAuthorsOrEditorsOrFeatured() { public void dataPropSubjectIsIceButNoAuthorsOrEditorsOrFeatured() {
action = new AddDataPropertyStatement(ontModel, URI_NOBODY_WROTE_IT, action = new AddDataPropertyStatement(ontModel, URI_NOBODY_WROTE_IT,
URI_PERMITTED_PREDICATE); URI_PERMITTED_PREDICATE, SOME_LITERAL);
assertDecision(INCONCLUSIVE, policy.isAuthorized(idJoe, action)); assertDecision(INCONCLUSIVE, policy.isAuthorized(idJoe, action));
assertDecision(INCONCLUSIVE, policy.isAuthorized(idBozoAndJoe, action)); assertDecision(INCONCLUSIVE, policy.isAuthorized(idBozoAndJoe, action));
} }
@ -241,28 +239,28 @@ public class SelfEditorRelationshipPolicyTest extends AbstractTestClass {
@Test @Test
public void dataPropSubjectIsIceButWrongAuthor() { public void dataPropSubjectIsIceButWrongAuthor() {
action = new AddDataPropertyStatement(ontModel, URI_BOZO_WROTE_IT, action = new AddDataPropertyStatement(ontModel, URI_BOZO_WROTE_IT,
URI_PERMITTED_PREDICATE); URI_PERMITTED_PREDICATE, SOME_LITERAL);
assertDecision(INCONCLUSIVE, policy.isAuthorized(idJoe, action)); assertDecision(INCONCLUSIVE, policy.isAuthorized(idJoe, action));
} }
@Test @Test
public void dataPropSubjectIsIceButWrongEditor() { public void dataPropSubjectIsIceButWrongEditor() {
action = new AddDataPropertyStatement(ontModel, URI_BOZO_EDITED_IT, action = new AddDataPropertyStatement(ontModel, URI_BOZO_EDITED_IT,
URI_PERMITTED_PREDICATE); URI_PERMITTED_PREDICATE, SOME_LITERAL);
assertDecision(INCONCLUSIVE, policy.isAuthorized(idJoe, action)); assertDecision(INCONCLUSIVE, policy.isAuthorized(idJoe, action));
} }
@Test @Test
public void dataPropSubjectIsIceButWrongFeatured() { public void dataPropSubjectIsIceButWrongFeatured() {
action = new AddDataPropertyStatement(ontModel, action = new AddDataPropertyStatement(ontModel,
URI_BOZO_FEATURED_IN_IT, URI_PERMITTED_PREDICATE); URI_BOZO_FEATURED_IN_IT, URI_PERMITTED_PREDICATE, SOME_LITERAL);
assertDecision(INCONCLUSIVE, policy.isAuthorized(idJoe, action)); assertDecision(INCONCLUSIVE, policy.isAuthorized(idJoe, action));
} }
@Test @Test
public void dataPropSubjectIsIceWithSelfEditingAuthor() { public void dataPropSubjectIsIceWithSelfEditingAuthor() {
action = new AddDataPropertyStatement(ontModel, URI_JOE_WROTE_IT, action = new AddDataPropertyStatement(ontModel, URI_JOE_WROTE_IT,
URI_PERMITTED_PREDICATE); URI_PERMITTED_PREDICATE, SOME_LITERAL);
assertDecision(AUTHORIZED, policy.isAuthorized(idJoe, action)); assertDecision(AUTHORIZED, policy.isAuthorized(idJoe, action));
assertDecision(AUTHORIZED, policy.isAuthorized(idBozoAndJoe, action)); assertDecision(AUTHORIZED, policy.isAuthorized(idBozoAndJoe, action));
} }
@ -270,7 +268,7 @@ public class SelfEditorRelationshipPolicyTest extends AbstractTestClass {
@Test @Test
public void dataPropSubjectIsIceWithSelfEditingEditor() { public void dataPropSubjectIsIceWithSelfEditingEditor() {
action = new AddDataPropertyStatement(ontModel, URI_JOE_EDITED_IT, action = new AddDataPropertyStatement(ontModel, URI_JOE_EDITED_IT,
URI_PERMITTED_PREDICATE); URI_PERMITTED_PREDICATE, SOME_LITERAL);
assertDecision(AUTHORIZED, policy.isAuthorized(idJoe, action)); assertDecision(AUTHORIZED, policy.isAuthorized(idJoe, action));
assertDecision(AUTHORIZED, policy.isAuthorized(idBozoAndJoe, action)); assertDecision(AUTHORIZED, policy.isAuthorized(idBozoAndJoe, action));
} }
@ -278,7 +276,7 @@ public class SelfEditorRelationshipPolicyTest extends AbstractTestClass {
@Test @Test
public void dataPropSubjectIsIceWithSelfEditingFeatured() { public void dataPropSubjectIsIceWithSelfEditingFeatured() {
action = new AddDataPropertyStatement(ontModel, URI_JOE_FEATURED_IN_IT, action = new AddDataPropertyStatement(ontModel, URI_JOE_FEATURED_IN_IT,
URI_PERMITTED_PREDICATE); URI_PERMITTED_PREDICATE, SOME_LITERAL);
assertDecision(AUTHORIZED, policy.isAuthorized(idJoe, action)); assertDecision(AUTHORIZED, policy.isAuthorized(idJoe, action));
assertDecision(AUTHORIZED, policy.isAuthorized(idBozoAndJoe, action)); assertDecision(AUTHORIZED, policy.isAuthorized(idBozoAndJoe, action));
} }
@ -348,8 +346,7 @@ public class SelfEditorRelationshipPolicyTest extends AbstractTestClass {
@Test @Test
public void objectPropObjectIsIcebutNobodyIsSelfEditing() { public void objectPropObjectIsIcebutNobodyIsSelfEditing() {
action = new AddObjectPropertyStatement(ontModel, action = new AddObjectPropertyStatement(ontModel,
URI_PERMITTED_RESOURCE, PERMITTED_PREDICATE, URI_PERMITTED_RESOURCE, PERMITTED_PREDICATE, URI_JOE_EDITED_IT);
URI_JOE_EDITED_IT);
assertDecision(INCONCLUSIVE, policy.isAuthorized(idNobody, action)); assertDecision(INCONCLUSIVE, policy.isAuthorized(idNobody, action));
} }
@ -365,16 +362,14 @@ public class SelfEditorRelationshipPolicyTest extends AbstractTestClass {
@Test @Test
public void objectPropObjectIsIceButWrongAuthor() { public void objectPropObjectIsIceButWrongAuthor() {
action = new AddObjectPropertyStatement(ontModel, action = new AddObjectPropertyStatement(ontModel,
URI_PERMITTED_RESOURCE, PERMITTED_PREDICATE, URI_PERMITTED_RESOURCE, PERMITTED_PREDICATE, URI_BOZO_WROTE_IT);
URI_BOZO_WROTE_IT);
assertDecision(INCONCLUSIVE, policy.isAuthorized(idJoe, action)); assertDecision(INCONCLUSIVE, policy.isAuthorized(idJoe, action));
} }
@Test @Test
public void objectPropObjectIsIceButWrongEditor() { public void objectPropObjectIsIceButWrongEditor() {
action = new AddObjectPropertyStatement(ontModel, action = new AddObjectPropertyStatement(ontModel,
URI_PERMITTED_RESOURCE, PERMITTED_PREDICATE, URI_PERMITTED_RESOURCE, PERMITTED_PREDICATE, URI_BOZO_EDITED_IT);
URI_BOZO_EDITED_IT);
assertDecision(INCONCLUSIVE, policy.isAuthorized(idJoe, action)); assertDecision(INCONCLUSIVE, policy.isAuthorized(idJoe, action));
} }
@ -389,8 +384,7 @@ public class SelfEditorRelationshipPolicyTest extends AbstractTestClass {
@Test @Test
public void objectPropObjectIsIceWithSelfEditingAuthor() { public void objectPropObjectIsIceWithSelfEditingAuthor() {
action = new AddObjectPropertyStatement(ontModel, action = new AddObjectPropertyStatement(ontModel,
URI_PERMITTED_RESOURCE, PERMITTED_PREDICATE, URI_PERMITTED_RESOURCE, PERMITTED_PREDICATE, URI_JOE_WROTE_IT);
URI_JOE_WROTE_IT);
assertDecision(AUTHORIZED, policy.isAuthorized(idJoe, action)); assertDecision(AUTHORIZED, policy.isAuthorized(idJoe, action));
assertDecision(AUTHORIZED, policy.isAuthorized(idBozoAndJoe, action)); assertDecision(AUTHORIZED, policy.isAuthorized(idBozoAndJoe, action));
} }
@ -398,8 +392,7 @@ public class SelfEditorRelationshipPolicyTest extends AbstractTestClass {
@Test @Test
public void objectPropObjectIsIceWithSelfEditingEditor() { public void objectPropObjectIsIceWithSelfEditingEditor() {
action = new AddObjectPropertyStatement(ontModel, action = new AddObjectPropertyStatement(ontModel,
URI_PERMITTED_RESOURCE, PERMITTED_PREDICATE, URI_PERMITTED_RESOURCE, PERMITTED_PREDICATE, URI_JOE_EDITED_IT);
URI_JOE_EDITED_IT);
assertDecision(AUTHORIZED, policy.isAuthorized(idJoe, action)); assertDecision(AUTHORIZED, policy.isAuthorized(idJoe, action));
assertDecision(AUTHORIZED, policy.isAuthorized(idBozoAndJoe, action)); assertDecision(AUTHORIZED, policy.isAuthorized(idBozoAndJoe, action));
} }
@ -420,7 +413,7 @@ public class SelfEditorRelationshipPolicyTest extends AbstractTestClass {
@Test @Test
public void dataPropSubjectIsNotIce() { public void dataPropSubjectIsNotIce() {
action = new AddDataPropertyStatement(ontModel, URI_PERMITTED_RESOURCE, action = new AddDataPropertyStatement(ontModel, URI_PERMITTED_RESOURCE,
URI_PERMITTED_PREDICATE); URI_PERMITTED_PREDICATE, SOME_LITERAL);
assertDecision(INCONCLUSIVE, policy.isAuthorized(idJoe, action)); assertDecision(INCONCLUSIVE, policy.isAuthorized(idJoe, action));
} }