Esempio n. 1
0
  @Test
  public void testNotApplicable() {
    Subject subject = Subject.newInstance("John Smith");
    subject.addAttribute("urn:oasis:names:tc:xacml:1.0:subject:role-id", "ROLE_DOCUMENT_WRITER");

    Action action = Action.newInstance("write");
    Document doc = new Document(2, "OnBoarding Document", "XYZ Corporation", "Jim Doe");
    PepResponse response = getPepAgent().decide(subject, action, doc);
    Assert.assertNotNull(response);
    Assert.assertEquals(false, response.allowed());
  }
Esempio n. 2
0
  @Test
  public void testVarArgsPermit() {
    Subject subject = Subject.newInstance("John Smith");
    subject.addAttribute("urn:oasis:names:tc:xacml:1.0:subject:role-id", "ROLE_DOCUMENT_READER");
    BusinessRequestContext bc = new BusinessRequestContext("USA", "05:00 EST");

    Action action = Action.newInstance("read");
    List<Object> resources = new ArrayList<Object>();
    resources.add(new Document(1, "OnBoarding Document", "XYZ Corporation", "Jim Doe"));
    resources.add(new Client("XYZ Corporation", "USA"));

    PepResponse response = getPepAgent().decide(subject, action, resources, bc);
    Assert.assertNotNull(response);
    Assert.assertEquals(true, response.allowed());
  }
Esempio n. 3
0
  @Test(expected = PepException.class)
  public void testMix() {
    Subject subject = Subject.newInstance("John Smith");
    subject.addAttribute("urn:oasis:names:tc:xacml:1.0:subject:role-id", "ROLE_DOCUMENT_WRITER");

    Action action = Action.newInstance("write");

    Document doc1 = new Document(1, "OnBoarding Document", "ABC Corporation", "John Smith");
    Document doc2 = new Document(2, "OnBoarding Document", "XYZ Corporation", "Jim Doe");
    List<Object> resourceList = new ArrayList<Object>();
    resourceList.add(doc1);
    resourceList.add(doc2);

    PepResponse response = getPepAgent().decide(subject, action, resourceList);
    Assert.assertNotNull(response);
    response.allowed();
  }