@Test public void testAnyAuthenticated() { DQPWorkContext message = new DQPWorkContext(); message.setSession(Mockito.mock(SessionMetadata.class)); VDBMetaData vdb = new VDBMetaData(); DataPolicyMetadata dpm = new DataPolicyMetadata(); dpm.setAnyAuthenticated(true); vdb.addDataPolicy(dpm); Mockito.stub(message.getSession().getVdb()).toReturn(vdb); Map<String, DataPolicy> map = message.getAllowedDataPolicies(); assertEquals(1, map.size()); }
private void buildCompositeState(VDBRepository vdbRepository) throws VirtualDatabaseException { if (vdb.getVDBImports().isEmpty()) { this.vdb.addAttchment(ConnectorManagerRepository.class, this.cmr); return; } VDBMetaData newMergedVDB = this.vdb.clone(); ConnectorManagerRepository mergedRepo = this.cmr; if (!this.cmr.isShared()) { mergedRepo = new ConnectorManagerRepository(); mergedRepo.getConnectorManagers().putAll(this.cmr.getConnectorManagers()); } newMergedVDB.addAttchment(ConnectorManagerRepository.class, mergedRepo); ClassLoader[] toSearch = new ClassLoader[vdb.getVDBImports().size() + 1]; toSearch[0] = this.vdb.getAttachment(ClassLoader.class); this.children = new LinkedHashMap<VDBKey, CompositeVDB>(); newMergedVDB.setImportedModels(new TreeSet<String>(String.CASE_INSENSITIVE_ORDER)); int i = 1; for (VDBImport vdbImport : vdb.getVDBImports()) { CompositeVDB importedVDB = vdbRepository.getCompositeVDB(new VDBKey(vdbImport.getName(), vdbImport.getVersion())); if (importedVDB == null) { throw new VirtualDatabaseException( RuntimePlugin.Event.TEIID40083, RuntimePlugin.Util.gs( RuntimePlugin.Event.TEIID40083, vdb.getName(), vdb.getVersion(), vdbImport.getName(), vdbImport.getVersion())); } VDBMetaData childVDB = importedVDB.getVDB(); newMergedVDB.getVisibilityOverrides().putAll(childVDB.getVisibilityOverrides()); toSearch[i++] = childVDB.getAttachment(ClassLoader.class); this.children.put(new VDBKey(childVDB.getName(), childVDB.getVersion()), importedVDB); if (vdbImport.isImportDataPolicies()) { for (DataPolicy dp : importedVDB.getVDB().getDataPolicies()) { DataPolicyMetadata role = (DataPolicyMetadata) dp; if (newMergedVDB.addDataPolicy(role) != null) { throw new VirtualDatabaseException( RuntimePlugin.Event.TEIID40084, RuntimePlugin.Util.gs( RuntimePlugin.Event.TEIID40084, vdb.getName(), vdb.getVersion(), vdbImport.getName(), vdbImport.getVersion(), role.getName())); } if (role.isGrantAll()) { role.setSchemas(childVDB.getModelMetaDatas().keySet()); } } } // add models for (ModelMetaData m : childVDB.getModelMetaDatas().values()) { if (newMergedVDB.addModel(m) != null) { throw new VirtualDatabaseException( RuntimePlugin.Event.TEIID40085, RuntimePlugin.Util.gs( RuntimePlugin.Event.TEIID40085, vdb.getName(), vdb.getVersion(), vdbImport.getName(), vdbImport.getVersion(), m.getName())); } newMergedVDB.getImportedModels().add(m.getName()); String visibilityOverride = newMergedVDB.getPropertyValue(m.getName() + ".visible"); // $NON-NLS-1$ if (visibilityOverride != null) { boolean visible = Boolean.valueOf(visibilityOverride); newMergedVDB.setVisibilityOverride(m.getName(), visible); } } ConnectorManagerRepository childCmr = childVDB.getAttachment(ConnectorManagerRepository.class); if (childCmr == null) { throw new AssertionError("childVdb had not connector manager repository"); // $NON-NLS-1$ } if (!this.cmr.isShared()) { for (Map.Entry<String, ConnectorManager> entry : childCmr.getConnectorManagers().entrySet()) { if (mergedRepo.getConnectorManagers().put(entry.getKey(), entry.getValue()) != null) { throw new VirtualDatabaseException( RuntimePlugin.Event.TEIID40086, RuntimePlugin.Util.gs( RuntimePlugin.Event.TEIID40086, vdb.getName(), vdb.getVersion(), vdbImport.getName(), vdbImport.getVersion(), entry.getKey())); } } } } if (toSearch[0] != null) { CombinedClassLoader ccl = new CombinedClassLoader(toSearch[0].getParent(), toSearch); this.mergedVDB.addAttchment(ClassLoader.class, ccl); } this.mergedVDB = newMergedVDB; }