Search in sources :

Example 1 with AssertionEffect

use of com.yahoo.athenz.zms.AssertionEffect in project athenz by yahoo.

the class FileConnectionTest method testAssertionMatch.

@Test
public void testAssertionMatch() {
    File fileDir = new File("/home/athenz/zms_store");
    File quotaDir = new File("/home/athenz/zms_quota");
    Assertion assertion1 = new Assertion();
    assertion1.setAction("UPDATE").setResource("resource").setRole("zmsRole");
    Assertion assertion2 = new Assertion();
    assertion2.setAction("UPDATE").setResource("resource").setRole("zmsRole");
    try (FileConnection fileconnection = new FileConnection(fileDir, quotaDir)) {
        assertTrue(fileconnection.assertionMatch(assertion1, assertion2));
        Assertion assertion3 = new Assertion();
        assertion3.setAction("UPDATE").setResource("resource").setRole("zmsRole");
        Assertion assertion4 = new Assertion();
        assertion4.setAction("Delete").setResource("resource").setRole("zmsRole");
        assertFalse(fileconnection.assertionMatch(assertion3, assertion4));
        Assertion assertion5 = new Assertion();
        assertion5.setAction("UPDATE").setResource("resource1").setRole("zmsRole");
        Assertion assertion6 = new Assertion();
        assertion6.setAction("UPDATE").setResource("resource2").setRole("zmsRole");
        assertFalse(fileconnection.assertionMatch(assertion5, assertion6));
        Assertion assertion7 = new Assertion();
        assertion7.setAction("UPDATE").setResource("resource").setRole("zmsRole1");
        Assertion assertion8 = new Assertion();
        assertion8.setAction("UPDATE").setResource("resource").setRole("zmsRole2");
        assertFalse(fileconnection.assertionMatch(assertion7, assertion8));
        Assertion assertion9 = new Assertion();
        AssertionEffect effect1 = AssertionEffect.ALLOW;
        assertion9.setAction("UPDATE").setResource("resource").setRole("zmsRole").setEffect(effect1);
        Assertion assertion10 = new Assertion();
        assertion10.setAction("UPDATE").setResource("resource").setRole("zmsRole").setEffect(effect1);
        assertTrue(fileconnection.assertionMatch(assertion9, assertion10));
        Assertion assertion11 = new Assertion();
        AssertionEffect effect2 = AssertionEffect.ALLOW;
        AssertionEffect effect3 = AssertionEffect.DENY;
        assertion11.setAction("UPDATE").setResource("resource").setRole("zmsRole").setEffect(effect2);
        Assertion assertion12 = new Assertion();
        assertion12.setAction("UPDATE").setResource("resource").setRole("zmsRole").setEffect(effect3);
        assertFalse(fileconnection.assertionMatch(assertion11, assertion12));
    }
}
Also used : AssertionEffect(com.yahoo.athenz.zms.AssertionEffect) Assertion(com.yahoo.athenz.zms.Assertion) File(java.io.File) Test(org.testng.annotations.Test)

Example 2 with AssertionEffect

use of com.yahoo.athenz.zms.AssertionEffect in project athenz by yahoo.

the class FileConnection method assertionMatch.

boolean assertionMatch(Assertion assertion1, Assertion assertion2) {
    if (!assertion1.getAction().equals(assertion2.getAction())) {
        return false;
    }
    if (!assertion1.getResource().equals(assertion2.getResource())) {
        return false;
    }
    if (!assertion1.getRole().equals(assertion2.getRole())) {
        return false;
    }
    AssertionEffect effect1 = AssertionEffect.ALLOW;
    if (assertion1.getEffect() != null) {
        effect1 = assertion1.getEffect();
    }
    AssertionEffect effect2 = AssertionEffect.ALLOW;
    if (assertion2.getEffect() != null) {
        effect2 = assertion2.getEffect();
    }
    if (effect1 != effect2) {
        return false;
    }
    return true;
}
Also used : AssertionEffect(com.yahoo.athenz.zms.AssertionEffect)

Example 3 with AssertionEffect

use of com.yahoo.athenz.zms.AssertionEffect in project athenz by yahoo.

the class JDBCConnectionTest method testProcessInsertAssertionAffect.

@Test
public void testProcessInsertAssertionAffect() throws Exception {
    JDBCConnection jdbcConn = new JDBCConnection(mockConn, true);
    assertEquals("ALLOW", jdbcConn.processInsertValue(AssertionEffect.ALLOW));
    assertEquals("DENY", jdbcConn.processInsertValue(AssertionEffect.DENY));
    assertEquals("ALLOW", jdbcConn.processInsertValue((AssertionEffect) null));
    jdbcConn.close();
}
Also used : AssertionEffect(com.yahoo.athenz.zms.AssertionEffect) JDBCConnection(com.yahoo.athenz.zms.store.jdbc.JDBCConnection) Test(org.testng.annotations.Test)

Aggregations

AssertionEffect (com.yahoo.athenz.zms.AssertionEffect)3 Test (org.testng.annotations.Test)2 Assertion (com.yahoo.athenz.zms.Assertion)1 JDBCConnection (com.yahoo.athenz.zms.store.jdbc.JDBCConnection)1 File (java.io.File)1