public void GetNuGetPackageOwners_WithMultipleAttributes_Throws()
        {
            using (var certificate = _fixture.GetDefaultCertificate())
            {
                var attributes = CreateAttributeCollection(certificate, _fixture.DefaultKeyPair.Private,
                                                           vector =>
                {
                    var attribute = new BcAttribute(
                        new DerObjectIdentifier(Oids.NuGetPackageOwners),
                        new DerSet(
                            new DerSequence(
                                new DerUtf8String("a"),
                                new DerUtf8String("b"),
                                new DerUtf8String("c"))));

                    vector.Add(attribute);
                    vector.Add(attribute);
                });

                var exception = Assert.Throws <CryptographicException>(
                    () => AttributeUtility.GetNuGetPackageOwners(attributes));

                Assert.Equal("Multiple 1.3.6.1.4.1.311.84.2.1.1.2 attributes are not allowed.", exception.Message);
            }
        }
        public void GetNuGetPackageOwners_WhenSignedAttributesNull_Throws()
        {
            var exception = Assert.Throws <ArgumentNullException>(
                () => AttributeUtility.GetNuGetPackageOwners(signedAttributes: null));

            Assert.Equal("signedAttributes", exception.ParamName);
        }
        public void GetNuGetPackageOwners_WithValidInput_ReturnsUrl()
        {
            var packageOwners = new[] { "a", "b", "c" };
            var attribute     = AttributeUtility.CreateNuGetPackageOwners(packageOwners);
            var attributes    = new CryptographicAttributeObjectCollection(attribute);

            var nugetPackageOwners = AttributeUtility.GetNuGetPackageOwners(attributes);

            Assert.Equal(packageOwners, nugetPackageOwners);
        }
        public void GetNuGetPackageOwners_WithMultipleAttributeValues_Throws()
        {
            using (var certificate = _fixture.GetDefaultCertificate())
            {
                var attributes = CreateAttributeCollection(certificate, _fixture.DefaultKeyPair.Private,
                                                           vector =>
                {
                    var value = new DerSequence(
                        new DerUtf8String("a"),
                        new DerUtf8String("b"),
                        new DerUtf8String("c"));
                    var attribute = new BcAttribute(
                        new DerObjectIdentifier(Oids.NuGetPackageOwners),
                        new DerSet(value, value));

                    vector.Add(attribute);
                });

                var exception = Assert.Throws <SignatureException>(
                    () => AttributeUtility.GetNuGetPackageOwners(attributes));

                Assert.Equal("The nuget-package-owners attribute must have exactly one attribute value.", exception.Message);
            }
        }
        public void GetNuGetPackageOwners_WithEmptySignedAttributes_ReturnsNull()
        {
            var packageOwners = AttributeUtility.GetNuGetPackageOwners(new CryptographicAttributeObjectCollection());

            Assert.Null(packageOwners);
        }