Exemplo n.º 1
0
        public void checking_expiry_with_expired_ticket_works() {
            var signer = new TimeStampSigner("testing");
            var signed = signer.Sign("hello world");

            System.Threading.Thread.Sleep(1100);

            signer.HasExpired(signed, 1).ShouldBe(true);
        }
Exemplo n.º 2
0
        public void can_sign_with_timestamp() {
            var timedsigner = new TimeStampSigner("testing");
            var signed = timedsigner.Sign("hello world");

            var unsigned = timedsigner.Unsign(signed);

            unsigned.ShouldBe("hello world");
        }
Exemplo n.º 3
0
        public void tampering_with_timestamp_throws() {
            var timedsigner = new TimeStampSigner("testing");
            var signed = timedsigner.Sign("hello world");

            signed = signed.Substring(0, 15) + 3 + signed.Substring(15);

            Assert.Throws<BadSignatureException>(() => {
                var unsigned = timedsigner.Unsign(signed, 1);
            });
        }
Exemplo n.º 4
0
        public void timestamp_age_check_works() {
            var timedsigner = new TimeStampSigner("testing");
            var signed = timedsigner.Sign("hello world");

            Trace.WriteLine(signed);

            System.Threading.Thread.Sleep(1100);

            Assert.Throws<SignatureExpiredException>(() => {
                var unsigned = timedsigner.Unsign(signed, 1);
            });
        }
Exemplo n.º 5
0
        public void checking_expiry_with_valid_ticket_works() {
            var signer = new TimeStampSigner("testing");
            var signed = signer.Sign("hello world");

            signer.HasExpired(signed, 2).ShouldBe(false);
        }