use of ext.framework.b.TestCondition in project rt.equinox.framework by eclipse.
the class SecurityAdminUnitTests method testPostponedConditions02.
public void testPostponedConditions02() {
installConditionBundle();
TestCondition.clearConditions();
Bundle test1 = installTestBundle(TEST_BUNDLE);
Bundle test2 = installTestBundle(TEST2_BUNDLE);
ProtectionDomain pd1 = test1.adapt(ProtectionDomain.class);
ProtectionDomain pd2 = test2.adapt(ProtectionDomain.class);
ProtectionDomain[] pds = new ProtectionDomain[] { pd1, pd2 };
ConditionalPermissionUpdate update = cpa.newConditionalPermissionUpdate();
List rows = update.getConditionalPermissionInfos();
rows.add(cpa.newConditionalPermissionInfo(null, new ConditionInfo[] { POST_MUT_SAT }, READONLY_INFOS, ConditionalPermissionInfo.DENY));
rows.add(cpa.newConditionalPermissionInfo(null, new ConditionInfo[] { POST_MUT_SAT }, READONLY_INFOS, ConditionalPermissionInfo.DENY));
rows.add(cpa.newConditionalPermissionInfo(null, new ConditionInfo[] { POST_MUT_UNSAT }, READONLY_INFOS, ConditionalPermissionInfo.DENY));
rows.add(cpa.newConditionalPermissionInfo(null, ALLLOCATION_CONDS, READONLY_INFOS, ConditionalPermissionInfo.DENY));
// $NON-NLS-1$);
assertTrue("failed to commit", update.commit());
// $NON-NLS-1$ //$NON-NLS-2$
testSMPermission(pds, new FilePermission("test", "read"), false);
// $NON-NLS-1$
TestCondition tc1sat = TestCondition.getTestCondition("POST_MUT_SAT_" + test1.getBundleId());
// $NON-NLS-1$
TestCondition tc2sat = TestCondition.getTestCondition("POST_MUT_SAT_" + test2.getBundleId());
// $NON-NLS-1$
TestCondition tc1unsat = TestCondition.getTestCondition("POST_MUT_UNSAT_" + test1.getBundleId());
// $NON-NLS-1$
TestCondition tc2unsat = TestCondition.getTestCondition("POST_MUT_UNSAT_" + test2.getBundleId());
// Note that we need to avoid an ordering assumption on the order in which
// ProtectionDomains are processed by the AccessControlContext (bug 269917)
// Just make sure both tc1 and tc2 are not non-null at the same time.
// $NON-NLS-1$
assertTrue("tc1sat and tc2sat are either both null or both non-null", (tc1sat == null) ^ (tc2sat == null));
// $NON-NLS-1$
assertTrue("tc1unsat and tc2unsat are either both null or both non-null", (tc1unsat == null) ^ (tc2unsat == null));
TestCondition modifySat = tc1sat != null ? tc1sat : tc2sat;
TestCondition modifyUnsat = tc1unsat != null ? tc1unsat : tc2unsat;
modifySat.setSatisfied(false);
modifyUnsat.setSatisfied(true);
// $NON-NLS-1$ //$NON-NLS-2$
testSMPermission(pds, new FilePermission("test", "read"), false);
}
use of ext.framework.b.TestCondition in project rt.equinox.framework by eclipse.
the class SecurityAdminUnitTests method testPostponedConditions04.
public void testPostponedConditions04() {
installConditionBundle();
TestCondition.clearConditions();
Bundle test1 = installTestBundle(TEST_BUNDLE);
Bundle test2 = installTestBundle(TEST2_BUNDLE);
ProtectionDomain pd1 = test1.adapt(ProtectionDomain.class);
ProtectionDomain pd2 = test2.adapt(ProtectionDomain.class);
ProtectionDomain[] pds = new ProtectionDomain[] { pd1, pd2 };
ConditionalPermissionUpdate update = cpa.newConditionalPermissionUpdate();
List rows = update.getConditionalPermissionInfos();
rows.add(cpa.newConditionalPermissionInfo(null, new ConditionInfo[] { POST_MUT_SAT }, READONLY_INFOS, ConditionalPermissionInfo.DENY));
rows.add(cpa.newConditionalPermissionInfo(null, new ConditionInfo[] { POST_MUT_SAT }, READONLY_INFOS, ConditionalPermissionInfo.DENY));
rows.add(cpa.newConditionalPermissionInfo(null, new ConditionInfo[] { POST_MUT_UNSAT }, READONLY_INFOS, ConditionalPermissionInfo.DENY));
// $NON-NLS-1$);
assertTrue("failed to commit", update.commit());
// $NON-NLS-1$ //$NON-NLS-2$
testSMPermission(pds, new FilePermission("test", "read"), false);
// $NON-NLS-1$
TestCondition tc1sat = TestCondition.getTestCondition("POST_MUT_SAT_" + test1.getBundleId());
// $NON-NLS-1$
TestCondition tc2sat = TestCondition.getTestCondition("POST_MUT_SAT_" + test2.getBundleId());
// $NON-NLS-1$
TestCondition tc1unsat = TestCondition.getTestCondition("POST_MUT_UNSAT_" + test1.getBundleId());
// $NON-NLS-1$
TestCondition tc2unsat = TestCondition.getTestCondition("POST_MUT_UNSAT_" + test2.getBundleId());
// Note that we need to avoid an ordering assumption on the order in which
// ProtectionDomains are processed by the AccessControlContext (bug 269917)
// Just make sure both tc1 and tc2 are not non-null at the same time.
// $NON-NLS-1$
assertTrue("tc1sat and tc2sat are either both null or both non-null", (tc1sat == null) ^ (tc2sat == null));
// $NON-NLS-1$
assertTrue("tc1unsat and tc2unsat are either both null or both non-null", (tc1unsat == null) ^ (tc2unsat == null));
TestCondition modifySat = tc1sat != null ? tc1sat : tc2sat;
TestCondition modifyUnsat = tc1unsat != null ? tc1unsat : tc2unsat;
modifySat.setSatisfied(false);
modifyUnsat.setSatisfied(true);
// $NON-NLS-1$ //$NON-NLS-2$
testSMPermission(pds, new FilePermission("test", "read"), false);
}
use of ext.framework.b.TestCondition in project rt.equinox.framework by eclipse.
the class SecurityAdminUnitTests method testPostponedConditions05.
public void testPostponedConditions05() {
installConditionBundle();
TestCondition.clearConditions();
Bundle test1 = installTestBundle(TEST_BUNDLE);
Bundle test2 = installTestBundle(TEST2_BUNDLE);
ProtectionDomain pd1 = test1.adapt(ProtectionDomain.class);
ProtectionDomain pd2 = test2.adapt(ProtectionDomain.class);
ProtectionDomain[] pds = new ProtectionDomain[] { pd1, pd2 };
ConditionalPermissionUpdate update = cpa.newConditionalPermissionUpdate();
List rows = update.getConditionalPermissionInfos();
rows.add(cpa.newConditionalPermissionInfo(null, new ConditionInfo[] { POST_MUT_SAT }, READONLY_INFOS, ConditionalPermissionInfo.DENY));
rows.add(cpa.newConditionalPermissionInfo(null, new ConditionInfo[] { POST_MUT_UNSAT }, READONLY_INFOS, ConditionalPermissionInfo.ALLOW));
rows.add(cpa.newConditionalPermissionInfo(null, new ConditionInfo[] { POST_MUT_SAT }, READONLY_INFOS, ConditionalPermissionInfo.ALLOW));
rows.add(cpa.newConditionalPermissionInfo(null, new ConditionInfo[] { POST_MUT_UNSAT }, READONLY_INFOS, ConditionalPermissionInfo.ALLOW));
rows.add(cpa.newConditionalPermissionInfo(null, ALLLOCATION_CONDS, READONLY_INFOS, ConditionalPermissionInfo.ALLOW));
// $NON-NLS-1$);
assertTrue("failed to commit", update.commit());
// $NON-NLS-1$ //$NON-NLS-2$
testSMPermission(pds, new FilePermission("test", "read"), false);
// $NON-NLS-1$
TestCondition tc1sat = TestCondition.getTestCondition("POST_MUT_SAT_" + test1.getBundleId());
// $NON-NLS-1$
TestCondition tc2sat = TestCondition.getTestCondition("POST_MUT_SAT_" + test2.getBundleId());
// $NON-NLS-1$
TestCondition tc1unsat = TestCondition.getTestCondition("POST_MUT_UNSAT_" + test1.getBundleId());
// $NON-NLS-1$
TestCondition tc2unsat = TestCondition.getTestCondition("POST_MUT_UNSAT_" + test2.getBundleId());
// $NON-NLS-1$
assertNotNull("tc1sat", tc1sat);
// $NON-NLS-1$
assertNotNull("tc2sat", tc2sat);
// $NON-NLS-1$
assertNotNull("tc1unsat", tc1unsat);
// $NON-NLS-1$
assertNotNull("tc2unsat", tc2unsat);
tc1sat.setSatisfied(false);
tc2sat.setSatisfied(false);
// $NON-NLS-1$ //$NON-NLS-2$
testSMPermission(pds, new FilePermission("test", "read"), true);
}
use of ext.framework.b.TestCondition in project rt.equinox.framework by eclipse.
the class SecurityAdminUnitTests method testPostponedConditions03.
public void testPostponedConditions03() {
installConditionBundle();
TestCondition.clearConditions();
Bundle test1 = installTestBundle(TEST_BUNDLE);
Bundle test2 = installTestBundle(TEST2_BUNDLE);
ProtectionDomain pd1 = test1.adapt(ProtectionDomain.class);
ProtectionDomain pd2 = test2.adapt(ProtectionDomain.class);
ProtectionDomain[] pds = new ProtectionDomain[] { pd1, pd2 };
ConditionalPermissionUpdate update = cpa.newConditionalPermissionUpdate();
List rows = update.getConditionalPermissionInfos();
rows.add(cpa.newConditionalPermissionInfo(null, new ConditionInfo[] { POST_MUT_SAT }, READONLY_INFOS, ConditionalPermissionInfo.ALLOW));
rows.add(cpa.newConditionalPermissionInfo(null, new ConditionInfo[] { POST_MUT_SAT }, READONLY_INFOS, ConditionalPermissionInfo.ALLOW));
rows.add(cpa.newConditionalPermissionInfo(null, new ConditionInfo[] { POST_MUT_UNSAT }, READONLY_INFOS, ConditionalPermissionInfo.ALLOW));
rows.add(cpa.newConditionalPermissionInfo(null, ALLLOCATION_CONDS, READONLY_INFOS, ConditionalPermissionInfo.ALLOW));
// $NON-NLS-1$);
assertTrue("failed to commit", update.commit());
// $NON-NLS-1$ //$NON-NLS-2$
testSMPermission(pds, new FilePermission("test", "read"), true);
// $NON-NLS-1$
TestCondition tc1sat = TestCondition.getTestCondition("POST_MUT_SAT_" + test1.getBundleId());
// $NON-NLS-1$
TestCondition tc2sat = TestCondition.getTestCondition("POST_MUT_SAT_" + test2.getBundleId());
// $NON-NLS-1$
TestCondition tc1unsat = TestCondition.getTestCondition("POST_MUT_UNSAT_" + test1.getBundleId());
// $NON-NLS-1$
TestCondition tc2unsat = TestCondition.getTestCondition("POST_MUT_UNSAT_" + test2.getBundleId());
// $NON-NLS-1$
assertNotNull("tc1sat", tc1sat);
// $NON-NLS-1$
assertNotNull("tc2sat", tc2sat);
// $NON-NLS-1$
assertNotNull("tc1unsat", tc1unsat);
// $NON-NLS-1$
assertNotNull("tc2unsat", tc2unsat);
tc1sat.setSatisfied(false);
tc2sat.setSatisfied(false);
tc1unsat.setSatisfied(true);
tc2unsat.setSatisfied(true);
// $NON-NLS-1$ //$NON-NLS-2$
testSMPermission(pds, new FilePermission("test", "read"), true);
}
use of ext.framework.b.TestCondition in project rt.equinox.framework by eclipse.
the class SecurityAdminUnitTests method testPostponedConditions01.
public void testPostponedConditions01() {
installConditionBundle();
TestCondition.clearConditions();
Bundle test1 = installTestBundle(TEST_BUNDLE);
Bundle test2 = installTestBundle(TEST2_BUNDLE);
ProtectionDomain pd1 = test1.adapt(ProtectionDomain.class);
ProtectionDomain pd2 = test2.adapt(ProtectionDomain.class);
ProtectionDomain[] pds = new ProtectionDomain[] { pd1, pd2 };
ConditionalPermissionUpdate update = cpa.newConditionalPermissionUpdate();
List rows = update.getConditionalPermissionInfos();
rows.add(cpa.newConditionalPermissionInfo(null, new ConditionInfo[] { POST_MUT_SAT }, READONLY_INFOS, ConditionalPermissionInfo.DENY));
rows.add(cpa.newConditionalPermissionInfo(null, new ConditionInfo[] { POST_MUT_UNSAT }, READONLY_INFOS, ConditionalPermissionInfo.ALLOW));
rows.add(cpa.newConditionalPermissionInfo(null, ALLLOCATION_CONDS, READONLY_INFOS, ConditionalPermissionInfo.DENY));
// $NON-NLS-1$);
assertTrue("failed to commit", update.commit());
// $NON-NLS-1$ //$NON-NLS-2$
testSMPermission(pds, new FilePermission("test", "read"), false);
// $NON-NLS-1$
TestCondition tc1sat = TestCondition.getTestCondition("POST_MUT_SAT_" + test1.getBundleId());
// $NON-NLS-1$
TestCondition tc2sat = TestCondition.getTestCondition("POST_MUT_SAT_" + test2.getBundleId());
// $NON-NLS-1$
TestCondition tc1unsat = TestCondition.getTestCondition("POST_MUT_UNSAT_" + test1.getBundleId());
// $NON-NLS-1$
TestCondition tc2unsat = TestCondition.getTestCondition("POST_MUT_UNSAT_" + test2.getBundleId());
// $NON-NLS-1$
assertNotNull("tc1sat", tc1sat);
// $NON-NLS-1$
assertNotNull("tc2sat", tc2sat);
// $NON-NLS-1$
assertNotNull("tc1unsat", tc1unsat);
// $NON-NLS-1$
assertNotNull("tc2unsat", tc2unsat);
tc1sat.setSatisfied(false);
tc2sat.setSatisfied(false);
tc1unsat.setSatisfied(true);
tc2unsat.setSatisfied(true);
// $NON-NLS-1$ //$NON-NLS-2$
testSMPermission(pds, new FilePermission("test", "read"), true);
tc1sat.setSatisfied(true);
tc2sat.setSatisfied(true);
update = cpa.newConditionalPermissionUpdate();
rows = update.getConditionalPermissionInfos();
rows.remove(0);
// $NON-NLS-1$);
assertTrue("failed to commit", update.commit());
// $NON-NLS-1$ //$NON-NLS-2$
testSMPermission(pds, new FilePermission("test", "read"), true);
tc1unsat.setSatisfied(false);
tc2unsat.setSatisfied(false);
// $NON-NLS-1$ //$NON-NLS-2$
testSMPermission(pds, new FilePermission("test", "read"), false);
update = cpa.newConditionalPermissionUpdate();
rows = update.getConditionalPermissionInfos();
rows.remove(0);
// $NON-NLS-1$);
assertTrue("failed to commit", update.commit());
// $NON-NLS-1$ //$NON-NLS-2$
testSMPermission(pds, new FilePermission("test", "read"), false);
}
Aggregations