Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjphillips2010-07-20 15:27:15 -0400
committerjphillips2010-07-20 15:27:15 -0400
commitbeb3dfe0cf20b08d26f26c9ee759e76a73636854 (patch)
treefc7e8d291163b7e2a620350b89debae79d822ef6 /plugins/org.eclipse.osee.framework.access.test
parent3adc5fa026233019214bf8ec5f153da04fa84224 (diff)
downloadorg.eclipse.osee-beb3dfe0cf20b08d26f26c9ee759e76a73636854.tar.gz
org.eclipse.osee-beb3dfe0cf20b08d26f26c9ee759e76a73636854.tar.xz
org.eclipse.osee-beb3dfe0cf20b08d26f26c9ee759e76a73636854.zip
Added support for access control
Diffstat (limited to 'plugins/org.eclipse.osee.framework.access.test')
-rw-r--r--plugins/org.eclipse.osee.framework.access.test/src/org/eclipse/osee/framework/access/test/internal/AccessFilterChainTest.java55
1 files changed, 37 insertions, 18 deletions
diff --git a/plugins/org.eclipse.osee.framework.access.test/src/org/eclipse/osee/framework/access/test/internal/AccessFilterChainTest.java b/plugins/org.eclipse.osee.framework.access.test/src/org/eclipse/osee/framework/access/test/internal/AccessFilterChainTest.java
index c32e2ed9df..3e78f04042 100644
--- a/plugins/org.eclipse.osee.framework.access.test/src/org/eclipse/osee/framework/access/test/internal/AccessFilterChainTest.java
+++ b/plugins/org.eclipse.osee.framework.access.test/src/org/eclipse/osee/framework/access/test/internal/AccessFilterChainTest.java
@@ -30,55 +30,74 @@ import org.junit.Test;
public class AccessFilterChainTest {
@Test
- public void testUseCase1() {
+ public void testUseCase() {
//Can we edit this attribute on an artifact
AccessFilterChain chain = new AccessFilterChain();
IBasicArtifact<?> basicArtifact = new DefaultBasicArtifact(1, "1", "123");
- IAttributeType wordAttribute = CoreAttributeTypes.WORD_TEMPLATE_CONTENT;
+ IAttributeType attributeType = CoreAttributeTypes.WORD_TEMPLATE_CONTENT;
- BranchAccessFilter branchAccessFilter = new BranchAccessFilter(PermissionEnum.READ);
- ArtifactAccessFilter artifactAccessFilter = new ArtifactAccessFilter(PermissionEnum.WRITE, basicArtifact);
+ BranchAccessFilter branchAccessFilter = new BranchAccessFilter(basicArtifact, PermissionEnum.READ);
+ ArtifactAccessFilter artifactAccessFilter = new ArtifactAccessFilter(basicArtifact, PermissionEnum.WRITE);
AttributeTypeAccessFilter attributeTypeAccessFilter =
- new AttributeTypeAccessFilter(PermissionEnum.WRITE, basicArtifact);
+ new AttributeTypeAccessFilter(PermissionEnum.DENY, basicArtifact, attributeType);
chain.add(artifactAccessFilter);
chain.add(branchAccessFilter);
+ chain.add(attributeTypeAccessFilter);
PermissionEnum agrPermission = null;
- Assert.assertTrue(chain.doFilter(basicArtifact, PermissionEnum.READ, agrPermission));
- Assert.assertTrue(chain.doFilter(basicArtifact, PermissionEnum.WRITE, agrPermission));
+ Assert.assertFalse(chain.doFilter(basicArtifact, attributeTypeAccessFilter, PermissionEnum.WRITE, agrPermission));
+ Assert.assertTrue(chain.doFilter(basicArtifact, basicArtifact, PermissionEnum.WRITE, agrPermission));
}
@Test
- public void testChain() {
+ public void testWrongArtifactUseCase() {
AccessFilterChain chain = new AccessFilterChain();
IBasicArtifact<?> basicArtifact = new DefaultBasicArtifact(1, "1", "123");
+ IBasicArtifact<?> basicArtifact2 = new DefaultBasicArtifact(2, "2", "456");
+ IAttributeType attributeType = CoreAttributeTypes.WORD_TEMPLATE_CONTENT;
- BranchAccessFilter branchAccessFilter = new BranchAccessFilter(PermissionEnum.READ);
- ArtifactAccessFilter artifactAccessFilter = new ArtifactAccessFilter(PermissionEnum.WRITE);
+ BranchAccessFilter branchAccessFilter = new BranchAccessFilter(basicArtifact, PermissionEnum.READ);
+ ArtifactAccessFilter artifactAccessFilter = new ArtifactAccessFilter(basicArtifact, PermissionEnum.WRITE);
AttributeTypeAccessFilter attributeTypeAccessFilter =
- new AttributeTypeAccessFilter(PermissionEnum.WRITE, basicArtifact);
+ new AttributeTypeAccessFilter(PermissionEnum.DENY, basicArtifact, attributeType);
chain.add(artifactAccessFilter);
chain.add(branchAccessFilter);
+ chain.add(attributeTypeAccessFilter);
PermissionEnum agrPermission = null;
- Assert.assertTrue(chain.doFilter(basicArtifact, PermissionEnum.READ, agrPermission));
- Assert.assertTrue(chain.doFilter(basicArtifact, PermissionEnum.WRITE, agrPermission));
+ Assert.assertFalse(chain.doFilter(basicArtifact2, attributeTypeAccessFilter, PermissionEnum.WRITE, agrPermission));
}
@Test
- public void testChainDeny() {
+ public void testChain() {
AccessFilterChain chain = new AccessFilterChain();
- BranchAccessFilter branchAccessFilter = new BranchAccessFilter(PermissionEnum.DENY);
- ArtifactAccessFilter artifactAccessFilter = new ArtifactAccessFilter(PermissionEnum.WRITE);
+ IBasicArtifact<?> basicArtifact = new DefaultBasicArtifact(1, "1", "123");
+
+ BranchAccessFilter branchAccessFilter = new BranchAccessFilter(basicArtifact, PermissionEnum.READ);
+ ArtifactAccessFilter artifactAccessFilter = new ArtifactAccessFilter(basicArtifact, PermissionEnum.WRITE);
chain.add(artifactAccessFilter);
chain.add(branchAccessFilter);
+ PermissionEnum agrPermission = null;
+ Assert.assertTrue(chain.doFilter(basicArtifact, basicArtifact, PermissionEnum.READ, agrPermission));
+ Assert.assertTrue(chain.doFilter(basicArtifact, basicArtifact, PermissionEnum.WRITE, agrPermission));
+ }
+
+ @Test
+ public void testChainDeny() {
+ AccessFilterChain chain = new AccessFilterChain();
IBasicArtifact<?> basicArtifact = new DefaultBasicArtifact(1, "1", "123");
+ BranchAccessFilter branchAccessFilter = new BranchAccessFilter(basicArtifact, PermissionEnum.DENY);
+ ArtifactAccessFilter artifactAccessFilter = new ArtifactAccessFilter(basicArtifact, PermissionEnum.WRITE);
+
+ chain.add(artifactAccessFilter);
+ chain.add(branchAccessFilter);
+
PermissionEnum agrPermission = null;
- Assert.assertFalse(chain.doFilter(basicArtifact, PermissionEnum.READ, agrPermission));
- Assert.assertFalse(chain.doFilter(basicArtifact, PermissionEnum.WRITE, agrPermission));
+ Assert.assertFalse(chain.doFilter(basicArtifact, basicArtifact, PermissionEnum.READ, agrPermission));
+ Assert.assertFalse(chain.doFilter(basicArtifact, basicArtifact, PermissionEnum.WRITE, agrPermission));
}
}

Back to the top