예제 #1
0
 def pair(self, token, my_time=None):
     auth_instances = (X11PathsAuthentication(self.app_id,
                                              self.secret_key,
                                              utc=my_time), )
     return self._http_request(
         "GET",
         self.API_PAIR_URL__VERSION % self.API_VERSION + "/" + token,
         authentication_instances=auth_instances)
예제 #2
0
 def test_11paths_authentication_class_with_dynamic_time(self):
     auth = X11PathsAuthentication(app_id="123456", secret="654321")
     context = HttpRequestContext(method="POST",
                                  url_path="/path/",
                                  body_params={"param": "value"},
                                  renderer=FormRenderer())
     res_context = auth.apply_authentication(context=context)
     self.assertNotEqual("11PATHS 123456 8Ok3S1xUFLtjRxRkWVoZAKXZc1A=",
                         res_context.headers["Authorization"])
    def __init__(self, app_id, secret_key):
        """
        Initialize the Metashield SDK with provided user information.

        :param app_id: User appId to be used
        :param secret_key: User secretKey to be used
        """
        super(MetashieldCleanUp, self).__init__()
        self.app_id = app_id
        self.secret_key = secret_key
        self.authentication_instances += (X11PathsAuthentication(
            self.app_id, self.secret_key), )
예제 #4
0
    def __init__(self, app_id, secret_key, host=HOST, port=PORT):
        """Initialize the DIARIO SDK with provided user information.
        :param app_id: User appId to be used
        :param secret_key: User secretKey to be used
        :param host: IP address or domain
        :param port: TCP port
        """
        HOST = "{0}:{1}".format(host, port)
        super(TacytApp, self).__init__(host=HOST)

        self.app_id = app_id
        self.secret_key = secret_key
        self.authentication_instances += (X11PathsAuthentication(
            self.app_id, self.secret_key), )
예제 #5
0
 def test_11paths_authentication_post_empty_body_params(self):
     auth = X11PathsAuthentication(
         app_id="2kNhWLEETQ46KWLnAg48",
         secret="lBc4BSeqCGkidJZXictc3yiHbKBS87hjE05YrswJ",
         utc="2017-01-27 08:27:44")
     context = HttpRequestContext(method="POST",
                                  url_path="/ExternalApi/CleanFile",
                                  renderer=JSONRenderer())
     res_context = auth.apply_authentication(context=context)
     self.assertEqual(
         "11PATHS 2kNhWLEETQ46KWLnAg48 atYkLRYJ3b+CXU+GdklyALAr9NE=",
         res_context.headers["Authorization"])
     self.assertNotIn(X_11PATHS_BODY_HASH_HEADER_NAME, res_context.headers)
     self.assertEqual("application/x-www-form-urlencoded",
                      res_context.headers["Content-Type"])
예제 #6
0
 def test_11paths_authentication_class_json_ignorecase_header_name(self):
     auth = X11PathsAuthentication(app_id="123456",
                                   secret="654321",
                                   utc="2016-01-01 00:00:00")
     context = HttpRequestContext(
         method="POST",
         url_path="/path/",
         headers={"Content-type": "application/json"},
         body_params={"param": "value"},
         renderer=JSONRenderer())
     res_context = auth.apply_authentication(context=context)
     self.assertEqual("11PATHS 123456 6CFsVmrRxEz3Icz6U8SSHZ4RukE=",
                      res_context.headers[AUTHORIZATION_HEADER_NAME])
     self.assertEqual("f247c7579b452d08f38eec23c2d1a4a23daee0d2",
                      res_context.headers[X_11PATHS_BODY_HASH_HEADER_NAME])
예제 #7
0
    def __init__(self, app_id, secret_key, host=HOST, port=PORT):
        """Initialize the DIARIO SDK with provided user information.
        :param app_id: User appId to be used
        :param secret_key: User secretKey to be used
        :param host: IP address or domain
        :param port: TCP port
        """

        # HttpSdk.set_default_proxy("https://localhost:8080")
        HOST = "{0}:{1}".format(host, port)
        super(Diario, self).__init__(host=HOST)

        self.app_id = app_id
        self.secret_key = secret_key
        self.authentication_instances += (X11PathsAuthentication(
            self.app_id, self.secret_key), )
예제 #8
0
 def test_11paths_authentication_post_json_empty_body_params(self):
     auth = X11PathsAuthentication(
         app_id="2kNhWLEETQ46KWLnAg48",
         secret="lBc4BSeqCGkidJZXictc3yiHbKBS87hjE05YrswJ",
         utc="2017-01-27 08:27:44")
     context = HttpRequestContext(
         method="POST",
         url_path="/ExternalApi/CleanFile",
         headers={"Content-Type": "application/json"})
     res_context = auth.apply_authentication(context=context)
     self.assertEqual(
         "11PATHS 2kNhWLEETQ46KWLnAg48 u/91oWtEs2qkco5v6JXcfWx+FJ0=",
         res_context.headers["Authorization"])
     self.assertEqual("application/json",
                      res_context.headers["Content-Type"])
     self.assertEqual("da39a3ee5e6b4b0d3255bfef95601890afd80709",
                      res_context.headers["X-11paths-body-hash"])
예제 #9
0
 def test_11paths_authentication_post_json_body_params(self):
     auth = X11PathsAuthentication(
         app_id="2kNhWLEETQ46KWLnAg48",
         secret="lBc4BSeqCGkidJZXictc3yiHbKBS87hjE05YrswJ",
         utc="2017-01-27 08:27:44")
     context = HttpRequestContext(
         method="POST",
         url_path="/ExternalApi/CleanFile",
         body_params={"param": "value"},
         headers={"Content-Type": "application/json"})
     res_context = auth.apply_authentication(context=context)
     self.assertEqual(
         "11PATHS 2kNhWLEETQ46KWLnAg48 zvsWw6S2XZpke6rSvdpe0swlOIc=",
         res_context.headers["Authorization"])
     self.assertEqual("application/json",
                      res_context.headers["Content-Type"])
     self.assertEqual("f247c7579b452d08f38eec23c2d1a4a23daee0d2",
                      res_context.headers["X-11paths-body-hash"])
예제 #10
0
 def test_11paths_authentication_class_multiples_headers(self):
     auth = X11PathsAuthentication(
         app_id="2kNhWLEETQ46KWLnAg48",
         secret="lBc4BSeqCGkidJZXictc3yiHbKBS87hjE05YrswJ",
         utc="2017-01-27 08:27:44")
     context = HttpRequestContext(
         method="POST",
         url_path="/ExternalApi/CleanFile",
         renderer=MultiPartRenderer(),
         headers={
             "X-11paths-profile-id": "77ed609a-1a9b-4c16-97c2-ba32f72f5499",
             "Content-Type": "multipart/form-data"
         },
         files={"file": "tests/resources/file.png"})
     res_context = auth.apply_authentication(context=context)
     self.assertEqual(
         "11PATHS 2kNhWLEETQ46KWLnAg48 8/fuEv9NLn41ikh96hRHMFGs1ww=",
         res_context.headers["Authorization"])
예제 #11
0
    def create_file_11paths_auth(self,
                                 filename,
                                 file_stream,
                                 app_id,
                                 secret,
                                 description=None,
                                 name=None):
        """
        Create a file using 11paths authentication.

        :return: SdkResponse
        """
        auth = (X11PathsAuthentication(app_id, secret), )
        params = parse_args(name=name, description=description)
        return self.post(self.API_FILE_URL_PATH,
                         body_params=params,
                         files={"file": (filename, file_stream)},
                         authentication_instances=auth,
                         host="https://latch.elevenpaths.com")
예제 #12
0
 def test_11paths_authentication_form_multi(self):
     auth = X11PathsAuthentication(
         app_id="QRKJw6qX4fykZ3G3yqkQ",
         secret="eHkAXTebECWBs4TtNbNMBYC99AzMrmaydUWcUFEM",
         utc="2016-12-12 11:18:45")
     context = HttpRequestContext(
         method="POST",
         url_path=
         "/api/0.1/vulnerabilities/15fc104c-dc55-41d4-8d4e-4d76eda7a029/consequences",
         body_params={
             "consequence.scopes[]": "1",
             "consequence.impact[]": "1",
             "consequence.description[es]": "test",
             "consequence.description[en]": "test"
         },
         renderer=FormRenderer())
     res_context = auth.apply_authentication(context=context)
     self.assertEqual(
         "11PATHS QRKJw6qX4fykZ3G3yqkQ CMf3royzdD4l/P0RVKyr2uOXZ4Y=",
         res_context.headers[AUTHORIZATION_HEADER_NAME])
예제 #13
0
def set_11path_authorization(context, app_id, secret):
    safe_add_http_request_context_to_behave_context(context)
    context.http_request_context.authentication_instances.append(
        X11PathsAuthentication(app_id=app_id, secret=secret))
예제 #14
0
 def __init__(self, app_id, secret_key):
     super(Latch, self).__init__()
     self.app_id = app_id
     self.secret_key = secret_key
     self.authentication_instances += (X11PathsAuthentication(
         self.app_id, self.secret_key), )