Exemplo n.º 1
0
    def test_success_download_private_by_owner(self):
        """
        Download private file by owner with all valid params.
        """
        files.update().where(
            files.c.hash == self.data_hash).values(role='020').execute()
        response = self.make_request()

        self.assertEqual(200, response.status_code,
                         "'OK' status code is expected.")
        self.assertEqual('application/octet-stream', response.content_type,
                         "Has to be an octet-stream.")

        self.assertEqual(response.data, self.file_data,
                         "Stored file content is expected.")
Exemplo n.º 2
0
    def test_private_by_other(self):
        """
        Try to download private file by other.
        """
        files.update().where(
            files.c.hash == self.data_hash).values(role='020').execute()
        response = self.make_request(False)

        self.assertEqual(404, response.status_code,
                         "'Not Found' status code is expected.")
        self.assertEqual('application/json', response.content_type,
                         "Has to be a JSON.")

        self.assertDictEqual({'error_code': ERR_TRANSFER['NOT_FOUND']},
                             json.loads(response.data.decode()),
                             "Unexpected response data.")
Exemplo n.º 3
0
    def test_success_getting_private_by_owner(self):
        """
        Download private served file by owner with all valid params.
        """
        files.update().where(
            files.c.hash == self.data_hash
        ).values(role='021').execute()

        response = self.make_request()

        self.assertEqual(200, response.status_code,
                         "'OK' status code is expected.")
        self.assertEqual('application/octet-stream', response.content_type,
                         "Has to be an octet-stream.")
        self.assertEqual(self.query_string['file_alias'],
                         response.headers['X-Sendfile'],
                         "File has to have selected named.")

        self.assertEqual(response.data, self.file_data,
                         "Stored file content is expected.")
Exemplo n.º 4
0
    def test_success_audit_private_by_owner(self):
        """
        Audit private file by owner with all valid data.
        """
        files.update().where(
            files.c.hash == self.data_hash
        ).values(role='020').execute()

        response = self.make_request()

        self.assertEqual(201, response.status_code,
                         "'Created' status code is expected.")
        self.assertEqual('application/json', response.content_type,
                         "Has to be a JSON-response.")

        self.assertDictEqual(
            {
                'data_hash': self.send_data['data_hash'],
                'challenge_seed': self.send_data['challenge_seed'],
                'challenge_response': self.challenge_response
            },
            json.loads(response.data.decode()),
            "Unexpected response data."
        )