public async Task FindPackagesByIdTest() { string packageId = string.Format("TestV2FeedFindPackagesById.{0}", DateTime.UtcNow.Ticks); TestOutputHelper.WriteLine("Uploading package '{0}'", packageId); await _clientSdkHelper.UploadNewPackage(packageId, "1.0.0"); TestOutputHelper.WriteLine("Uploaded package '{0}'", packageId); await _clientSdkHelper.UploadNewPackage(packageId, "2.0.0"); // Wait for the packages to be available in V2 (due to async validation) await _clientSdkHelper.VerifyPackageExistsInV2Async(packageId, "1.0.0"); await _clientSdkHelper.VerifyPackageExistsInV2Async(packageId, "2.0.0"); string url = UrlHelper.V2FeedRootUrl + @"/FindPackagesById()?id='" + packageId + "'&$orderby=Version"; string[] expectedTexts = { @"<id>" + UrlHelper.V2FeedRootUrl + "Packages(Id='" + packageId + "',Version='1.0.0')</id>", @"<id>" + UrlHelper.V2FeedRootUrl + "Packages(Id='" + packageId + "',Version='2.0.0')</id>" }; var containsResponseText = await _odataHelper.ContainsResponseText(url, expectedTexts); Assert.True(containsResponseText); }
public async Task VerifyPackageKeyReturns200ForFullApiKey() { // Arrange var packageId = $"VerifyPackageKeyReturns200ForFullApiKey.{DateTimeOffset.UtcNow.Ticks}"; var packageVersion = "1.0.0"; await _clientSdkHelper.UploadNewPackage(packageId, packageVersion); // Act & Assert Assert.Equal(HttpStatusCode.OK, await VerifyPackageKey(EnvironmentSettings.TestAccountApiKey, packageId)); Assert.Equal(HttpStatusCode.OK, await VerifyPackageKey(EnvironmentSettings.TestAccountApiKey, packageId, packageVersion)); }
public async Task VerifyPackageKey_Returns404ForMissingPackage() { // Arrange var packageId = $"VerifyPackageKey_Returns404ForMissingPackage.{DateTimeOffset.UtcNow.Ticks}"; var packageVersion = "1.0.0"; await _clientSdkHelper.UploadNewPackage(packageId, packageVersion); var verificationKey = await CreateVerificationKey(EnvironmentSettings.TestAccountApiKey, packageId, packageVersion); // Act & Assert Assert.Equal(HttpStatusCode.NotFound, await VerifyPackageKey(verificationKey, packageId + "_bad", packageVersion)); }
public async Task UploadMultipleVersionOfPackage() { var packageId = string.Format("TestMultipleVersion.{0}", DateTime.Now.Ticks); await _clientSdkHelper.UploadNewPackage(packageId, "1.0.0"); await _clientSdkHelper.UploadNewPackage(packageId, "2.0.0"); _clientSdkHelper.VerifyPackageExistsInSource(packageId, "1.0.0"); _clientSdkHelper.VerifyPackageExistsInSource(packageId, "2.0.0"); _clientSdkHelper.VerifyVersionCount(packageId, 2); }
public async Task PackagesAppearInFeedInOrderTest() { // This test uploads/unlists packages in a particular order to test the timestamps of the packages in the feed. // Because it waits for previous requests to finish before starting new ones, it will only catch ordering issues if these issues are greater than a second or two. // This is consistent with the time frame in which we've seen these issues in the past, but if new issues arise that are on a smaller scale, this test will not catch it! if (CanUploadToSite()) { var packageIds = new List <string>(PackagesInOrderNumPackages); var startingTime = DateTime.UtcNow; // Upload the packages in order. var uploadStartTimestamp = DateTime.UtcNow.AddMinutes(-1); for (var i = 0; i < PackagesInOrderNumPackages; i++) { var packageId = GetPackagesAppearInFeedInOrderPackageId(startingTime, i); await _clientSdkHelper.UploadNewPackage(packageId); packageIds.Add(packageId); } await CheckPackageTimestampsInOrder(packageIds, "Created", uploadStartTimestamp); // Unlist the packages in order. var unlistStartTimestamp = DateTime.UtcNow.AddMinutes(-1); for (var i = 0; i < PackagesInOrderNumPackages; i++) { await _clientSdkHelper.UnlistPackage(packageIds[i]); } await CheckPackageTimestampsInOrder(packageIds, "LastEdited", unlistStartTimestamp); } }
public async Task ScopedApiKeysCanOnlyPushAndUnlistWithCorrectScopes() { // Arrange var packageCreationHelper = new PackageCreationHelper(TestOutputHelper); var commandlineHelper = new CommandlineHelper(TestOutputHelper); var packageId = UploadHelper.GetUniquePackageId(nameof(ScopedApiKeysCanOnlyPushAndUnlistWithCorrectScopes)); var version1 = "1.0.0"; var version2 = "2.0.0"; // 1. Try to upload package using 'unlist' api key => expect failure TestOutputHelper.WriteLine($"1. Trying to upload package '{packageId}', version '{version1}' using 'unlist' API key. Expected result: failure."); await _clientSdkHelper.UploadNewPackage(packageId, version1, apiKey : EnvironmentSettings.TestAccountApiKey_Unlist, success : false); // 2. Try to upload package using 'push version' api key => expect failure TestOutputHelper.WriteLine($"2. Trying to upload package '{packageId}', version '{version1}' using 'push version' API key. Expected result: failure."); await _clientSdkHelper.UploadNewPackage(packageId, version1, apiKey : EnvironmentSettings.TestAccountApiKey_PushVersion, success : false); // 3. Upload package using 'push' api key => expect success TestOutputHelper.WriteLine($"3. Trying to upload package '{packageId}', version '{version1}' using 'push' API key. Expected result: success."); await _clientSdkHelper.UploadNewPackage(packageId, version1, apiKey : EnvironmentSettings.TestAccountApiKey_Push); // 4. Upload new version of package using 'push version' api key => expect success TestOutputHelper.WriteLine($"4. Trying to upload package '{packageId}', version '{version2}' using 'push version' API key. Expected result: success."); await _clientSdkHelper.UploadNewPackage(packageId, version2, apiKey : EnvironmentSettings.TestAccountApiKey_PushVersion); // Verify the existence of the two pushed packages. await _clientSdkHelper.VerifyPackageExistsInV2Async(packageId, version1); await _clientSdkHelper.VerifyPackageExistsInV2Async(packageId, version2); // 5. Try unlisting package version1 using 'push' api key => expect failure TestOutputHelper.WriteLine($"5. Trying to unlist package '{packageId}', version '{version1}' using 'push' API key. Expected result: failure."); await _clientSdkHelper.UnlistPackage(packageId, version1, EnvironmentSettings.TestAccountApiKey_Push, success : false); // 6. Try unlisting package version2 using 'push version' api key => expect failure TestOutputHelper.WriteLine($"6. Trying to unlist package '{packageId}', version '{version2}' using 'push' API key. Expected result: failure."); await _clientSdkHelper.UnlistPackage(packageId, version2, EnvironmentSettings.TestAccountApiKey_PushVersion, success : false); // 7. Unlist both packages using 'unlist' api key => expect succees TestOutputHelper.WriteLine($"7. Trying to unlist package '{packageId}', version '{version1}' using 'unlist' API key. Expected result: success."); await _clientSdkHelper.UnlistPackage(packageId, version1, EnvironmentSettings.TestAccountApiKey_Unlist); TestOutputHelper.WriteLine($"8. Trying to unlist package '{packageId}', version '{version2}' using 'unlist' API key. Expected result: success."); await _clientSdkHelper.UnlistPackage(packageId, version2, EnvironmentSettings.TestAccountApiKey_Unlist); }
public async Task UploadAndUnlistPackagesAsOrganizationCollaborator() { var apiKey = EnvironmentSettings.TestOrganizationCollaboratorAccountApiKey; // Cannot push new package ID as organization await _clientSdkHelper.UploadNewPackage( UploadHelper.GetUniquePackageId(nameof(UploadAndUnlistPackagesAsOrganizationCollaborator)), success : false, apiKey : apiKey); // Can push new version of an existing package as organization var id = Constants.TestOrganizationCollaboratorPackageId; var version = UploadHelper.GetUniquePackageVersion(); await _clientSdkHelper.UploadNewPackageAndVerify(id, version, apiKey : apiKey); // Can unlist versions of an existing package as organization await _clientSdkHelper.UnlistPackageAndVerify(id, version, apiKey); }
public async Task FindPackagesByIdTest() { string packageId = string.Format("TestV2FeedFindPackagesById.{0}", DateTime.UtcNow.Ticks); TestOutputHelper.WriteLine("Uploading package '{0}'", packageId); await _clientSdkHelper.UploadNewPackage(packageId); TestOutputHelper.WriteLine("Uploaded package '{0}'", packageId); await _clientSdkHelper.UploadNewPackage(packageId, "2.0.0"); // "&$orderby=Version" is appended to bypass the search hijacker string url = UrlHelper.V2FeedRootUrl + @"/FindPackagesById()?id='" + packageId + "'&$orderby=Version"; string[] expectedTexts = { @"<id>" + UrlHelper.V2FeedRootUrl + "Packages(Id='" + packageId + "',Version='1.0.0')</id>", @"<id>" + UrlHelper.V2FeedRootUrl + "Packages(Id='" + packageId + "',Version='2.0.0')</id>" }; var containsResponseText = await _odataHelper.ContainsResponseText(url, expectedTexts); Assert.True(containsResponseText); }