コード例 #1
0
        public void Given_an_epub_file_then_when_signed_it_has_the_correct_signature()
        {
            const String nonce = "TaPMeKEjVEOJrFm/KLG9AA==";

            var xmlSigner = new XmlSigner(PASSWORD);

            var result = xmlSigner.Sign(Doc, nonce, _anyExpirationTime);

            Assert.That(
                result.DocumentElement.LastChild.InnerText, Is.EqualTo("5RdxB1z60V3QmIPbnVUddAMrrUs="),
                "The HMAC was not calculated as expected."
            );
        }
コード例 #2
0
        public void Sign_throws_format_exceoption_unless_nonce_is_base_64_encoded()
        {
            var xmlSigner = new XmlSigner(PASSWORD);

            var nonce = Guid.NewGuid().ToString();

            const String expectedMessage = "Invalid character in a Base-64 string.";

            Assert.That(
                () => xmlSigner.Sign(Doc, nonce, _anyExpirationTime),
                Throws.TypeOf(typeof(FormatException)).
                With.Property("Message").EqualTo(expectedMessage)
            );
        }
コード例 #3
0
        public void Sign_returns_a_new_xml_document()
        {
            var xmlSigner = new XmlSigner(PASSWORD);

            const String nonce = "TaPMeKEjVEOJrFm/KLG9AA==";

            var result = xmlSigner.Sign(Doc, nonce, _anyExpirationTime);

            Assert.That(
                result,
                Is.Not.SameAs(Doc.DocumentElement),
                "Expected Sign to return a new instance, not update the supplied one."
            );
        }
コード例 #4
0
        public void Check_hash()
        {
            var doc = NewPackagingRequest(EPUB_FILE);

            const String nonce = "TaPMeKEjVEOJrFm/KLG9AA==";
            var expirationTime = new DateTime(2010, 02, 16, 11, 24, 41);

            var result = new XmlSigner(PASSWORD).Sign(
                doc,
                nonce,
                expirationTime
            );

            Assert.That(
                result.DocumentElement.LastChild.InnerText, Is.EqualTo("5RdxB1z60V3QmIPbnVUddAMrrUs="),
                "The HMAC was not calculated as expected."
            );
        }