internal DownloadMetadata2CatalogAsyncTest()
            {
                UtcNow      = DateTime.UtcNow;
                LastCreated = UtcNow.AddHours(-3);
                LastEdited  = UtcNow.AddHours(-2);
                LastDeleted = UtcNow.AddHours(-1);

                Packages = new SortedList <DateTime, IList <FeedPackageDetails> >();

                PackageCatalogItemCreator = new Mock <IPackageCatalogItemCreator>(MockBehavior.Strict);
                Storage          = new Mock <IStorage>(MockBehavior.Strict);
                TelemetryService = new Mock <ITelemetryService>(MockBehavior.Strict);
                Logger           = new Mock <ILogger>();

                CatalogBaseUri  = new Uri("https://nuget.test/v3-catalog0/");
                CatalogIndexUri = new Uri(CatalogBaseUri, "index.json");

                Storage.Setup(x => x.ResolveUri(
                                  It.Is <string>(relativeUri => relativeUri == "index.json")))
                .Returns(CatalogIndexUri);

                FeedPackageDetails = new FeedPackageDetails(
                    new Uri("https://nuget.test/packages/a"),
                    UtcNow.AddMinutes(-45),
                    UtcNow.AddMinutes(-30),
                    UtcNow.AddMinutes(-15),
                    packageId: "a",
                    packageVersion: "1.0.0");
            }
예제 #2
0
        /// <inheritdoc />
        public Uri GetUrl(string fileName, string folderName, DateTime expiration)
        {
            if (IsNullOrWhiteSpace(fileName))
            {
                throw new ArgumentNullException(nameof(fileName));
            }

            if (IsNullOrWhiteSpace(folderName))
            {
                throw new ArgumentNullException(nameof(folderName));
            }

            if (expiration == default)
            {
                throw new ArgumentException("Invalid expiration", nameof(expiration));
            }

            var policy = new SharedAccessBlobPolicy
            {
                SharedAccessStartTime  = UtcNow.AddMinutes(-5),
                SharedAccessExpiryTime = expiration,
                Permissions            = Read
            };
            var blob = _cloudBlobClient
                       .GetContainerReference(folderName)
                       .GetBlockBlobReference(fileName);
            var sharedAccessSignature = blob.GetSharedAccessSignature(policy);

            return(new Uri(sharedAccessSignature));
        }
예제 #3
0
 private CheckResult GetCheckResult(int minutesDelta, CheckResultType type)
 {
     return(new CheckResult
     {
         Check = new Check
         {
             Name = CheckName
         },
         CheckBatch = new CheckBatch(),
         Type = type,
         Time = TimeUtilities.DateTimeOffsetToLong(UtcNow.AddMinutes(minutesDelta))
     });
 }
예제 #4
0
        protected virtual bool IsMobileCodeOlderThan(UserAccount account, int duration)
        {
            if (account == null)
            {
                throw new ArgumentNullException(nameof(account));
            }

            if (account.MobileCodeSent == null || string.IsNullOrWhiteSpace(account.MobileCode))
            {
                return(true);
            }

            return(account.MobileCodeSent < UtcNow.AddMinutes(-duration));
        }