public async Task UpdateAcrTagAttributesMR() { using (var context = MockContext.Start(GetType().FullName, nameof(UpdateAcrTagAttributesMR))) { var updateAttributes = new ChangeableAttributes() { DeleteEnabled = true, ListEnabled = true, ReadEnabled = true, WriteEnabled = false }; var tag = "latest"; var client = await ACRTestUtil.GetACRClientAsync(context, ACRTestUtil.ManagedTestRegistry); await client.UpdateAcrTagAttributesAsync(ACRTestUtil.ProdRepository, tag, updateAttributes); var tagAttributes = await client.GetAcrTagAttributesAsync(ACRTestUtil.ProdRepository, tag); Assert.False(tagAttributes.TagAttributes.ChangeableAttributes.WriteEnabled); updateAttributes.WriteEnabled = true; await client.UpdateAcrTagAttributesAsync(ACRTestUtil.ProdRepository, tag, updateAttributes); tagAttributes = await client.GetAcrTagAttributesAsync(ACRTestUtil.ProdRepository, tag); Assert.True(tagAttributes.TagAttributes.ChangeableAttributes.WriteEnabled); } }
public async Task UpdateAcrManifestAttributesMR() { using (var context = MockContext.Start(GetType().FullName, nameof(UpdateAcrManifestAttributesMR))) { var updateAttributes = new ChangeableAttributes() { DeleteEnabled = true, ListEnabled = true, ReadEnabled = true, WriteEnabled = false }; var digest = "sha256:eabe547f78d4c18c708dd97ec3166cf7464cc651f1cbb67e70d407405b7ad7b6"; var client = await ACRTestUtil.GetACRClientAsync(context, ACRTestUtil.ManagedTestRegistry); await client.UpdateAcrManifestAttributesAsync(ACRTestUtil.ProdRepository, digest, updateAttributes); var updatedManifest = await client.GetAcrManifestAttributesAsync(ACRTestUtil.ProdRepository, digest); Assert.False(updatedManifest.Manifest.ChangeableAttributes.WriteEnabled); updateAttributes.WriteEnabled = true; await client.UpdateAcrManifestAttributesAsync(ACRTestUtil.ProdRepository, digest, updateAttributes); updatedManifest = await client.GetAcrManifestAttributesAsync(ACRTestUtil.ProdRepository, digest); Assert.Equal(ExpectedAttributesOfProdRepository.ImageName, updatedManifest.ImageName); Assert.Equal(ExpectedAttributesOfProdRepository.Registry, updatedManifest.Registry); VerifyAcrManifestAttributesBase(ExpectedAttributesOfProdRepository.Manifest, updatedManifest.Manifest); } }
public async Task GetManifestMR() { using (var context = MockContext.Start(GetType().FullName, nameof(GetManifestMR))) { var tag = "latest"; var client = await ACRTestUtil.GetACRClientAsync(context, ACRTestUtil.ManagedTestRegistry); var manifest = await client.GetManifestAsync(ACRTestUtil.TestRepository, tag); Assert.Equal(1, manifest.SchemaVersion); Assert.Equal(ACRTestUtil.TestRepository, manifest.Name); Assert.Equal(tag, manifest.Tag); Assert.Equal("amd64", manifest.Architecture); Assert.Equal(10, manifest.FsLayers.Count); Assert.Equal(10, manifest.ImageHistories.Count); Assert.Equal(1, manifest.Signatures.Count); var signature = manifest.Signatures[0]; Assert.NotEqual(string.Empty, signature.ProtectedHeader); Assert.NotEqual(string.Empty, signature.Signature); Assert.Equal("P-256", signature.Header.Jwk.Crv); Assert.NotEqual(string.Empty, signature.Header.Jwk.Kid); Assert.Equal("EC", signature.Header.Jwk.Kty); Assert.NotEqual(string.Empty, signature.Header.Jwk.X); Assert.NotEqual(string.Empty, signature.Header.Jwk.Y); } }
public async Task UpdateAcrManifestAttributes() { using (var context = MockContext.Start(GetType(), nameof(UpdateAcrManifestAttributes))) { var client = await ACRTestUtil.GetACRClientAsync(context, ACRTestUtil.ManagedTestRegistryForChanges); var updateAttributes = new ChangeableAttributes() { DeleteEnabled = true, ListEnabled = true, ReadEnabled = true, WriteEnabled = false }; var digest = "sha256:dbefd3c583a226ddcef02536cd761d2d86dc7e6f21c53f83957736d6246e9ed8"; //Update attributes await client.Manifests.UpdateAttributesAsync(ACRTestUtil.changeableRepository, digest, updateAttributes); var updatedManifest = await client.Manifests.GetAttributesAsync(ACRTestUtil.changeableRepository, digest); //Check for success Assert.False(updatedManifest.Attributes.ChangeableAttributes.WriteEnabled); //Return attributes to original updateAttributes.WriteEnabled = true; await client.Manifests.UpdateAttributesAsync(ACRTestUtil.changeableRepository, digest, updateAttributes); updatedManifest = await client.Manifests.GetAttributesAsync(ACRTestUtil.changeableRepository, digest); Assert.Equal(ExpectedAttributesChangeableRepository.ImageName, updatedManifest.ImageName); Assert.Equal(ExpectedAttributesChangeableRepository.Registry, updatedManifest.Registry); VerifyAcrManifestAttributesBase(ExpectedAttributesChangeableRepository.Attributes, updatedManifest.Attributes); } }
public async Task UpdateAcrRepositoryAttributes() { using (var context = MockContext.Start(GetType(), nameof(UpdateAcrRepositoryAttributes))) { var client = await ACRTestUtil.GetACRClientAsync(context, ACRTestUtil.ManagedTestRegistryForChanges); //Changeable attributes var updateAttributes = new ChangeableAttributes() { DeleteEnabled = false, ListEnabled = true, ReadEnabled = true, WriteEnabled = false }; await client.Repository.UpdateAttributesAsync(ACRTestUtil.changeableRepository, updateAttributes); var repositoryDetails = await client.Repository.GetAttributesAsync(ACRTestUtil.changeableRepository); //Undo change in remote (in case this fails) updateAttributes.WriteEnabled = true; updateAttributes.DeleteEnabled = true; await client.Repository.UpdateAttributesAsync(ACRTestUtil.changeableRepository, updateAttributes); //Check success Assert.Equal(1, repositoryDetails.TagCount); Assert.Equal(1, repositoryDetails.ManifestCount); Assert.Equal(ACRTestUtil.changeableRepository, 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 UpdateAcrRepositoryAttributesMR() { using (var context = MockContext.Start(GetType().FullName, nameof(UpdateAcrRepositoryAttributesMR))) { var client = await ACRTestUtil.GetACRClientAsync(context, ACRTestUtil.ManagedTestRegistry); var updateAttributes = new ChangeableAttributes() { DeleteEnabled = true, ListEnabled = true, ReadEnabled = true, WriteEnabled = false }; await client.UpdateAcrRepositoryAttributesAsync(ACRTestUtil.ProdRepository, updateAttributes); 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.False(repositoryDetails.ChangeableAttributes.WriteEnabled); updateAttributes.WriteEnabled = true; await client.UpdateAcrRepositoryAttributesAsync(ACRTestUtil.ProdRepository, updateAttributes); } }
public async Task DeleteAcrRepository() { using (var context = MockContext.Start(GetType(), nameof(DeleteAcrRepository))) { var client = await ACRTestUtil.GetACRClientAsync(context, ACRTestUtil.ManagedTestRegistryForChanges); var repositories = await client.Repository.GetListAsync(); //Selects one of the previously stored hello-world repositories for deletion string deletableRepo = ""; foreach (var repo in repositories.Names) { if (repo.StartsWith("hello-world")) { deletableRepo = repo; continue; } } var deletedRepo = await client.Repository.DeleteAsync(deletableRepo); Assert.Equal(1, deletedRepo.ManifestsDeleted.Count); Assert.Equal("sha256:92c7f9c92844bbbb5d0a101b22f7c2a7949e40f8ea90c8b3bc396879d95e899a", deletedRepo.ManifestsDeleted[0]); Assert.Equal(1, deletedRepo.TagsDeleted.Count); Assert.Collection(deletedRepo.TagsDeleted, tag => Assert.Equal("latest", tag)); } }
public async Task DeleteAcrTagCRThrowException() { using (var context = MockContext.Start(GetType().FullName, nameof(DeleteAcrTagCRThrowException))) { var client = await ACRTestUtil.GetACRClientAsync(context, ACRTestUtil.ClassicTestRegistry); await Assert.ThrowsAsync <AcrErrorsException>(() => client.DeleteAcrTagAsync(ACRTestUtil.ProdRepository, "latest")); } }
public async Task GetAcrRepositoriesCRThrowException() { using (var context = MockContext.Start(GetType().FullName, nameof(GetAcrRepositoriesCRThrowException))) { var client = await ACRTestUtil.GetACRClientAsync(context, ACRTestUtil.ClassicTestRegistry); await Assert.ThrowsAsync <AcrErrorsException>(() => client.GetAcrRepositoriesAsync()); } }
public async Task GetAcrRepositoryDetailsCRThrowException() { using (var context = MockContext.Start(this.GetType(), nameof(GetAcrRepositoryDetailsCRThrowException))) { var client = await ACRTestUtil.GetACRClientAsync(context, ACRTestUtil.ClassicTestRegistry); await Assert.ThrowsAsync <AcrErrorsException>(() => client.GetAcrRepositoryAttributesAsync(ACRTestUtil.ProdRepository)); } }
public async Task DeleteAcrRepositoryCRThrowException() { using (var context = MockContext.Start(this.GetType(), nameof(DeleteAcrRepositoryCRThrowException))) { var client = await ACRTestUtil.GetACRClientAsync(context, ACRTestUtil.ClassicTestRegistryForDeleting); await Assert.ThrowsAsync <AcrErrorsException>(() => client.DeleteAcrRepositoryAsync("prod/bash")); } }
public async Task UpdateAcrTagAttributesCRThrowException() { using (var context = MockContext.Start(GetType().FullName, nameof(UpdateAcrTagAttributesCRThrowException))) { var client = await ACRTestUtil.GetACRClientAsync(context, ACRTestUtil.ClassicTestRegistry); await Assert.ThrowsAsync <AcrErrorsException>(() => client.UpdateAcrTagAttributesAsync(ACRTestUtil.ProdRepository, "latest", default(ChangeableAttributes))); } }
public async Task GetAcrAccessTokenFromLogin() { using (var context = MockContext.Start(GetType(), nameof(GetAcrAccessTokenFromLogin))) { AzureContainerRegistryClient client = await ACRTestUtil.GetACRClientAsync(context, ACRTestUtil.ManagedTestRegistry); var accessToken = await client.AccessTokens.GetFromLoginAsync(ACRTestUtil.ManagedTestRegistryFullName, ACRTestUtil.Scope); ValidateAccessToken(accessToken.AccessTokenProperty); } }
public async Task GetAcrRefreshTokenFromExchange() { using (var context = MockContext.Start(GetType(), nameof(GetAcrRefreshTokenFromExchange))) { AzureContainerRegistryClient client = await ACRTestUtil.GetACRClientAsync(context, ACRTestUtil.ManagedTestRegistry); var refreshToken = await client.RefreshTokens.GetFromExchangeAsync("access_token", ACRTestUtil.ManagedTestRegistryFullName, null, null, await ACRTestUtil.GetAADAccessToken()); ValidateRefreshToken(refreshToken.RefreshTokenProperty); } }
public async Task CancelBlobUpload() { using (var context = MockContext.Start(GetType(), nameof(CancelBlobUpload))) { AzureContainerRegistryClient client = await ACRTestUtil.GetACRClientAsync(context, ACRTestUtil.ManagedTestRegistryForChanges); var uploadInfo = await client.Blob.StartUploadAsync(ACRTestUtil.changeableRepository); await client.Blob.CancelUploadAsync(uploadInfo.Location); } }
public async Task GetAcrManifestAttributesCRReturnsNull() { using (var context = MockContext.Start(GetType().FullName, nameof(GetAcrManifestAttributesCRReturnsNull))) { var client = await ACRTestUtil.GetACRClientAsync(context, ACRTestUtil.ClassicTestRegistry); var manifestAttributes = await client.GetAcrManifestAttributesAsync(ACRTestUtil.ProdRepository, "sha256:eabe547f78d4c18c708dd97ec3166cf7464cc651f1cbb67e70d407405b7ad7b6"); Assert.Null(manifestAttributes); } }
public async Task CheckBlob() { using (var context = MockContext.Start(GetType(), nameof(CheckBlob))) { AzureContainerRegistryClient client = await ACRTestUtil.GetACRClientAsync(context, ACRTestUtil.ManagedTestRegistry); var blob = await client.Blob.CheckAsync(ACRTestUtil.ProdRepository, ProdConfigBlobDigest); Assert.Equal(blob.DockerContentDigest, ProdConfigBlobDigest); Assert.Equal(5635, blob.ContentLength); } }
public async Task CheckBlobChunk() { using (var context = MockContext.Start(GetType(), nameof(CheckBlobChunk))) { AzureContainerRegistryClient client = await ACRTestUtil.GetACRClientAsync(context, ACRTestUtil.ManagedTestRegistry); var blobData = await client.Blob.CheckChunkAsync(ACRTestUtil.ProdRepository, ProdConfigBlobDigest, "bytes=0-300"); //Range is actually ignored in this request. Ends up working quite similarly to CheckBlob Assert.Equal(5635, blobData.ContentLength); } }
public async Task GetV2Manifest() { using (var context = MockContext.Start(GetType(), nameof(GetV2Manifest))) { var tag = "latest"; var client = await ACRTestUtil.GetACRClientAsync(context, ACRTestUtil.ManagedTestRegistry); var manifest = (V2Manifest)await client.Manifests.GetAsync(ACRTestUtil.TestRepository, tag, ACRTestUtil.MediatypeV2Manifest); VerifyManifest(ExpectedV2ManifestProd, manifest); } }
public async Task GetOCIIndex() { using (var context = MockContext.Start(GetType(), nameof(GetOCIIndex))) { var tag = "oci"; var client = await ACRTestUtil.GetACRClientAsync(context, ACRTestUtil.ManagedTestRegistry); var manifest = (OCIIndex)await client.Manifests.GetAsync(ACRTestUtil.ManifestListTestRepository, tag, ACRTestUtil.MediatypeOCIIndex); VerifyManifest(ExpectedOCIIndex, manifest); } }
public async Task MoreScopeTests(string headerValue, string expectedScope) { using (var context = MockContext.Start(GetType(), nameof(MoreScopeTests))) { var _httpRequest = new HttpRequestMessage(); _httpRequest.Headers.Add("Www-Authenticate", headerValue); var client = await ACRTestUtil.GetCredentialsAsync(context, ACRTestUtil.ManagedTestRegistryForChanges); string actualScope = client.GetScopeFromHeaders(_httpRequest.Headers); Assert.Equal(expectedScope, actualScope); } }
public async Task DeleteAcrTagMR() { using (var context = MockContext.Start(GetType().FullName, nameof(DeleteAcrTagMR))) { var client = await ACRTestUtil.GetACRClientAsync(context, ACRTestUtil.ManagedTestRegistryForDeleting); await client.DeleteAcrTagAsync(ACRTestUtil.ProdRepository, "latest"); var tags = await client.GetTagListAsync(ACRTestUtil.ProdRepository); Assert.Equal(0, tags.Tags.Count); } }
public async Task GetTagsCR() { using (var context = MockContext.Start(GetType().FullName, nameof(GetTagsCR))) { var client = await ACRTestUtil.GetACRClientAsync(context, ACRTestUtil.ClassicTestRegistry); var tags = await client.GetTagListAsync(ACRTestUtil.ProdRepository); Assert.Equal(1, tags.Tags.Count); Assert.Equal("latest", tags.Tags[0]); Assert.Equal(ACRTestUtil.ProdRepository, tags.Name); } }
public async Task GetTags() { using (var context = MockContext.Start(GetType(), nameof(GetTags))) { var client = await ACRTestUtil.GetACRClientAsync(context, ACRTestUtil.ManagedTestRegistry); var tags = await client.Tag.GetListAsync(ACRTestUtil.ProdRepository); Assert.Equal(2, tags.Tags.Count); Assert.Equal("latest", tags.Tags[1].Name); Assert.Equal(ACRTestUtil.ProdRepository, tags.ImageName); } }
public async Task ListRepositoryCR() { using (var context = MockContext.Start(this.GetType(), nameof(ListRepositoryCR))) { var client = await ACRTestUtil.GetACRClientAsync(context, ACRTestUtil.ClassicTestRegistry); var repositories = await client.GetRepositoriesAsync(); Assert.Equal(2, repositories.Names.Count); Assert.Collection(repositories.Names, name => Assert.Equal(ACRTestUtil.ProdRepository, name), name => Assert.Equal(ACRTestUtil.TestRepository, name)); } }
public async Task GetAcrRepositoriesMR() { using (var context = MockContext.Start(GetType().FullName, nameof(GetAcrRepositoriesMR))) { var client = await ACRTestUtil.GetACRClientAsync(context, ACRTestUtil.ManagedTestRegistry); var repositories = await client.GetAcrRepositoriesAsync(); Assert.Equal(2, repositories.Names.Count); Assert.Collection(repositories.Names, name => Assert.Equal(ACRTestUtil.ProdRepository, name), name => Assert.Equal(ACRTestUtil.TestRepository, name)); } }
public async Task GetBlob() { using (var context = MockContext.Start(GetType(), nameof(GetBlob))) { AzureContainerRegistryClient client = await ACRTestUtil.GetACRClientAsync(context, ACRTestUtil.ManagedTestRegistry); Stream blob = await client.Blob.GetAsync(ACRTestUtil.ProdRepository, ProdConfigBlobDigest); StreamReader reader = new StreamReader(blob, Encoding.UTF8); string originalBlob = reader.ReadToEnd(); Assert.Equal(ProdConfigBlob, originalBlob); } }
public async Task CreateManifestList() { using (var context = MockContext.Start(GetType(), nameof(CreateManifestList))) { var tag = "test-manifest-list"; var client = await ACRTestUtil.GetACRClientAsync(context, ACRTestUtil.ManagedTestRegistry); await client.Manifests.CreateAsync(ACRTestUtil.ManifestListTestRepository, tag, ExpectedManifestList); var manifest = (ManifestList)await client.Manifests.GetAsync(ACRTestUtil.ManifestListTestRepository, tag, ACRTestUtil.MediatypeManifestList); VerifyManifest(ExpectedManifestList, manifest); } }
public async Task GetAcrManifests() { using (var context = MockContext.Start(GetType(), nameof(GetAcrManifests))) { var client = await ACRTestUtil.GetACRClientAsync(context, ACRTestUtil.ManagedTestRegistry); var manifests = await client.Manifests.GetListAsync(ACRTestUtil.ProdRepository); Assert.Equal(ExpectedAttributesOfProdRepository.ImageName, manifests.ImageName); Assert.Equal(ExpectedAttributesOfProdRepository.Registry, manifests.Registry); Assert.Equal(2, manifests.ManifestsAttributes.Count); VerifyAcrManifestAttributesBase(ExpectedAttributesOfProdRepository.Attributes, manifests.ManifestsAttributes[1]); } }
public async Task GetAcrManifestAttributes() { using (var context = MockContext.Start(GetType(), nameof(GetAcrManifestAttributes))) { var client = await ACRTestUtil.GetACRClientAsync(context, ACRTestUtil.ManagedTestRegistry); var repositoryAttributes = await client.Manifests.GetAttributesAsync(ACRTestUtil.ProdRepository, "sha256:dbefd3c583a226ddcef02536cd761d2d86dc7e6f21c53f83957736d6246e9ed8"); Assert.Equal(ExpectedAttributesOfProdRepository.ImageName, repositoryAttributes.ImageName); Assert.Equal(ExpectedAttributesOfProdRepository.Registry, repositoryAttributes.Registry); VerifyAcrManifestAttributesBase(ExpectedAttributesOfProdRepository.Attributes, repositoryAttributes.Attributes); } }