public void Hash_WhenStringProvided_ShouldHashProperSignature()
        {
            //arrange
            var key = "helloworld";
            var sut = new SignatureHasher(key);

            //act
            var input = "Mon, 01 Jan 2015 12:00:00+0100\n\nhttps://api.almostinsided.com/thread?filter%5Bforumid%5D=123&order=title+DESC&pageSize=5\napplication/json; version=1";
            var actual = sut.Hash(input);

            //assert
            actual.Should(Be.EqualTo(@"UxOzeeCrGIcVSnnKdCeOEt1ulj5umyXoEpGMHFv/7Z0="));
        }
        public void Hash_WhenStringProvided_ShouldHashProperSignature()
        {
            //arrange
            var key = "helloworld";
            var sut = new SignatureHasher(key);

            //act
            var input  = "Mon, 01 Jan 2015 12:00:00+0100\n\nhttps://api.almostinsided.com/thread?filter%5Bforumid%5D=123&order=title+DESC&pageSize=5\napplication/json; version=1";
            var actual = sut.Hash(input);

            //assert
            actual.Should(Be.EqualTo(@"UxOzeeCrGIcVSnnKdCeOEt1ulj5umyXoEpGMHFv/7Z0="));
        }
Exemplo n.º 3
0
        public void SignUri_WhenCalled_ShouldReturnUriWithSignature()
        {
            //arrange
            var hasher = new SignatureHasher(_secretKey);
            var signatureConstructor = new SignatureConstructor();

            var sut = new UriSignedConstructor(signatureConstructor, hasher, _apiKey);

            //act
            var actual = sut.SignUri(_uri, _now).ToString();

            //assert
            var sigValue = WebUtility.UrlEncode(hasher.Hash(signatureConstructor.BuildSignature(_uri, _now)));

            actual.Should(Be.StringContaining("sig=" + sigValue));
        }
Exemplo n.º 4
0
 public UriSignedConstructor(SignatureConstructor signatureConstructor, SignatureHasher signatureHasher, string apiKey)
 {
     _apiKey = apiKey;
     _signatureConstructor = signatureConstructor;
     _signatureHasher      = signatureHasher;
 }
 public UriSignedConstructor(SignatureConstructor signatureConstructor,SignatureHasher signatureHasher,string apiKey)
 {
     _apiKey = apiKey;
     _signatureConstructor = signatureConstructor;
     _signatureHasher = signatureHasher;
 }