Esempio n. 1
0
        public async Task DeleteAcrTag()
        {
            using (var context = MockContext.Start(GetType(), nameof(DeleteAcrTag)))
            {
                var client = await ACRTestUtil.GetACRClientAsync(context, ACRTestUtil.ManagedTestRegistryForChanges);

                var tags = await client.Tag.GetListAsync(ACRTestUtil.deleteableRepository);

                await client.Tag.DeleteAsync(ACRTestUtil.deleteableRepository, tags.Tags[0].Name);

                var newTags = await client.Tag.GetListAsync(ACRTestUtil.deleteableRepository);

                Assert.DoesNotContain(newTags.Tags, tag => { return(tag.Equals(tags.Tags[0])); });
            }
        }
        public async Task DeleteAcrRepositoryMR()
        {
            using (var context = MockContext.Start(GetType().FullName, nameof(DeleteAcrRepositoryMR)))
            {
                var client = await ACRTestUtil.GetACRClientAsync(context, ACRTestUtil.ManagedTestRegistryForDeleting);

                var deletedRepo = await client.DeleteAcrRepositoryAsync(ACRTestUtil.TestRepository);

                Assert.Equal(1, deletedRepo.ManifestsDeleted.Count);
                Assert.Equal("sha256:eabe547f78d4c18c708dd97ec3166cf7464cc651f1cbb67e70d407405b7ad7b6", deletedRepo.ManifestsDeleted[0]);
                Assert.Equal(2, deletedRepo.TagsDeleted.Count);
                Assert.Collection(deletedRepo.TagsDeleted, tag => Assert.Equal("01", tag),
                                  tag => Assert.Equal("latest", tag));
            }
        }
Esempio n. 3
0
        public async Task GetAcrTags()
        {
            using (var context = MockContext.Start(GetType(), nameof(GetAcrTags)))
            {
                var client = await ACRTestUtil.GetACRClientAsync(context, ACRTestUtil.ManagedTestRegistry);

                var tags = await client.Tag.GetListAsync(ACRTestUtil.ProdRepository);

                Assert.Equal(ACRTestUtil.ProdRepository, tags.ImageName);
                Assert.Equal(ACRTestUtil.ManagedTestRegistryFullName, tags.Registry);
                Assert.Equal(2, tags.Tags.Count);
                ValidateTagAttributesBase(tags.Tags[0], prodTags.Tags[0]);
                ValidateTagAttributesBase(tags.Tags[1], prodTags.Tags[1]);
            }
        }
Esempio n. 4
0
        public async Task GetBlobStatus()
        {
            using (var context = MockContext.Start(GetType(), nameof(GetBlobStatus)))
            {
                AzureContainerRegistryClient client = await ACRTestUtil.GetACRClientAsync(context, ACRTestUtil.ManagedTestRegistry);

                var uploadInfo = await client.Blob.StartUploadAsync(ACRTestUtil.BlobTestRepository);

                var status = await client.Blob.GetStatusAsync(uploadInfo.Location.Substring(1));

                Assert.Equal(uploadInfo.DockerUploadUUID, status.DockerUploadUUID);
                Assert.Equal("0-0", status.Range);
                await client.Blob.CancelUploadAsync(uploadInfo.Location);
            }
        }
Esempio n. 5
0
        public async Task MountBlob()
        {
            using (var context = MockContext.Start(GetType(), nameof(MountBlob)))
            {
                AzureContainerRegistryClient client = await ACRTestUtil.GetACRClientAsync(context, ACRTestUtil.ManagedTestRegistryForChanges);

                var res = await client.Blob.MountAsync("somethingnew", "doundo/bash", "sha256:16463e0c481e161aabb735437d30b3c9c7391c2747cc564bb927e843b73dcb39");

                Stream blob = await client.Blob.GetAsync("somethingnew", "sha256:16463e0c481e161aabb735437d30b3c9c7391c2747cc564bb927e843b73dcb39");

                StreamReader reader       = new StreamReader(blob, Encoding.UTF8);
                string       originalBlob = reader.ReadToEnd();
                Assert.Equal(ProdConfigBlob, originalBlob);
            }
        }
        public async Task CreateAndDeleteManifest()
        {
            using (var context = MockContext.Start(GetType(), nameof(CreateAndDeleteManifest)))
            {
                var client = await ACRTestUtil.GetACRClientAsync(context, ACRTestUtil.ManagedTestRegistryForChanges);

                await client.Manifests.CreateAsync(ACRTestUtil.changeableRepository, "temporary", ExpectedV2ManifestProd);

                var newManifest = (V2Manifest)await client.Manifests.GetAsync(ACRTestUtil.changeableRepository, "temporary", ACRTestUtil.MediatypeV2Manifest);

                var tag = await client.Tag.GetAttributesAsync(ACRTestUtil.changeableRepository, "temporary");

                VerifyManifest(ExpectedV2ManifestProd, newManifest);
                await client.Manifests.DeleteAsync(ACRTestUtil.changeableRepository, tag.Attributes.Digest);
            }
        }
Esempio n. 7
0
        public async Task GetAcrRepositoryDetails()
        {
            using (var context = MockContext.Start(GetType(), nameof(GetAcrRepositoryDetails)))
            {
                var client = await ACRTestUtil.GetACRClientAsync(context, ACRTestUtil.ManagedTestRegistry);

                var repositoryDetails = await client.Repository.GetAttributesAsync(ACRTestUtil.ProdRepository);

                Assert.Equal(ACRTestUtil.ManagedTestRegistryFullName, repositoryDetails.Registry);
                Assert.Equal(2, repositoryDetails.TagCount);
                Assert.Equal(2, repositoryDetails.ManifestCount);
                Assert.Equal("2019-08-01T22:49:11.1632015Z", repositoryDetails.CreatedTime);
                Assert.Equal(ACRTestUtil.ProdRepository, repositoryDetails.ImageName);
                Assert.False(repositoryDetails.ChangeableAttributes.DeleteEnabled);
                Assert.True(repositoryDetails.ChangeableAttributes.ListEnabled);
                Assert.True(repositoryDetails.ChangeableAttributes.ReadEnabled);
                Assert.False(repositoryDetails.ChangeableAttributes.WriteEnabled);
            }
        }
        public async Task GetAcrRepositoryDetailsMR()
        {
            using (var context = MockContext.Start(GetType().FullName, nameof(GetAcrRepositoryDetailsMR)))
            {
                var client = await ACRTestUtil.GetACRClientAsync(context, ACRTestUtil.ManagedTestRegistry);

                var repositoryDetails = await client.GetAcrRepositoryAttributesAsync(ACRTestUtil.ProdRepository);

                Assert.Equal(ACRTestUtil.ManagedTestRegistryFullName, repositoryDetails.Registry);
                Assert.Equal(1, repositoryDetails.TagCount);
                Assert.Equal(1, repositoryDetails.ManifestCount);
                Assert.Equal("2018-09-28T23:37:52.0356217Z", repositoryDetails.LastUpdateTime);
                Assert.Equal("2018-09-28T23:37:51.9668212Z", repositoryDetails.CreatedTime);
                Assert.Equal(ACRTestUtil.ProdRepository, repositoryDetails.ImageName);
                Assert.True(repositoryDetails.ChangeableAttributes.DeleteEnabled);
                Assert.True(repositoryDetails.ChangeableAttributes.ListEnabled);
                Assert.True(repositoryDetails.ChangeableAttributes.ReadEnabled);
                Assert.True(repositoryDetails.ChangeableAttributes.WriteEnabled);
            }
        }
Esempio n. 9
0
        public async Task ListRepository()
        {
            using (var context = MockContext.Start(GetType(), nameof(ListRepository)))
            {
                var client = await ACRTestUtil.GetACRClientAsync(context, ACRTestUtil.ManagedTestRegistry);

                var repositories = await client.Repository.GetListAsync(null, 1);

                Assert.Equal(1, repositories.Names.Count);
                Assert.Collection(repositories.Names, name => Assert.Equal(ACRTestUtil.ManifestListTestRepository, name));

                repositories = await client.Repository.GetListAsync();

                Assert.Equal(4, repositories.Names.Count);
                Assert.Collection(repositories.Names, name => Assert.Equal(ACRTestUtil.ManifestListTestRepository, name),
                                  name => Assert.Equal(ACRTestUtil.OCITestRepository, name),
                                  name => Assert.Equal(ACRTestUtil.ProdRepository, name),
                                  name => Assert.Equal(ACRTestUtil.TestRepository, name));
            }
        }
Esempio n. 10
0
        public async Task GetAcrTagsMR()
        {
            using (var context = MockContext.Start(GetType().FullName, nameof(GetAcrTagsMR)))
            {
                var client = await ACRTestUtil.GetACRClientAsync(context, ACRTestUtil.ManagedTestRegistry);

                var tags = await client.GetAcrTagsAsync(ACRTestUtil.ProdRepository);

                Assert.Equal(ACRTestUtil.ProdRepository, tags.ImageName);
                Assert.Equal(ACRTestUtil.ManagedTestRegistryFullName, tags.Registry);
                Assert.Equal(1, tags.TagsAttributes.Count);
                var tagAttributes = tags.TagsAttributes[0];
                Assert.Equal("latest", tagAttributes.Name);
                Assert.Equal("2018-09-28T23:37:52.0607161Z", tagAttributes.LastUpdateTime);
                Assert.Equal("2018-09-28T23:37:52.0607161Z", tagAttributes.CreatedTime);
                Assert.Equal("sha256:eabe547f78d4c18c708dd97ec3166cf7464cc651f1cbb67e70d407405b7ad7b6", tagAttributes.Digest);
                Assert.True(tagAttributes.ChangeableAttributes.DeleteEnabled);
                Assert.True(tagAttributes.ChangeableAttributes.ReadEnabled);
                Assert.True(tagAttributes.ChangeableAttributes.ListEnabled);
                Assert.True(tagAttributes.ChangeableAttributes.WriteEnabled);
            }
        }