public async Task Get_ClientArchiveResource_ReturnsNotFoundIfNotFound()
        {
            var archivedConfig = "SampleConfig_123454.json";
            var testContext    = TestHttpContextBuilder.CreateForPath($"/{clientId}/{archivedConfig}")
                                 .WithClaims(readClaim)
                                 .TestContext;
            var expectedResource = new ConfigArchiveEntry
            {
                HasEntry = false
            };

            configArchive.Setup(r => r.GetArchiveConfig(archivedConfig, It.Is <ConfigurationIdentity>(s => s.Client.Equals(expectedClient))))
            .ReturnsAsync(() => expectedResource);
            await target.Handle(testContext, options);

            httpResponseFactory.Verify(f => f.BuildNotFoundStatusResponse(testContext));
        }
        public async Task Get_ClientArchiveResource_GetsClientResource()
        {
            var archivedConfig = "SampleConfig_123454.json";
            var testContext    = TestHttpContextBuilder.CreateForPath($"/{clientId}/{archivedConfig}")
                                 .WithClaims(readClaim)
                                 .TestContext;
            var expectedResource = new ConfigArchiveEntry
            {
                HasEntry = true,
                Content  = "JsonString",
                Name     = archivedConfig
            };

            configArchive.Setup(r => r.GetArchiveConfig(archivedConfig, It.Is <ConfigurationIdentity>(s => s.Client.Equals(expectedClient))))
            .ReturnsAsync(() => expectedResource);
            await target.Handle(testContext, options);

            httpResponseFactory.Verify(f => f.BuildJsonFileResponse(testContext, expectedResource.Content, expectedResource.Name));
        }
        public Task <ConfigArchiveEntry> GetArchiveConfig(string name, ConfigurationIdentity identity)
        {
            string path = Path.Combine(GetArchiveResourceSetFolder(identity).FullName, name);

            if (!File.Exists(path))
            {
                return(Task.FromResult(new ConfigArchiveEntry {
                    Name = name, Content = string.Empty
                }));
            }
            var storageObject = JObject.Parse(File.ReadAllText(path));
            var json          = storageObject.GetValue("Config").ToString();
            var result        = new ConfigArchiveEntry
            {
                Name     = name,
                Content  = json,
                HasEntry = true
            };

            return(Task.FromResult(result));
        }