protected override Task <ISymbolStore> GetStoreWithFileAsync() { fakeHttpMessageHandler.ContentMap[new Uri(URL_IN_STORE)] = Encoding.UTF8.GetBytes(BUILD_ID.ToHexString()); return(Task.FromResult <ISymbolStore>( new HttpSymbolStore(fakeFileSystem, httpClient, STORE_URL))); }
public async Task AddFile_VerifyPathStructureAsync() { var store = GetEmptyStore(); var fileReference = await store.AddFileAsync(sourceSymbolFile, FILENAME, BUILD_ID, log); Assert.AreEqual(Path.Combine(STORE_PATH, FILENAME, BUILD_ID.ToString(), FILENAME), fileReference.Location); }
protected override Task <ISymbolStore> GetStoreWithFileAsync() { _crashReportClient.GenerateSymbolFileDownloadUrlAsync(BUILD_ID.ToHexString(), FILENAME) .Returns(_urlInStore); _fakeHttpMessageHandler.ContentMap[new Uri(_urlInStore)] = Encoding.UTF8.GetBytes(BUILD_ID.ToHexString()); return(Task.FromResult <ISymbolStore>( new StadiaSymbolStore(fakeFileSystem, _httpClient, _crashReportClient))); }
public async Task FindFile_HttpRequestExceptionAsync() { _crashReportClient.GenerateSymbolFileDownloadUrlAsync(BUILD_ID.ToHexString(), FILENAME) .Returns(_urlInStore); _fakeHttpMessageHandler.ExceptionMap[new Uri(_urlInStore)] = new HttpRequestException("message"); ISymbolStore store = new StadiaSymbolStore(fakeFileSystem, _httpClient, _crashReportClient); IFileReference fileReference = await store.FindFileAsync(FILENAME, BUILD_ID, true, log); Assert.Null(fileReference); StringAssert.Contains(Strings.FailedToSearchStadiaStore(FILENAME, "message"), log.ToString()); }
public async Task FindFile_HttpNotFoundAsync() { _crashReportClient.GenerateSymbolFileDownloadUrlAsync(BUILD_ID.ToHexString(), FILENAME) .Returns(_urlInStore); // By default, HTTP client returns Not Found for every file. ISymbolStore store = new StadiaSymbolStore(fakeFileSystem, _httpClient, _crashReportClient); IFileReference fileReference = await store.FindFileAsync(FILENAME, BUILD_ID, true, log); Assert.Null(fileReference); StringAssert.Contains( Strings.FileNotFoundInStadiaStore(BUILD_ID.ToHexString(), FILENAME), log.ToString()); }
public async Task FindFile_APIExceptionAsync() { var ex = new CloudException( "Failed to generate download URL: permission denied", new RpcException(new Status(StatusCode.PermissionDenied, "message"))); _crashReportClient.GenerateSymbolFileDownloadUrlAsync(BUILD_ID.ToHexString(), FILENAME) .Returns(x => Task.FromException <string>(ex)); ISymbolStore store = new StadiaSymbolStore(fakeFileSystem, _httpClient, _crashReportClient); IFileReference fileReference = await store.FindFileAsync(FILENAME, BUILD_ID, true, log); Assert.Null(fileReference); StringAssert.Contains(Strings.FailedToSearchStadiaStore(FILENAME, ex.Message), log.ToString()); }
public async Task FindFile_InvalidSymbolFileWithCacheAsync() { string storeAPath = Path.Combine(STORE_A_PATH, FILENAME, BUILD_ID.ToString(), FILENAME); fakeBuildIdWriter.WriteBuildId(storeAPath, BUILD_ID); sourceSymbolFile = new FileReference(fakeFileSystem, storeAPath); fakeBinaryFileUtil.AddVerificationFailureFor(BUILD_ID, "Symbol verification error"); storeSequence.AddStore(cacheA); storeSequence.AddStore(storeA); var logWriter = new StringWriter(); var fileReference = await storeSequence.FindFileAsync(FILENAME, BUILD_ID, true, logWriter); Assert.That(fileReference, Is.Null); }
public async Task FindFile_InvalidSymbolFileInCacheAsync() { // Test the scenario where the symbol store cache contains an invalid symbol file, // but the store contains a correct file. In that case, we should overwrite the cache // with the correct file and return a reference to it. string storeAPath = Path.Combine(STORE_A_PATH, FILENAME, BUILD_ID.ToString(), FILENAME); fakeBuildIdWriter.WriteBuildId(storeAPath, BUILD_ID); sourceSymbolFile = new FileReference(fakeFileSystem, storeAPath); BuildId badBuildId = new BuildId("BAAD"); string cacheAPath = Path.Combine(CACHE_A_PATH, FILENAME, BUILD_ID.ToString(), FILENAME); fakeBuildIdWriter.WriteBuildId(cacheAPath, badBuildId); sourceSymbolFile = new FileReference(fakeFileSystem, cacheAPath); fakeBinaryFileUtil.AddVerificationFailureFor(badBuildId, "Symbol verification error"); storeSequence.AddStore(cacheA); storeSequence.AddStore(storeA); var logWriter = new StringWriter(); var fileReference = await storeSequence.FindFileAsync(FILENAME, BUILD_ID, true, logWriter); Assert.That(fileReference.Location, Is.EqualTo((await cacheA.FindFileAsync(FILENAME, BUILD_ID)).Location)); Assert.That(await fakeBinaryFileUtil.ReadBuildIdAsync( (await storeA.FindFileAsync(FILENAME, BUILD_ID)).Location), Is.EqualTo(BUILD_ID)); Assert.That(await fakeBinaryFileUtil.ReadBuildIdAsync( (await cacheA.FindFileAsync(FILENAME, BUILD_ID)).Location), Is.EqualTo(BUILD_ID)); }