mdr.assertAccess(desc, desc.getDef(), mockAccessCheckCache);
verify(mockAccessCheckCache, times(2)).getIfPresent(anyString());
}
public void testExistsCache() throws Exception {
ConfigAdapter configAdapter = Aura.getConfigAdapter();
MasterDefRegistry mdr = getAuraMDR();
MasterDefRegistryImpl mdri = (MasterDefRegistryImpl) mdr;
Map<DefType, DefDescriptor<?>> defs = addDefsToCaches(mdri);
Map<DefType, DefDescriptor<?>> nonPrivDefs = addNonPriveledgedDefsToMDR(mdri);
for (DefDescriptor<?> dd : defs.values()) {
assertTrue(dd + " should exist.", dd.exists());
}
for (DefDescriptor<?> dd : nonPrivDefs.values()) {
assertTrue(dd + " should exist.", dd.exists());
}
DefDescriptor<?> nsDef = defs.get(DefType.NAMESPACE);
DefDescriptor<?> layoutDef = defs.get(DefType.LAYOUTS);
DefDescriptor<?> rendererDef = defs.get(DefType.RENDERER);
DefDescriptor<?> appDef = defs.get(DefType.APPLICATION);
DefDescriptor<?> controllerDef = defs.get(DefType.CONTROLLER);
DefDescriptor<?> cmpDef = defs.get(DefType.COMPONENT);
DefDescriptor<?> npNSDef = nonPrivDefs.get(DefType.NAMESPACE);
DefDescriptor<?> npLayoutDef = nonPrivDefs.get(DefType.LAYOUTS);
DefDescriptor<?> npRendererDef = nonPrivDefs.get(DefType.RENDERER);
DefDescriptor<?> nsAppDef = nonPrivDefs.get(DefType.APPLICATION);
DefDescriptor<?> nsControllerDef = nonPrivDefs.get(DefType.CONTROLLER);
DefDescriptor<?> nsCmpDef = nonPrivDefs.get(DefType.COMPONENT);
// only picking 3 defs to test the ns as they are mostly dupes
assertTrue(nsDef.getNamespace() + " should have been isPriveleged",
configAdapter.isPrivilegedNamespace(nsDef.getNamespace()));
assertTrue(layoutDef.getNamespace() + " should have been isPriveleged",
configAdapter.isPrivilegedNamespace(layoutDef.getNamespace()));
assertTrue(rendererDef.getNamespace() + " should have been isPriveleged",
configAdapter.isPrivilegedNamespace(rendererDef.getNamespace()));
assertFalse(npLayoutDef.getNamespace() + " should not have been isPriveleged",
configAdapter.isPrivilegedNamespace(npLayoutDef.getNamespace()));
assertFalse(npNSDef.getNamespace() + " should not have been isPriveleged",
configAdapter.isPrivilegedNamespace(npNSDef.getNamespace()));
assertFalse(npRendererDef.getNamespace() + " should not have been isPriveleged",
configAdapter.isPrivilegedNamespace(npRendererDef.getNamespace()));
MasterDefRegistry mdr2 = restartContextGetNewMDR();
MasterDefRegistryImpl mdri2 = (MasterDefRegistryImpl) mdr2;
// objects wont be in eists cache yet, just defsCache, need to call exists to prime exists cache