use of org.xwiki.model.reference.WikiReference in project xwiki-platform by xwiki.
the class SolrIndexScriptServiceTest method indexMultipleReferencesChecksRights.
@Test
public void indexMultipleReferencesChecksRights() throws Exception {
EntityReference wikiReference = new WikiReference("someWiki");
// Call
// Note: Faking it. just using one reference but still calling the multiple references method (which is what we
// wanted anyway)
this.service.index(Arrays.asList(wikiReference));
// Assert and verify
// Actual rights check
verify(this.mockAuthorization).hasAccess(Right.ADMIN, this.userReference, wikiReference);
verify(this.mockAuthorization).hasAccess(Right.PROGRAM, this.contentAuthorReference, wikiReference);
}
use of org.xwiki.model.reference.WikiReference in project xwiki-platform by xwiki.
the class DefaultSecurityCacheLoaderTest method setUp.
@Before
public void setUp() throws Exception {
XWikiBridge bridge = mocker.registerMockComponent(XWikiBridge.class);
when(bridge.getMainWikiReference()).thenReturn(new WikiReference("wiki"));
securityReferenceFactory = mocker.getInstance(SecurityReferenceFactory.class);
mocker.registerMockComponent(SecurityCache.class);
mocker.registerMockComponent(SecurityCacheRulesInvalidator.class);
mocker.registerMockComponent(SecurityEntryReader.class);
mocker.registerMockComponent(UserBridge.class);
mocker.registerMockComponent(AuthorizationSettler.class);
securityCacheLoader = mocker.getInstance(SecurityCacheLoader.class);
}
use of org.xwiki.model.reference.WikiReference in project xwiki-platform by xwiki.
the class DefaultSecurityCacheTest method configure.
@Before
public void configure() throws Exception {
if (cache == null) {
cache = new TestCache<Object>();
final CacheManager cacheManager = securityCacheMocker.getInstance(CacheManager.class);
when(cacheManager.createNewCache(any(CacheConfiguration.class))).thenReturn(cache);
}
XWikiBridge xwikiBridge = securityReferenceFactoryMocker.getInstance(XWikiBridge.class);
when(xwikiBridge.getMainWikiReference()).thenReturn(new WikiReference("xwiki"));
this.factory = securityReferenceFactoryMocker.getComponentUnderTest();
this.securityCache = securityCacheMocker.getComponentUnderTest();
aMissingParentRef = factory.newEntityReference(new SpaceReference("space", new WikiReference("missing")));
aMissingEntityRef = factory.newEntityReference(new DocumentReference("missingPage", xspaceRef.getOriginalSpaceReference()));
aMissingUserRef = factory.newUserReference(new DocumentReference("missingUser", xXWikiSpace.getOriginalSpaceReference()));
aMissingGroupRef = factory.newGroupReference(new DocumentReference("missingGroup", xXWikiSpace.getOriginalSpaceReference()));
aMissingWikiRef = factory.newEntityReference(new WikiReference("missingWiki"));
}
use of org.xwiki.model.reference.WikiReference in project xwiki-platform by xwiki.
the class DefaultSecurityCacheTest method AddAccessEntry.
private String AddAccessEntry(final SecurityAccessEntry entry) throws ParentEntryEvictedException, ConflictingInsertionException {
WikiReference entityWiki = (WikiReference) entry.getReference().getOriginalReference().extractReference(EntityType.WIKI);
WikiReference userWiki = entry.getUserReference().getOriginalReference().getWikiReference();
if (entityWiki != userWiki) {
if (entry.getUserReference().isGlobal()) {
securityCache.add(entry, factory.newEntityReference(entityWiki));
return cache.getLastInsertedKey();
} else {
return null;
}
} else {
securityCache.add(entry);
return cache.getLastInsertedKey();
}
}
use of org.xwiki.model.reference.WikiReference in project xwiki-platform by xwiki.
the class SolrFieldStringEntityReferenceResolverTest method resolve.
@Test
public void resolve() throws Exception {
EntityReferenceProvider currentEntityReferenceProvider = this.mocker.getInstance(EntityReferenceProvider.class, "current");
when(currentEntityReferenceProvider.getDefaultReference(EntityType.WIKI)).thenReturn(new WikiReference("test"));
EntityReferenceResolver<String> resolver = mocker.getComponentUnderTest();
DocumentReference documentReference = new DocumentReference("test", Arrays.asList("My App", "Code", "Model"), "A Class");
assertEquals(new ClassPropertyReference("title", documentReference), new ClassPropertyReference(resolver.resolve("My App.Code.Model.A Class.title", EntityType.CLASS_PROPERTY)));
documentReference = new DocumentReference("test", Arrays.asList("My.App", "Co.de"), "A.Class");
assertEquals(new ClassPropertyReference("ti.tle", documentReference), new ClassPropertyReference(resolver.resolve("My..App.Co..de.A..Class.ti..tle", EntityType.CLASS_PROPERTY)));
assertEquals(new SpaceReference("0.9", new SpaceReference("a..z", new WikiReference("test"))), new SpaceReference(resolver.resolve("a....z.0..9", EntityType.SPACE)));
// Relative reference resolved based on the given parameters.
assertEquals(new ClassPropertyReference("title", new DocumentReference("foo", Arrays.asList("Code", "Model"), "A Class")), new ClassPropertyReference(resolver.resolve("Code.Model.A Class.title", EntityType.CLASS_PROPERTY, new SpaceReference("My App", new WikiReference("foo")))));
// Relative reference resolve based on the current entity.
when(currentEntityReferenceProvider.getDefaultReference(EntityType.SPACE)).thenReturn(new EntityReference("Code", EntityType.SPACE, new EntityReference("My App", EntityType.SPACE, null)));
assertEquals(new ClassPropertyReference("title", new DocumentReference("bar", Arrays.asList("My App", "Code"), "A Class")), new ClassPropertyReference(resolver.resolve("A Class.title", EntityType.CLASS_PROPERTY, new WikiReference("bar"))));
}
Aggregations