예제 #1
0
        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!
            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);
        }
예제 #2
0
        public async Task UploadAndUnlistPackages(string apiKey)
        {
            // Can push new package ID
            await _clientSdkHelper.UploadPackage(apiKey);

            // Can push new version of an existing package
            await _clientSdkHelper.UploadPackageVersion(apiKey);

            // Can unlist versions of an existing package
            await _clientSdkHelper.UnlistPackage(apiKey);
        }
예제 #3
0
        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 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!
            var packageIds     = new List <string>(PackagesInOrderNumPackages);
            var packageVersion = "1.0.0";
            var startingTime   = DateTime.UtcNow;

            // Upload the packages in order.
            var uploadStartTimestamp = DateTime.UtcNow.AddMinutes(-1);

            for (var i = 0; i < PackagesInOrderNumPackages; i++)
            {
                var packageId = $"TestV2FeedPackagesAppearInFeedInOrderTest.{startingTime.Ticks}.{i}";
                await _clientSdkHelper.UploadNewPackage(packageId, packageVersion);

                packageIds.Add(packageId);
            }

            // Wait for the packages to be available in V2 (due to async validation)
            foreach (var packageId in packageIds)
            {
                await _clientSdkHelper.VerifyPackageExistsInV2Async(packageId, packageVersion);
            }

            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);
        }
예제 #5
0
        public async Task VerifyScopedApiKeys()
        {
            // Arrange
            var packageCreationHelper = new PackageCreationHelper(TestOutputHelper);
            var commandlineHelper     = new CommandlineHelper(TestOutputHelper);

            var packageId = "ScopedApiKeysTest_" + DateTime.Now.Ticks;
            var version1  = "1.0.0";
            var version2  = "2.0.0";

            string package1FullPath = null;
            string package2FullPath = null;

            try
            {
                package1FullPath = await packageCreationHelper.CreatePackage(packageId, version1);

                package2FullPath = await packageCreationHelper.CreatePackage(packageId, version2);

                // 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.");
                var processResult = await commandlineHelper.UploadPackageAsync(package1FullPath, UrlHelper.V2FeedPushSourceUrl, EnvironmentSettings.TestAccountApiKey_Unlist);

                Assert.True(processResult.ExitCode != 0, "Package push succeeded, although was expected to fail.");

                // 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.");
                processResult = await commandlineHelper.UploadPackageAsync(package1FullPath, UrlHelper.V2FeedPushSourceUrl, EnvironmentSettings.TestAccountApiKey_PushVersion);

                Assert.True(processResult.ExitCode != 0, "Package push succeeded, although was expected to fail.");

                // 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.UploadExistingPackage(package1FullPath, 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.UploadExistingPackage(package2FullPath, 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 failture
                TestOutputHelper.WriteLine($"5. Trying to unlist package '{packageId}', version '{version1}' using 'push' API key. Expected result: failure.");
                processResult = await commandlineHelper.DeletePackageAsync(packageId, version1, UrlHelper.V2FeedPushSourceUrl, EnvironmentSettings.TestAccountApiKey_Push);

                Assert.True(processResult.ExitCode != 0, "Package delete succeeded, although was expected to fail.");

                // 6. Try unlisting package version2 using 'push version' api key => expect failture
                TestOutputHelper.WriteLine($"6. Trying to unlist package '{packageId}', version '{version2}' using 'push' API key. Expected result: failure.");
                processResult = await commandlineHelper.DeletePackageAsync(packageId, version2, UrlHelper.V2FeedPushSourceUrl, EnvironmentSettings.TestAccountApiKey_PushVersion);

                Assert.True(processResult.ExitCode != 0, "Package delete succeeded, although was expected to fail.");

                // 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);
            }
            finally
            {
                _clientSdkHelper.CleanCreatedPackage(package1FullPath);
                _clientSdkHelper.CleanCreatedPackage(package2FullPath);
            }
        }