コード例 #1
0
        public async Task ExcludesGloballyIgnoredProject(Project p)
        {
            _ruleSet.IgnoreGlobally.Projects = new[] { p.Name };

            Harbor.Setup(h => h.GetAllProjects()).ReturnsAsync(new[] { p });

            await _sut.Process();

            Serilog.Verify(l => l.Verbose("Skipping project {@project}", p.Name), Times.Once);
            Harbor.Verify(h => h.GetRepositories(It.IsAny <int>()), Times.Never);
        }
コード例 #2
0
        public async Task ExcludesGloballyIgnoredRepos(Project p, Repository r)
        {
            _ruleSet.IgnoreGlobally.Repos = new[] { r.Name };

            Harbor.Setup(h => h.GetAllProjects()).ReturnsAsync(new[] { p });
            Harbor.Setup(h => h.GetRepositories(It.IsAny <int>())).ReturnsAsync(new[] { r });

            await _sut.Process();

            Serilog.Verify(l => l.Verbose("Skipping repository {@repository}", r), Times.Once);
            Harbor.Verify(h => h.GetTags(It.IsAny <string>()), Times.Never);
        }
コード例 #3
0
        public async Task RuleExcludesTag(Tag t)
        {
            _fixture.Inject(new Regex(".*"));
            _ruleSet.Rules.Add(_fixture.Build <Rule>().WithAutoProperties().With(r => r.Ignore, new[] { t.Name }).Create());

            Harbor.Setup(h => h.GetTags(It.IsAny <string>())).ReturnsAsync(new[] { t });

            await _sut.Process();

            Serilog.Verify(l => l.Information("Tag {repo}:{name} skipped because it was found in an ignore list that applies to {repo}", t.Repository, t.Name, _repository.Name), Times.Once);
            Harbor.Verify(h => h.DeleteTag(It.IsAny <string>(), It.IsAny <string>()), Times.Never);
        }
コード例 #4
0
        public async Task ExcludesGloballyIgnoredTags(Project p, Repository r, Tag t)
        {
            _ruleSet.IgnoreGlobally.Tags = new[] { t.Name };

            Harbor.Setup(h => h.GetAllProjects()).ReturnsAsync(new[] { p });
            Harbor.Setup(h => h.GetRepositories(It.IsAny <int>())).ReturnsAsync(new[] { r });
            Harbor.Setup(h => h.GetTags(It.IsAny <string>())).ReturnsAsync(new[] { t });

            await _sut.Process();

            Serilog.Verify(l => l.Information("Tag {repo}:{name} skipped due to global ignore rules", t.Repository, t.Name), Times.Once);
            Harbor.Verify(h => h.DeleteTag(It.IsAny <string>(), It.IsAny <string>()), Times.Never);
        }
コード例 #5
0
        public async Task UnmatchedTagsAreKeptImplicitly()
        {
            _ruleSet.DefaultRule.Tag = new Regex("^$");

            var tags = _fixture.CreateMany <Tag>(10);

            Harbor.Setup(h => h.GetTags(It.IsAny <string>())).ReturnsAsync(tags);

            await _sut.Process();

            Harbor.Verify(h => h.DeleteTag(It.IsAny <string>(), It.IsAny <string>()), Times.Never);
            Serilog.Verify(l => l.Warning("The default rule did not match all remaining tags for {@repo}. {count} remaining tags will be kept", _repository, 10), Times.Once);
        }
コード例 #6
0
        public async Task SkipsHarbor14CorruptTags()
        {
            var tag = _fixture.Build <Tag>()
                      .WithAutoProperties()
                      .Without(t => t.Digest)
                      .Create();

            Harbor.Setup(h => h.GetTags(It.IsAny <string>())).ReturnsAsync(new[] { tag });

            await _sut.Process();

            Serilog.Verify(l => l.Warning("Tag {repo}:{name} does not have a digest and was likely corrupted during a delete operation. This tag will be skipped. See https://github.com/vmware/harbor/issues/4214 for details", tag.Repository, tag.Name), Times.Once);
            Harbor.Verify(h => h.DeleteTag(It.IsAny <string>(), It.IsAny <string>()), Times.Never);
        }