Пример #1
0
        public void SignUri_WhenCalled_ShouldReturnUriWithTheApiKey()
        {
            //arrange
            var sut = new UriSignedConstructor(new SignatureConstructor(), new SignatureHasher(_secretKey), _apiKey);


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

            //assert
            actual.Should(Be.StringContaining("apikey=" + _apiKey));
        }
Пример #2
0
        public async Task <JsonTextReader> Get(string url)
        {
            var now = DateTime.Now;

            var signedUri = _uriSignedConstructor.SignUri(url, now);

            var request = WebRequest.Create(signedUri) as HttpWebRequest;

            request.Accept = "application/json; version=1";

            ReplaceTheHeaderDateProperty(request, now);

            var response = await request.GetResponseAsync();

            return(new JsonTextReader(new StreamReader(response.GetResponseStream())));
        }
Пример #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));
        }