Пример #1
0
        public void Load_IfSigningSpecificationsIsNull_Throws()
        {
            var exception = Assert.Throws <ArgumentNullException>(
                () => SignatureContent.Load(new byte[] { }, signingSpecifications: null));

            Assert.Equal("signingSpecifications", exception.ParamName);
        }
Пример #2
0
        public void Load_IfBytesIsNull_Throws()
        {
            var exception = Assert.Throws <ArgumentNullException>(
                () => SignatureContent.Load(bytes: null, signingSpecifications: SigningSpecifications.V1));

            Assert.Equal("bytes", exception.ParamName);
        }
Пример #3
0
        public void Load_IfContentIsInvalid_Throws(string content)
        {
            var bytes = Encoding.UTF8.GetBytes(content);

            var exception = Assert.Throws <SignatureException>(
                () => SignatureContent.Load(bytes, SigningSpecifications.V1));

            Assert.Equal("The package signature content is invalid.", exception.Message);
        }
Пример #4
0
        public void Load_ReadsValidContent()
        {
            var content = SignatureContent.Load(
                Encoding.UTF8.GetBytes("Version:1\r\n\r\n2.16.840.1.101.3.4.2.1-Hash:a\r\n\r\n"),
                SigningSpecifications.V1);

            Assert.Equal(HashAlgorithmName.SHA256, content.HashAlgorithm);
            Assert.Equal("a", content.HashValue);
        }
Пример #5
0
        public void Load_IfHashAlgorithmIsUnsupported_Throws(string content)
        {
            var bytes = Encoding.UTF8.GetBytes(content);

            var exception = Assert.Throws <SignatureException>(
                () => SignatureContent.Load(bytes, SigningSpecifications.V1));

            Assert.Equal("Package hash information could not be read from the package signature.", exception.Message);
        }
Пример #6
0
        public void Load_IfSignatureFormatVersionIsUnsupported_Throws()
        {
            var bytes = Encoding.UTF8.GetBytes("Version:2\n\n");

            var exception = Assert.Throws <SignatureException>(
                () => SignatureContent.Load(bytes, SigningSpecifications.V1));

            Assert.Equal(NuGetLogCode.NU3007, exception.Code);
            Assert.Equal(
                "The package signature format version is not supported. Updating your client may solve this problem.",
                exception.Message);
        }