Exemplo n.º 1
0
 def get_base_string(url, method, query_params, oauth_parameters):
     # Merge the query string parameters
     merge_params = oauth_parameters.copy()
     #  merge_params.update(query_params)
     return "{}&{}&{}".format(
         util.uri_rfc3986_encode(method.upper()),
         util.uri_rfc3986_encode(util.normalize_url(url)),
         util.uri_rfc3986_encode(util.normalize_params(url, merge_params)))
Exemplo n.º 2
0
    def test_signature_base_string(self):
        uri = "https://api.mastercard.com"
        base_uri = Util.normalize_url(uri)

        oauth_parameters = OAuthParameters()
        oauth_parameters.set_oauth_body_hash("body/hash")
        oauth_parameters.set_oauth_nonce("randomnonce")

        base_string = OAuth.get_base_string(base_uri, "POST", oauth_parameters.get_base_parameters_dict())
        self.assertEqual("POST&https%3A%2F%2Fapi.mastercard.com%2F&oauth_body_hash%3Dbody%2Fhash%26oauth_nonce%3Drandomnonce", base_string);
Exemplo n.º 3
0
 def get_base_string(url, method, oauth_parameters):
     merge_params = oauth_parameters.copy()
     return "{}&{}&{}".format(util.uri_rfc3986_encode(method.upper()),
                              util.uri_rfc3986_encode(util.normalize_url(url)),
                              util.uri_rfc3986_encode(util.normalize_params(url, merge_params)))
Exemplo n.º 4
0
 def test_url_normalization_lowercase_scheme_and_host(self):
     uri = "HTTPS://API.MASTERCARD.COM/TEST"
     base_uri = Util.normalize_url(uri)
     self.assertEqual("https://api.mastercard.com/TEST", base_uri)
Exemplo n.º 5
0
 def test_url_normalization_add_trailing_slash(self):
     uri = "https://api.mastercard.com"
     base_uri = Util.normalize_url(uri)
     self.assertEqual("https://api.mastercard.com/", base_uri)
Exemplo n.º 6
0
 def test_url_normalization_remove_fragment(self):
     uri = "https://api.mastercard.com/test?query=param#fragment"
     base_uri = Util.normalize_url(uri)
     self.assertEqual("https://api.mastercard.com/test", base_uri)
Exemplo n.º 7
0
 def test_url_normalization_redundant_ports3(self):
     uri = "https://api.mastercard.com:17443/test?query=param"
     base_uri = Util.normalize_url(uri)
     self.assertEqual("https://api.mastercard.com:17443/test", base_uri)
Exemplo n.º 8
0
 def test_url_normalization_redundant_ports2(self):
     uri = "http://api.mastercard.com:80/test"
     base_uri = Util.normalize_url(uri)
     self.assertEqual("http://api.mastercard.com/test", base_uri)
Exemplo n.º 9
0
 def test_url_normalization_rfc_examples2(self):
     uri = "http://EXAMPLE.COM:80/r%20v/X?id=123"
     base_uri = Util.normalize_url(uri)
     self.assertEqual("http://example.com/r%20v/X", base_uri)
Exemplo n.º 10
0
 def test_url_normalization_rfc_examples1(self):
     uri = "https://www.example.net:8080"
     base_uri = Util.normalize_url(uri)
     self.assertEqual("https://www.example.net:8080/", base_uri)