public NpmRepositoryTest()
        {
            RepoUrl = Environment.GetEnvironmentVariable(EnvVar_Url);
            ApiKey  = Environment.GetEnvironmentVariable(EnvVar_ApiKey);
            Assert.True(!string.IsNullOrEmpty(RepoUrl), $"No environment variable found for {EnvVar_Url}");
            Assert.True(!string.IsNullOrEmpty(ApiKey), $"No environment variable found for {EnvVar_ApiKey}");

            ServiceProvider = new ServiceCollection()
                              .AddLogging(loggingBuilder => { loggingBuilder.AddDebug(); })
                              .BuildServiceProvider();

            LoggerFactory = ServiceProvider.GetRequiredService <ILoggerFactory>();

            var sourceRepoFeedConfig = new Settings.Feed
            {
                Name = "packagerepo.npm.test-source",
            };

            sourceRepoFeedConfig.Settings.Add("Uri", (RepoUrl.EndsWith("/") ? RepoUrl.Substring(0, RepoUrl.Length - 1) : RepoUrl) + "-source/");
            sourceRepoFeedConfig.Settings.Add("ApiKey", ApiKey);

            var targetRepoFeedConfig = new Settings.Feed
            {
                Name = "packagerepo.npm.test",
            };

            targetRepoFeedConfig.Settings.Add("Uri", RepoUrl);
            targetRepoFeedConfig.Settings.Add("ApiKey", ApiKey);

            SourceRepo = new NpmRepository(sourceRepoFeedConfig, LoggerFactory);
            TargetRepo = new NpmRepository(targetRepoFeedConfig, LoggerFactory);
        }
Beispiel #2
0
 public void Execute(RepoUrl repo_url)
 {
     try
     {
         repo_url.DeleteAll();
     }
     catch (Exception ex)
     {
         Console.Out.WriteLine(ex.Message);
     }
 }
Beispiel #3
0
        public override int GetHashCode()
        {
            var hashCode = 352033288;

            hashCode = hashCode * -1521134295 + Url.GetHashCode();
            hashCode = hashCode * -1521134295 + Title.GetHashCode();
            hashCode = hashCode * -1521134295 + RepoUrl.GetHashCode();
            hashCode = hashCode * -1521134295 + Number.GetHashCode();

            return(hashCode);
        }
Beispiel #4
0
        public string GetUrl(string url_short)
        {
            if (string.IsNullOrEmpty(url_short) || url_short.Length > 4000)
            {
                throw new Exception("Bad input!");
            }
            long    id      = se.Decode(url_short);
            RepoUrl repoURL = new RepoUrl(ConnectionString);
            string  url     = repoURL.GetUrlById(id);

            return(url);
        }
        public async Task Test_ProgetRepository_Uri_Doesnt_Exist()
        {
            var repoFeedConfig = new Settings.Feed
            {
                Name = "choco.notfound",
            };

            repoFeedConfig.Settings.Add("Uri", RepoUrl.TrimEnd('/') + "-not-found");

            var sourceRepo = new ProgetRepository(repoFeedConfig, LoggerFactory);

            await Assert.ThrowsAsync <WebException>(async() => await sourceRepo.ListAsync(NotepadPlusPlusPackageId, false, true).ToListAsync());
        }
Beispiel #6
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (Chart != null ? Chart.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Directory != null ? Directory.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Helm != null ? Helm.GetHashCode() : 0);
         // hashCode = (hashCode * 397) ^ (Ksonnet != null ? Ksonnet.GetHashCode() : 0);
         // hashCode = (hashCode * 397) ^ (Kustomize != null ? Kustomize.GetHashCode() : 0);
         // hashCode = (hashCode * 397) ^ (Plugin != null ? Plugin.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Path != null ? Path.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (RepoUrl != null ? RepoUrl.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (TargetRevision != null ? TargetRevision.GetHashCode() : 0);
         return(hashCode);
     }
 }
Beispiel #7
0
        public string Shorten(string url)
        {
            Uri uri = null;

            if (string.IsNullOrEmpty(url) || url.Length > 4000 || !Uri.TryCreate(url, UriKind.Absolute, out uri) || null == uri || (uri.Scheme != "http" && uri.Scheme != "https"))
            {
                throw new Exception("Bad input!");
            }
            else
            {
                RepoUrl repoURL = new RepoUrl(ConnectionString);
                long    id      = repoURL.GetOrInsertUrl(url.Trim());
                if (id == 0)
                {
                    throw new Exception("DB Error!");
                }
                return(se.Encode(id));
            }
        }
Beispiel #8
0
        public void TestConnect()
        {
            RepoUrl repoURL = new RepoUrl(ConnectionString);

            repoURL.TestConnect();
        }