public void Constructor_WithValidInput_InitializesProperty()
        {
            var packageOwners      = new[] { "a", "b", "c" };
            var nugetPackageOwners = new NuGetPackageOwners(packageOwners);

            Assert.Equal(packageOwners, nugetPackageOwners.PackageOwners);
        }
        public void Read_WithInvalidPackageOwner_Throws(string packageOwner)
        {
            var bytes = new DerSequence(new DerUtf8String(packageOwner)).GetDerEncoded();

            var exception = Assert.Throws <SignatureException>(() => NuGetPackageOwners.Read(bytes));

            Assert.Equal("The nuget-package-owners attribute is invalid.", exception.Message);
        }
Пример #3
0
        public void CreateNuGetPackageOwners_WithValidInput_ReturnsInstance()
        {
            var packageOwners = new[] { "a", "b", "c" };
            var attribute     = AttributeUtility.CreateNuGetPackageOwners(packageOwners);

            Assert.Equal(Oids.NuGetPackageOwners, attribute.Oid.Value);
            Assert.Equal(1, attribute.Values.Count);

            var nugetPackageOwners = NuGetPackageOwners.Read(attribute.Values[0].RawData);

            Assert.Equal(packageOwners, nugetPackageOwners.PackageOwners);
        }
        public void Read_WithValidInput_ReturnsInstance()
        {
            var packageOwners = new[] { "a", "b", "c" };
            var sequence      = new DerSequence(
                new DerUtf8String("a"),
                new DerUtf8String("b"),
                new DerUtf8String("c"));
            var bytes = sequence.GetDerEncoded();

            var nugetPackageOwners = NuGetPackageOwners.Read(bytes);

            Assert.Equal(packageOwners, nugetPackageOwners.PackageOwners);
        }
        public void Encode_ReturnsValidDer()
        {
            var packageOwners = new[] { "a", "b", "c" };

            var sequence = new DerSequence(
                new DerUtf8String("a"),
                new DerUtf8String("b"),
                new DerUtf8String("c"));
            var expectedBytes      = sequence.GetDerEncoded();
            var nugetPackageOwners = new NuGetPackageOwners(packageOwners);

            var actualBytes = nugetPackageOwners.Encode();

            Assert.Equal(expectedBytes, actualBytes);
        }
Пример #6
0
        private static void VerifyAttributesRepository(
            CryptographicAttributeObjectCollection attributes,
            SignPackageRequest request,
            Uri v3ServiceIndexUrl,
            IReadOnlyList <string> packageOwners)
        {
            VerifyAttributes(attributes, request);

            var nugetV3ServiceIndexUrlAttributeFound = false;
            var nugetPackageOwnersAttributeFound     = false;

            foreach (var attribute in attributes)
            {
                Assert.Equal(1, attribute.Values.Count);

                switch (attribute.Oid.Value)
                {
                case Oids.NuGetV3ServiceIndexUrl:
                    var nugetV3ServiceIndexUrl = NuGetV3ServiceIndexUrl.Read(attribute.Values[0].RawData);

                    Assert.True(nugetV3ServiceIndexUrl.V3ServiceIndexUrl.IsAbsoluteUri);
                    Assert.Equal(v3ServiceIndexUrl.OriginalString, nugetV3ServiceIndexUrl.V3ServiceIndexUrl.OriginalString);

                    nugetV3ServiceIndexUrlAttributeFound = true;
                    break;

                case Oids.NuGetPackageOwners:
                    var nugetPackageOwners = NuGetPackageOwners.Read(attribute.Values[0].RawData);

                    Assert.Equal(packageOwners, nugetPackageOwners.PackageOwners);

                    nugetPackageOwnersAttributeFound = true;
                    break;
                }
            }

            Assert.True(nugetV3ServiceIndexUrlAttributeFound);
            Assert.Equal(packageOwners != null && packageOwners.Count > 0, nugetPackageOwnersAttributeFound);
        }
 public void Read_WithInvalidAsn1_Throws()
 {
     Assert.Throws <CryptographicException>(() => NuGetPackageOwners.Read(new byte[] { 0x30, 0x0b }));
 }