public void FilterChangeLogRecordsByWorkload() { // Arrange var changeLogRecords = new ChangeLogRecords { ChangeLogs = ChangeLogRecordsModelShould.GetChangeLogRecords().ChangeLogs }; var searchOptions = new ChangeLogSearchOptions(workload: "Compliance"); // Act var changeLog = Services.ChangesService.FilterChangeLogRecords(changeLogRecords, searchOptions, _graphProxyConfigs); // Assert Assert.NotNull(changeLog); Assert.Collection(changeLog.ChangeLogs, item => { Assert.Equal("6a6c7aa0-4b67-4d07-9ebf-c2bc1bcef553", item.Id); Assert.Equal("Compliance", item.WorkloadArea); Assert.Equal("eDiscovery", item.SubArea); Assert.Collection(item.ChangeList, item => { Assert.Equal("6a6c7aa0-4b67-4d07-9ebf-c2bc1bcef553", item.Id); Assert.Equal("Resource", item.ApiChange); Assert.Equal("ediscoveryCase,reviewSet,reviewSetQuery", item.ChangedApiName); Assert.Equal("Addition", item.ChangeType); Assert.Equal("ediscoveryCase,reviewSet,reviewSetQuery", item.Target); }); }); }
public void FilterChangeLogRecordsByEndDateAndDaysRange() { // Arrange var changeLogRecords = new ChangeLogRecords { ChangeLogs = ChangeLogRecordsModelShould.GetChangeLogRecords().ChangeLogs }; var endDate = DateTime.Parse("2021-01-01"); var searchOptions = new ChangeLogSearchOptions(endDate: endDate, daysRange: 30); // Act var changeLog = Services.ChangesService.FilterChangeLogRecords(changeLogRecords, searchOptions, _graphProxyConfigs); // Assert Assert.NotNull(changeLog); Assert.Collection(changeLog.ChangeLogs, item => { Assert.Equal("dca6467b-d026-4316-8353-2c6c02598af3", item.Id); Assert.Equal("Reports", item.WorkloadArea); Assert.Equal("Identity and access reports", item.SubArea); Assert.Collection(item.ChangeList, item => { Assert.Equal("dca6467b-d026-4316-8353-2c6c02598af3", item.Id); Assert.Equal("Resource", item.ApiChange); Assert.Equal("relyingPartyDetailedSummary,listing", item.ChangedApiName); Assert.Equal("Addition", item.ChangeType); Assert.Equal("relyingPartyDetailedSummary,listing", item.Target); }); }); }
public void PaginateChangeLogRecordsFirstPage() { // Arrange var changeLogRecords = new ChangeLogRecords { ChangeLogs = ChangeLogRecordsModelShould.GetChangeLogRecords().ChangeLogs }; var searchOptions = new ChangeLogSearchOptions { Page = 1, PageLimit = 2 }; // Act var changeLog = Services.ChangesService.FilterChangeLogRecords(changeLogRecords, searchOptions, _graphProxyConfigs); // Assert -- fetch first two items from the changelog sample Assert.NotNull(changeLog); Assert.Collection(changeLog.ChangeLogs, item => { Assert.Equal("6a6c7aa0-4b67-4d07-9ebf-c2bc1bcef553", item.Id); Assert.Equal("Compliance", item.WorkloadArea); Assert.Equal("eDiscovery", item.SubArea); Assert.Collection(item.ChangeList, item => { Assert.Equal("6a6c7aa0-4b67-4d07-9ebf-c2bc1bcef553", item.Id); Assert.Equal("Resource", item.ApiChange); Assert.Equal("ediscoveryCase,reviewSet,reviewSetQuery", item.ChangedApiName); Assert.Equal("Addition", item.ChangeType); Assert.Equal("ediscoveryCase,reviewSet,reviewSetQuery", item.Target); }); }, item => { Assert.Equal("2d94636a-2d78-44d6-8b08-ff2a9121214b", item.Id); Assert.Equal("Extensions", item.WorkloadArea); Assert.Equal("Schema extensions", item.SubArea); Assert.Collection(item.ChangeList, item => { Assert.Equal("2d94636a-2d78-44d6-8b08-ff2a9121214b", item.Id); Assert.Equal("Resource", item.ApiChange); Assert.Equal("schema extensions,Microsoft Cloud for US Government.", item.ChangedApiName); Assert.Equal("Addition", item.ChangeType); Assert.Equal("schema extensions,Microsoft Cloud for US Government", item.Target); }); }); }
public void FilterChangeLogRecordsByDates() { // Arrange var changeLogRecords = new ChangeLogRecords { ChangeLogs = ChangeLogRecordsModelShould.GetChangeLogRecords().ChangeLogs }; var startDate = DateTime.Parse("2020-01-01"); var endDate = DateTime.Parse("2020-10-01"); var searchOptions = new ChangeLogSearchOptions(startDate: startDate, endDate: endDate); // Act var changeLog = Services.ChangesService.FilterChangeLogRecords(changeLogRecords, searchOptions, _graphProxyConfigs); // Assert Assert.NotNull(changeLog); Assert.Collection(changeLog.ChangeLogs, item => { Assert.Equal("6a6c7aa0-4b67-4d07-9ebf-c2bc1bcef553", item.Id); Assert.Equal("Compliance", item.WorkloadArea); Assert.Equal("eDiscovery", item.SubArea); Assert.Collection(item.ChangeList, item => { Assert.Equal("6a6c7aa0-4b67-4d07-9ebf-c2bc1bcef553", item.Id); Assert.Equal("Resource", item.ApiChange); Assert.Equal("ediscoveryCase,reviewSet,reviewSetQuery", item.ChangedApiName); Assert.Equal("Addition", item.ChangeType); Assert.Equal("ediscoveryCase,reviewSet,reviewSetQuery", item.Target); }); }, item => { Assert.Equal("2d94636a-2d78-44d6-8b08-ff2a9121214b", item.Id); Assert.Equal("Extensions", item.WorkloadArea); Assert.Equal("Schema extensions", item.SubArea); Assert.Collection(item.ChangeList, item => { Assert.Equal("2d94636a-2d78-44d6-8b08-ff2a9121214b", item.Id); Assert.Equal("Resource", item.ApiChange); Assert.Equal("schema extensions,Microsoft Cloud for US Government.", item.ChangedApiName); Assert.Equal("Addition", item.ChangeType); Assert.Equal("schema extensions,Microsoft Cloud for US Government", item.Target); }); }); }
public void PaginateChangeLogRecordsLastPage() { // Arrange var changeLogRecords = new ChangeLogRecords { ChangeLogs = ChangeLogRecordsModelShould.GetChangeLogRecords().ChangeLogs }; var searchOptions = new ChangeLogSearchOptions { Page = 2, PageLimit = 2 }; // Act var changeLog = Services.ChangesService.FilterChangeLogRecords(changeLogRecords, searchOptions, _graphProxyConfigs); // Assert -- fetch last item from the changelog sample Assert.NotNull(changeLog); Assert.Collection(changeLog.ChangeLogs, item => { Assert.Equal("dca6467b-d026-4316-8353-2c6c02598af3", item.Id); Assert.Equal("Reports", item.WorkloadArea); Assert.Equal("Identity and access reports", item.SubArea); Assert.Collection(item.ChangeList, item => { Assert.Equal("dca6467b-d026-4316-8353-2c6c02598af3", item.Id); Assert.Equal("Resource", item.ApiChange); Assert.Equal("relyingPartyDetailedSummary,listing", item.ChangedApiName); Assert.Equal("Addition", item.ChangeType); Assert.Equal("relyingPartyDetailedSummary,listing", item.Target); }); }); }
public void PaginateChangeLogRecordsMiddlePage() { // Arrange var changeLogRecords = new ChangeLogRecords { ChangeLogs = ChangeLogRecordsModelShould.GetChangeLogRecords().ChangeLogs }; var searchOptions = new ChangeLogSearchOptions { Page = 2, PageLimit = 1 }; // Act var changeLog = Services.ChangesService.FilterChangeLogRecords(changeLogRecords, searchOptions, _graphProxyConfigs); // Assert -- fetch middle item from the changelog sample Assert.NotNull(changeLog); Assert.Collection(changeLog.ChangeLogs, item => { Assert.Equal("2d94636a-2d78-44d6-8b08-ff2a9121214b", item.Id); Assert.Equal("Extensions", item.WorkloadArea); Assert.Equal("Schema extensions", item.SubArea); Assert.Collection(item.ChangeList, item => { Assert.Equal("2d94636a-2d78-44d6-8b08-ff2a9121214b", item.Id); Assert.Equal("Resource", item.ApiChange); Assert.Equal("schema extensions,Microsoft Cloud for US Government.", item.ChangedApiName); Assert.Equal("Addition", item.ChangeType); Assert.Equal("schema extensions,Microsoft Cloud for US Government", item.Target); }); }); }
public async Task <IActionResult> GetChangesAsync( [FromQuery] string requestUrl = null, [FromQuery] string workload = null, [FromQuery] double daysRange = 0, [FromQuery] DateTime?startDate = null, // yyyy-MM-ddTHH:mm:ss [FromQuery] DateTime?endDate = null, // yyyy-MM-ddTHH:mm:ss [FromQuery] int page = 1, [FromQuery] int?pageLimit = null, [FromQuery] string graphVersion = "v1.0") { try { // Options for searching, filtering and paging the changelog data var searchOptions = new ChangeLogSearchOptions(requestUrl: requestUrl, workload: workload, daysRange: daysRange, startDate: startDate, endDate: endDate) { Page = page, PageLimit = pageLimit }; // Get the requested culture info. var cultureFeature = HttpContext.Features.Get <IRequestCultureFeature>(); var cultureInfo = cultureFeature.RequestCulture.Culture; // Fetch the changelog records var changeLog = await _changesStore.FetchChangeLogRecordsAsync(cultureInfo); // Filter the changelog records if (changeLog.ChangeLogs.Any()) { // Configs for fetching workload names from given requestUrl var graphProxyConfigs = new MicrosoftGraphProxyConfigs() { GraphProxyBaseUrl = _configuration[ChangesServiceConstants.GraphProxyBaseUrlConfigPath], GraphProxyRelativeUrl = _configuration[ChangesServiceConstants.GraphProxyRelativeUrlConfigPath], GraphProxyAuthorization = _configuration[ChangesServiceConstants.GraphProxyAuthorization], GraphVersion = graphVersion }; changeLog = ChangesService.Services.ChangesService .FilterChangeLogRecords(changeLog, searchOptions, graphProxyConfigs, _httpClientUtility); } else { // No records return(NoContent()); } if (!changeLog.ChangeLogs.Any()) { // Filtered items yielded no result return(NotFound()); } return(Ok(changeLog)); } catch (InvalidOperationException ex) { return(new JsonResult(ex.Message) { StatusCode = StatusCodes.Status400BadRequest }); } catch (ArgumentException ex) { return(new JsonResult(ex.Message) { StatusCode = StatusCodes.Status404NotFound }); } catch (Exception ex) { return(new JsonResult(ex.Message) { StatusCode = StatusCodes.Status500InternalServerError }); } }