Ejemplo n.º 1
0
    def create_response(self, status):

        response = Response()

        if status:
            response.code = "ok"
            response.status_code = 200
            response._content = self.driver.page_source.encode()
        else:
            response.code = "expired"
            response.status_code = 400
            response._content = b""

        return response
Ejemplo n.º 2
0
 def create_search(self, query_expression):
     respObj = Response()
     if (self.get_token()):
         self.query = query_expression
         response = self.build_searchId()
         if (response != None):
             respObj.code = "200"
             respObj.error_type = ""
             respObj.status_code = 200
             content = '{"search_id": "' + \
                           str(response) + \
                           '", "data": {"message":  "Search id generated."}}'
             respObj._content = bytes(content, 'utf-8')
         else:
             respObj.code = "404"
             respObj.error_type = "Not found"
             respObj.status_code = 404
             respObj.message = "Could not generate search id."
     else:
         respObj.error_type = "Unauthorized: Access token could not be generated."
         respObj.message = "Unauthorized: Access token could not be generated."
     return ResponseWrapper(respObj)
Ejemplo n.º 3
0
    def test_login_with_cloud_login_ok(self, post):
        expected_vectors = None
        expected_token = "mocked_token"

        postRespLogin = Response()
        postRespLogin.code = ""
        postRespLogin.status_code = 200
        post.return_value = self.get_response(
            "", 200,
            b'{"success": "true", "data": {"password": "******", "stok": "mocked_token"}}'
        )
        self.router.cloud_login("user1", "pass1")
        self.assertEqual(expected_vectors, self.router.vectors)
        self.assertEqual(expected_token, self.router.token)
Ejemplo n.º 4
0
 def get_response(code: str, status_code: int, content: bytes) -> Response:
     r = Response()
     r.code = code
     r.status_code = status_code
     r._content = content
     return r