コード例 #1
0
    def login(self, username='******', password='******'):
        leap_session = self._test_account.leap_session
        user_auth = mock()
        user_auth.uuid = 'some_user_uuid'
        leap_session.user_auth = user_auth
        config = mock()
        config.leap_home = 'some_folder'
        leap_session.config = config
        leap_session.fresh_account = False
        self.leap_session = leap_session
        self.services = self._test_account.services

        self._set_leap_srp_auth(username, password, user_auth)
        when(LeapSessionFactory).create(username, password,
                                        user_auth).thenReturn(leap_session)
        when(leap_session).initial_sync().thenAnswer(
            lambda: defer.succeed(None))
        when(pixelated.config.services).Services(ANY()).thenReturn(
            self.services)

        request = request_mock(path='/login',
                               method="POST",
                               body={
                                   'username': username,
                                   'password': password
                               })
        return self._render(request, as_json=False)
コード例 #2
0
 def get(self, path, get_args='', as_json=True, from_request=None):
     request = request_mock(path)
     request.args = get_args
     if from_request:
         session = from_request.getSession()
         request.session = session
     return self._render(request, as_json)
コード例 #3
0
 def get(self, path, get_args='', as_json=True, from_request=None):
     request = request_mock(path)
     request.args = get_args
     if from_request:
         session = from_request.getSession()
         request.session = session
     return self._render(request, as_json)
コード例 #4
0
    def post(self, path, body='', headers=None, ajax=True, csrf='token', as_json=True, from_request=None):
        headers = headers or {'Content-Type': 'application/json'}
        request = request_mock(path=path, method="POST", body=body, headers=headers, ajax=ajax, csrf=csrf)

        if from_request:
            session = from_request.getSession()
            request.session = session
        return self._render(request, as_json)
コード例 #5
0
    def post(self, path, body='', headers=None, ajax=True, csrf='token', as_json=True, from_request=None):
        headers = headers or {'Content-Type': 'application/json'}
        request = request_mock(path=path, method="POST", body=body, headers=headers, ajax=ajax, csrf=csrf)

        if from_request:
            session = from_request.getSession()
            request.session = session
        return self._render(request, as_json)
コード例 #6
0
 def delete(self, path, body="", ajax=True, csrf='token'):
     request = request_mock(path=path,
                            body=body,
                            headers={'Content-Type': ['application/json']},
                            method="DELETE",
                            ajax=ajax,
                            csrf=csrf)
     return self._render(request)
コード例 #7
0
 def post(self, path, body='', headers=None, ajax=True, csrf='token'):
     headers = headers or {'Content-Type': 'application/json'}
     request = request_mock(path=path,
                            method="POST",
                            body=body,
                            headers=headers,
                            ajax=ajax,
                            csrf=csrf)
     return self._render(request)
コード例 #8
0
    def login(self, username="******", password="******"):
        leap_session = mock(LeapSession)
        user_auth = mock()
        user_auth.uuid = "some_user_uuid"
        leap_session.user_auth = user_auth
        config = mock()
        config.leap_home = "some_folder"
        leap_session.config = config
        leap_session.fresh_account = False

        self._set_leap_srp_auth(username, password)
        when(leap_session).initial_sync().thenAnswer(lambda: defer.succeed(None))
        when(LeapSessionFactory).create(username, password).thenReturn(leap_session)
        when(pixelated.config.services).Services(ANY()).thenReturn(self._test_account.services)

        request = request_mock(path="/login", method="POST", body={"username": username, "password": password})
        return self._render(request, as_json=False)
コード例 #9
0
    def login(self, username='******', password='******'):
        leap_session = self._test_account.leap_session
        user_auth = mock()
        user_auth.uuid = 'some_user_uuid'
        leap_session.user_auth = user_auth
        config = mock()
        config.leap_home = 'some_folder'
        leap_session.config = config
        leap_session.fresh_account = False
        self.leap_session = leap_session
        self.services = self._test_account.services

        self._set_leap_srp_auth(username, password, user_auth)
        when(LeapSessionFactory).create(username, password, user_auth).thenReturn(leap_session)
        when(leap_session).initial_sync().thenAnswer(lambda: defer.succeed(None))
        when(pixelated.config.services).Services(ANY()).thenReturn(self.services)

        request = request_mock(path='/login', method="POST", body={'username': username, 'password': password})
        return self._render(request, as_json=False)
コード例 #10
0
 def post(self, path, body="", headers=None, ajax=True, csrf="token"):
     headers = headers or {"Content-Type": "application/json"}
     request = request_mock(path=path, method="POST", body=body, headers=headers, ajax=ajax, csrf=csrf)
     return self._render(request)
コード例 #11
0
 def get(self, path, get_args="", as_json=True, ajax=True, csrf="token"):
     request = request_mock(path, ajax=ajax, csrf=csrf)
     request.args = get_args
     return self._render(request, as_json)
コード例 #12
0
 def delete(self, path, body=""):
     request = request_mock(path=path, body=body, headers={"Content-Type": ["application/json"]}, method="DELETE")
     return self._render(request)
コード例 #13
0
 def put(self, path, body):
     request = request_mock(path=path, method="PUT", body=body, headers={"Content-Type": ["application/json"]})
     return self._render(request)
コード例 #14
0
 def get(self, path, get_args="", as_json=True):
     request = request_mock(path)
     request.args = get_args
     return self._render(request, as_json)
コード例 #15
0
 def post(self, path, body='', headers=None):
     headers = headers or {'Content-Type': 'application/json'}
     request = request_mock(path=path, method="POST", body=body, headers=headers)
     return self._render(request)
コード例 #16
0
 def get(self, path, get_args='', as_json=True, ajax=True, csrf='token'):
     request = request_mock(path, ajax=ajax, csrf=csrf)
     request.args = get_args
     return self._render(request, as_json)
コード例 #17
0
 def put(self, path, body):
     request = request_mock(path=path,
                            method="PUT",
                            body=body,
                            headers={'Content-Type': ['application/json']})
     return self._render(request)
コード例 #18
0
 def get(self, path, get_args='', as_json=True):
     request = request_mock(path)
     request.args = get_args
     return self._render(request, as_json)
コード例 #19
0
 def post(self, path, body=''):
     request = request_mock(path=path, method="POST", body=body, headers={'Content-Type': ['application/json']})
     return self._render(request)
コード例 #20
0
 def setUp(self):
     self.dummy_request = request_mock()
     self.controller = SyncInfoResource()
コード例 #21
0
 def put(self, path, body, ajax=True, csrf='token'):
     request = request_mock(path=path, method="PUT", body=body, headers={'Content-Type': ['application/json']}, ajax=ajax, csrf=csrf)
     return self._render(request)
コード例 #22
0
 def post(self, path, body='', headers=None, ajax=True, csrf='token'):
     headers = headers or {'Content-Type': 'application/json'}
     request = request_mock(path=path, method="POST", body=body, headers=headers, ajax=ajax, csrf=csrf)
     return self._render(request)
コード例 #23
0
 def delete(self, path, body="", ajax=True, csrf="token"):
     request = request_mock(
         path=path, body=body, headers={"Content-Type": ["application/json"]}, method="DELETE", ajax=ajax, csrf=csrf
     )
     return self._render(request)
コード例 #24
0
 def setUp(self):
     self.dummy_request = request_mock()
     self.controller = SyncInfoResource()
コード例 #25
0
 def delete(self, path, body=""):
     request = request_mock(path=path,
                            body=body,
                            headers={'Content-Type': ['application/json']},
                            method="DELETE")
     return self._render(request)