Ejemplo n.º 1
0
        public void SignatureFailureTest()
        {
            var context = _workContext.WithTag(_tag);

            var testHeaders = new List <KeyValuePair <string, IEnumerable <string> > >
            {
                new KeyValuePair <string, IEnumerable <string> >("Content-Type", new string[] { "application/x-www-form-urlencoded", "charset=utf-8" }),
                new KeyValuePair <string, IEnumerable <string> >("Content-MD5", new string[] { "kdskflosifm3938dldasksdfjdf" }),
                new KeyValuePair <string, IEnumerable <string> >("Api-Cv", new string[] { "dkdfjdie.1" }),
                new KeyValuePair <string, IEnumerable <string> >("Api-Key", new string[] { "3asfvesef" }),
                new KeyValuePair <string, IEnumerable <string> >("Api-duplicate", new string[] { "false" }),
            };

            var          uri        = new Uri("http://*****:*****@domain.com";

            IHmacConfiguration hmacConfiguration = new HmacConfiguration();
            var    hmac      = new HmacSignature(hmacConfiguration);
            string signature = hmac.CreateSignature(context, credential, apiKey, method, uri, testHeaders);

            signature = signature.Remove(credential.Length + 5, 2);
            hmac.ValidateSignature(context, signature, apiKey, method, uri, testHeaders).Should().BeFalse();
        }