public void testFilterExactAttribute() { try { GenericApplicationContext gContext = BaseDataConnectorTest.createSpringContext(RESOLVER_CONFIG); GroupDataConnector gdc = (GroupDataConnector) gContext.getBean("testFilterExactAttribute"); Filter filter = gdc.getFilter(); Set<Group> groups = filter.getResults(grouperSession); assertEquals(1, groups.size()); assertTrue(groups.contains(groupA)); assertFalse(groups.contains(groupB)); assertFalse(groups.contains(groupC)); assertTrue(filter.matches(groupA)); assertFalse(filter.matches(groupB)); assertFalse(filter.matches(groupC)); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException(e); } }
/** * Assert that the attributes returned from the data connector match the provided attributes. * * @param dataConnectorName the data connector name * @param principalName the principalName * @param correctMap the correct attributes */ private void runAttributeDefinitionTest( String dataConnectorName, String principalName, AttributeMap correctMap, String attributeDefinitionName) { try { GenericApplicationContext gContext = BaseDataConnectorTest.createSpringContext(RESOLVER_CONFIG); ShibbolethResolutionContext ctx = getShibContext(principalName); // resolve data connector dependency GroupDataConnector gdc = (GroupDataConnector) gContext.getBean(dataConnectorName); gdc.resolve(ctx); ctx.getResolvedPlugins().put(gdc.getId(), gdc); // resolve attribute definition AttributeDefinition ad = (AttributeDefinition) gContext.getBean(attributeDefinitionName); BaseAttribute attr = ad.resolve(ctx); // assert equality AttributeMap currentMap = new AttributeMap(); currentMap.setAttribute(attr); LOG.debug("correctMap\n{}", correctMap); LOG.debug("currentMap\n{}", currentMap); assertEquals(correctMap, currentMap); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException(e); } }
public void testGroupNotFound() { try { GenericApplicationContext gContext = BaseDataConnectorTest.createSpringContext(RESOLVER_CONFIG); GroupDataConnector gdc = (GroupDataConnector) gContext.getBean("testAttributesOnly"); Map<String, BaseAttribute> map = gdc.resolve(getShibContext("notfound")); assertTrue(map.isEmpty()); } catch (Exception e) { throw new RuntimeException(e); } }
public void testFieldSyntax3() { try { BaseDataConnectorTest.createSpringContext( TEST_PATH + "GroupDataConnectorTest-resolver-invalid-3.xml"); fail("Should throw a BeanCreationException"); } catch (BeanCreationException e) { // OK } catch (ResourceException e) { throw new RuntimeException(e); } }
/** * Assert that the attributes returned from the data connector match the provided attributes. * * @param dataConnectorName the data connector name * @param group the group * @param correctMap the correct attributes */ private void runResolveTest(String dataConnectorName, Group group, AttributeMap correctMap) { try { GenericApplicationContext gContext = BaseDataConnectorTest.createSpringContext(RESOLVER_CONFIG); GroupDataConnector gdc = (GroupDataConnector) gContext.getBean(dataConnectorName); AttributeMap currentMap = new AttributeMap(gdc.resolve(getShibContext(group.getName()))); LOG.debug("correctMap\n{}", correctMap); LOG.debug("currentMap\n{}", currentMap); assertEquals(correctMap, currentMap); } catch (Exception e) { throw new RuntimeException(e); } }
public void testMatchFilterMinus() { try { GenericApplicationContext gContext = BaseDataConnectorTest.createSpringContext(RESOLVER_CONFIG); GroupDataConnector gdc = (GroupDataConnector) gContext.getBean("testFilterMinus"); assertTrue( "map should not be empty", !gdc.resolve(getShibContext(groupA.getName())).isEmpty()); assertTrue("map should be empty", gdc.resolve(getShibContext(groupB.getName())).isEmpty()); assertTrue("map should be empty", gdc.resolve(getShibContext(groupC.getName())).isEmpty()); } catch (Exception e) { throw new RuntimeException(e); } }
public void setUp() { super.setUp(); // add etc:attribute:courses:courseType attribute Stem etcStem = StemFinder.findByName(GrouperSession.staticGrouperSession(), "etc:attribute", true); Stem coursesStem = etcStem.addChildStem("courses", "Courses"); AttributeDef attributeDef = coursesStem.addChildAttributeDef("courseType", AttributeDefType.attr); attributeDef.setAssignToGroup(true); attributeDef.setMultiValued(true); attributeDef.setValueType(AttributeDefValueType.string); attributeDef.store(); coursesStem.addChildAttributeDefName(attributeDef, "courseType", "courseType"); }