public async Task <IEnumerable <IFabricPrincipal> > SearchPrincipalsAsync( string searchText, PrincipalType principalType, string searchType, string tenantId = null) { switch (searchType) { case SearchTypes.Wildcard: _azureQuery = new AzureWildcardQuery(); break; case SearchTypes.Exact: _azureQuery = new AzureExactMatchQuery(); break; default: throw new DirectorySearchException($"{searchType} is not a valid search type"); } switch (principalType) { case PrincipalType.User: return(await GetUserPrincipalsAsync(searchText, tenantId).ConfigureAwait(false)); case PrincipalType.Group: return(await GetGroupPrincipalsAsync(searchText, tenantId).ConfigureAwait(false)); default: return(await GetUserAndGroupPrincipalsAsync(searchText, tenantId).ConfigureAwait(false)); } }
public async Task <IEnumerable <IFabricGroup> > SearchGroupsAsync(string searchText, string searchType, string tenantId = null) { var fabricGroups = new List <IFabricGroup>(); switch (searchType) { case SearchTypes.Wildcard: _azureQuery = new AzureWildcardQuery(); break; case SearchTypes.Exact: _azureQuery = new AzureExactMatchQuery(); break; default: throw new DirectorySearchException($"{searchType} is not a valid search type"); } var queryText = _azureQuery.QueryText(searchText, PrincipalType.Group); var fabricGraphApiGroups = await GetAllGroupsFromTenantsAsync(queryText, tenantId); foreach (var fabricGraphApiGroup in fabricGraphApiGroups) { fabricGroups.Add(CreateFabricGroup(fabricGraphApiGroup)); } return(fabricGroups); }
protected override void Given() { lhs = Substitute.For<IAzureQuery>(); lhsSet = new[] {new InternalId(Guid.NewGuid()), new InternalId(Guid.NewGuid())}; lhs.Execute(null).ReturnsForAnyArgs(lhsSet); lhs.ExecuteInsideIntersect(null, null).ReturnsForAnyArgs(lhsSet); sut = new IntersectOperator(new[] {lhs}); }
protected override void Given() { lhs = Substitute.For<IAzureQuery>(); rhs = Substitute.For<IAzureQuery>(); intersectingGuid1 = new InternalId(Guid.NewGuid()); intersectingGuid2 = new InternalId(Guid.NewGuid()); lhs.ExecuteInsideIntersect(null, null).ReturnsForAnyArgs(new[] {intersectingGuid1}); rhs.ExecuteInsideIntersect(null, null).ReturnsForAnyArgs(new[] {intersectingGuid2}); sut = new UnionOperator(new[] {lhs, rhs}); joinConstraint = new[] { intersectingGuid1, new InternalId(Guid.NewGuid()), intersectingGuid2 }; }
protected override void Given() { insideTrackedGraph = new TrackedGraph(new StoredGraph(new InternalId(Guid.NewGuid()), RegisteredGraph.GraphType, AccessCondition.None, new PreservedMemoryStream("letspretendthisisserialiseddata".Select(_ => (byte)_).ToArray())), new IProjectedIndex[] {new ProjectedIndex<int>(RegisteredIndexer.IndexName, 101)}, RegisteredGraph); lowerTrackedGraph = new TrackedGraph(new StoredGraph(new InternalId(Guid.NewGuid()), RegisteredGraph.GraphType, AccessCondition.None, new PreservedMemoryStream("letspretendthisisserialiseddata".Select(_ => (byte)_).ToArray())), new IProjectedIndex[] {new ProjectedIndex<int>(RegisteredIndexer.IndexName, 100)}, RegisteredGraph); upperTrackedGraph = new TrackedGraph(new StoredGraph(new InternalId(Guid.NewGuid()), RegisteredGraph.GraphType, AccessCondition.None, new PreservedMemoryStream("letspretendthisisserialiseddata".Select(_ => (byte)_).ToArray())), new IProjectedIndex[] {new ProjectedIndex<int>(RegisteredIndexer.IndexName, 103)}, RegisteredGraph); lessThanTrackedGraph = new TrackedGraph(new StoredGraph(new InternalId(Guid.NewGuid()), RegisteredGraph.GraphType, AccessCondition.None, new PreservedMemoryStream("letspretendthisisserialiseddata".Select(_ => (byte)_).ToArray())), new IProjectedIndex[] {new ProjectedIndex<int>(RegisteredIndexer.IndexName, 99)}, RegisteredGraph); greaterThanTrackedGraph = new TrackedGraph(new StoredGraph(new InternalId(Guid.NewGuid()), RegisteredGraph.GraphType, AccessCondition.None, new PreservedMemoryStream("letspretendthisisserialiseddata".Select(_ => (byte)_).ToArray())), new IProjectedIndex[] {new ProjectedIndex<int>(RegisteredIndexer.IndexName, 104)}, RegisteredGraph); Subject.InTransactionDo( _ => { _.InsertGraph(insideTrackedGraph); _.InsertGraph(lowerTrackedGraph); _.InsertGraph(upperTrackedGraph); _.InsertGraph(lessThanTrackedGraph); _.InsertGraph(greaterThanTrackedGraph); }); query = new InsideQuery<int>(Subject.IndexDatabases[RegisteredIndexer.IndexName], RegisteredIndexer, 100, 103); joinConstraint = new[] { insideTrackedGraph.StoredGraph.InternalId, greaterThanTrackedGraph.StoredGraph.InternalId, }; }
protected override void Given() { firstMatchingTrackedGraph = new TrackedGraph(new StoredGraph(new InternalId(Guid.NewGuid()), RegisteredGraph.GraphType, AccessCondition.None, new PreservedMemoryStream("letspretendthisisserialiseddata".Select(_ => (byte)_).ToArray())), new IProjectedIndex[] { new ProjectedIndex<int>(RegisteredIndexer.IndexName, 101), new ProjectedIndex<int>(RegisteredIndexer.IndexName, 100) }, RegisteredGraph); secondMatchingTrackedGraph = new TrackedGraph(new StoredGraph(new InternalId(Guid.NewGuid()), RegisteredGraph.GraphType, AccessCondition.None, new PreservedMemoryStream("letspretendthisisserialiseddata".Select(_ => (byte)_).ToArray())), new IProjectedIndex[] { new ProjectedIndex<int>(RegisteredIndexer.IndexName, 99), new ProjectedIndex<int>(RegisteredIndexer.IndexName, 101), new ProjectedIndex<int>(RegisteredIndexer.IndexName, 100) }, RegisteredGraph); matchingButExcludedByIntersectTrackedGraph = new TrackedGraph(new StoredGraph(new InternalId(Guid.NewGuid()), RegisteredGraph.GraphType, AccessCondition.None, new PreservedMemoryStream("letspretendthisisserialiseddata".Select(_ => (byte)_).ToArray())), new IProjectedIndex[] { new ProjectedIndex<int>(RegisteredIndexer.IndexName, 100), new ProjectedIndex<int>(RegisteredIndexer.IndexName, 101) }, RegisteredGraph); nonMatchingTrackedGraph = new TrackedGraph(new StoredGraph(new InternalId(Guid.NewGuid()), RegisteredGraph.GraphType, AccessCondition.None, new PreservedMemoryStream("letspretendthisisserialiseddata".Select(_ => (byte)_).ToArray())), new IProjectedIndex[] { new ProjectedIndex<int>(RegisteredIndexer.IndexName, 101) }, RegisteredGraph); Subject.InTransactionDo( _ => { _.InsertGraph(firstMatchingTrackedGraph); _.InsertGraph(secondMatchingTrackedGraph); _.InsertGraph(matchingButExcludedByIntersectTrackedGraph); _.InsertGraph(nonMatchingTrackedGraph); }); query = new AllOfQuery<int>(Subject.IndexDatabases[RegisteredIndexer.IndexName], RegisteredIndexer, new[] {101, 100}); joinConstraint = new[] {firstMatchingTrackedGraph.StoredGraph.InternalId, secondMatchingTrackedGraph.StoredGraph.InternalId}; }
protected override void Given() { equaltrackedGraph = new TrackedGraph(new StoredGraph(new InternalId(Guid.NewGuid()), RegisteredGraph.GraphType, AccessCondition.None, new PreservedMemoryStream("letspretendthisisserialiseddata".Select(_ => (byte)_).ToArray())), new IProjectedIndex[] {new ProjectedIndex<int>(RegisteredIndexer.IndexName, 100)}, RegisteredGraph); anotherEqualtrackedGraph = new TrackedGraph(new StoredGraph(new InternalId(Guid.NewGuid()), RegisteredGraph.GraphType, AccessCondition.None, new PreservedMemoryStream("letspretendthisisserialiseddata".Select(_ => (byte)_).ToArray())), new IProjectedIndex[] {new ProjectedIndex<int>(RegisteredIndexer.IndexName, 100)}, RegisteredGraph); notEqualtrackedGraph = new TrackedGraph(new StoredGraph(new InternalId(Guid.NewGuid()), RegisteredGraph.GraphType, AccessCondition.None, new PreservedMemoryStream("letspretendthisisserialiseddata".Select(_ => (byte)_).ToArray())), new IProjectedIndex[] {new ProjectedIndex<int>(RegisteredIndexer.IndexName, 99)}, RegisteredGraph); anotherNotEqualtrackedGraph = new TrackedGraph(new StoredGraph(new InternalId(Guid.NewGuid()), RegisteredGraph.GraphType, AccessCondition.None, new PreservedMemoryStream("letspretendthisisserialiseddata".Select(_ => (byte)_).ToArray())), new IProjectedIndex[] {new ProjectedIndex<int>(RegisteredIndexer.IndexName, 101)}, RegisteredGraph); Subject.InTransactionDo( _ => { _.InsertGraph(equaltrackedGraph); _.InsertGraph(anotherEqualtrackedGraph); _.InsertGraph(notEqualtrackedGraph); _.InsertGraph(anotherNotEqualtrackedGraph); }); query = new NotEqualToQuery<int>(Subject.IndexDatabases[RegisteredIndexer.IndexName], RegisteredIndexer, 100); joinConstraint = new[] { equaltrackedGraph.StoredGraph.InternalId, notEqualtrackedGraph.StoredGraph.InternalId, }; }