コード例 #1
0
ファイル: tests.py プロジェクト: katalyzator/voxball
 def test_verify_csrf(self):
     auth_token = self.get_token()
     response = c.post('/api/authe/csrf/verify/', {
         AUTH_TOKEN_HEADER: auth_token,
         'csrf_token': token.generate_csrf('m')
     },
                       HTTP_CSRF_TOKEN=token.generate_csrf('m'))
     self.common_test(response, status_code=STATUS_OK, code=codes.OK)
コード例 #2
0
ファイル: tests.py プロジェクト: katalyzator/voxball
 def test_facebook_login_wrong_token(self):
     response = c.post('/api/authe/facebook_login/',
                       {'access_token': TEST_FB_ACCESS_TOKEN + 'UJ47'},
                       HTTP_CSRF_TOKEN=token.generate_csrf('m'))
     self.common_test(response,
                      status_code=STATUS_OK,
                      code=codes.FB_OAUTH_TOKEN_INVALID)
コード例 #3
0
ファイル: tests.py プロジェクト: katalyzator/voxball
 def test_register_ok_without_full_name(self):
     response = c.post('/api/authe/register/', {
         'email': TEST_USERNAME,
         'password': TEST_PASSWORD
     },
                       HTTP_CSRF_TOKEN=token.generate_csrf('m'))
     self.common_test(response, status_code=STATUS_OK, code=codes.OK)
コード例 #4
0
ファイル: tests.py プロジェクト: katalyzator/voxball
 def test_register_bad_email3(self):
     response = c.post('/api/authe/register/', {
         'email': 'mtemirulan@xcom',
         'password': TEST_PASSWORD
     },
                       HTTP_CSRF_TOKEN=token.generate_csrf('m'))
     self.common_test(response, status_code=STATUS_OK, code=codes.BAD_EMAIL)
コード例 #5
0
ファイル: tests.py プロジェクト: katalyzator/voxball
    def test_create_invalid_dates(self):
        auth_token = self.get_token()

        params = {
            AUTH_TOKEN_HEADER:
            auth_token,
            "title":
            "Test title",
            "poll_type":
            3,
            "date_begin":
            get_timestamp_in_milli(),
            "date_end":
            get_timestamp_in_milli(),
            "sc_choices[]": [
                '{"value":"What is she?", "priority":"1"}',
                '{"value":"What is he?", "priority":"2"}'
            ]
        }
        response = c.post('/api/moderators/template/create/',
                          params,
                          HTTP_CSRF_TOKEN=token.generate_csrf('m'))
        self.common_test(response,
                         status_code=STATUS_OK,
                         code=codes.INVALID_POLL_TYPE)
コード例 #6
0
ファイル: tests.py プロジェクト: katalyzator/voxball
    def test_create_categories_match(self):
        auth_token = self.get_token()

        category, _ = Category.objects.get_or_create(name="soccer")

        params = {
            AUTH_TOKEN_HEADER:
            auth_token,
            "title":
            "Test title",
            "poll_type":
            1,
            "date_begin":
            get_timestamp_in_milli(),
            "date_end":
            get_timestamp_in_milli(),
            "sc_choices[]": [
                '{"value":"What is she?", "priority":"1"}',
                '{"value":"What is he?", "priority":"2"}'
            ],
            "category_ids[]": [category.id, 2]
        }
        response = c.post('/api/moderators/template/create/',
                          params,
                          HTTP_CSRF_TOKEN=token.generate_csrf('m'))
        self.common_test(response,
                         status_code=STATUS_OK,
                         code=codes.CATEGORIES_DOESNT_MATCH)
コード例 #7
0
ファイル: tests.py プロジェクト: katalyzator/voxball
 def test_reset_password_user_not_found(self):
     response = c.post(
         '/api/authe/reset/',
         {'username': '******'},
         HTTP_CSRF_TOKEN=token.generate_csrf('m'))
     self.common_test(response,
                      status_code=STATUS_OK,
                      code=codes.USERNAME_NOT_FOUND)
コード例 #8
0
ファイル: tests.py プロジェクト: katalyzator/voxball
    def test_get_articles_ok(self):
        auth_token = self.get_token()

        params = {AUTH_TOKEN_HEADER: auth_token}
        response = c.post('/api/moderators/articles/get/',
                          params,
                          HTTP_CSRF_TOKEN=token.generate_csrf('m'))
        self.common_test_ok(response)
コード例 #9
0
ファイル: tests.py プロジェクト: katalyzator/voxball
    def test_poll_feed_ok(self):
        auth_token = self.get_token()

        params = {AUTH_TOKEN_HEADER: auth_token}
        response = c.post('/api/moderators/polls/feed/',
                          params,
                          HTTP_CSRF_TOKEN=token.generate_csrf('m'))
        self.common_test_ok(response)
コード例 #10
0
ファイル: tests.py プロジェクト: katalyzator/voxball
    def test_get_polls_by_title_ok(self):
        auth_token = self.get_token()

        params = {AUTH_TOKEN_HEADER: auth_token, "poll_title": "Test title"}
        response = c.post('/api/moderators/polls/get_polls_by_title/',
                          params,
                          HTTP_CSRF_TOKEN=token.generate_csrf('m'))
        self.common_test_ok(response)
コード例 #11
0
ファイル: tests.py プロジェクト: katalyzator/voxball
    def test_reset_password_ok(self):
        user, _ = User.objects.get_or_create(email=TEST_USERNAME)
        user.set_password(TEST_PASSWORD)
        user.is_active = True
        user.save()

        response = c.post('/api/authe/reset/', {'username': TEST_USERNAME},
                          HTTP_CSRF_TOKEN=token.generate_csrf('m'))
        self.common_test(response, status_code=STATUS_OK, code=codes.OK)
コード例 #12
0
ファイル: tests.py プロジェクト: katalyzator/voxball
 def test_login_wrong_username(self):
     response = c.post('/api/authe/login/', {
         'username': TEST_USERNAME,
         'password': TEST_PASSWORD
     },
                       HTTP_CSRF_TOKEN=token.generate_csrf('m'))
     self.common_test(response,
                      status_code=STATUS_OK,
                      code=codes.USERNAME_NOT_FOUND)
コード例 #13
0
ファイル: tests.py プロジェクト: katalyzator/voxball
 def test_sms_user_activate_code_ok(self):
     response = c.post('/api/authe/sms_activate/', {
         'phone': TEST_PHONE,
         'code': CODE
     },
                       HTTP_CSRF_TOKEN=token.generate_csrf('m'))
     self.common_test(response,
                      status_code=STATUS_OK,
                      code=codes.ACTIVATION_CODE_NOT_FOUND)
コード例 #14
0
ファイル: tests.py プロジェクト: katalyzator/voxball
    def test_sms_user_activate_ok(self):
        Activation.objects.generate(username=TEST_PHONE, code=CODE)

        response = c.post('/api/authe/sms_activate/', {
            'phone': TEST_PHONE,
            'code': CODE
        },
                          HTTP_CSRF_TOKEN=token.generate_csrf('m'))
        self.common_test(response, status_code=STATUS_OK, code=codes.OK)
コード例 #15
0
ファイル: tests.py プロジェクト: katalyzator/voxball
    def test_logout_ok(self):
        auth_token = self.get_token()

        response = c.post('/api/authe/logout/', {
            AUTH_TOKEN_HEADER: auth_token,
            'token_string': token
        },
                          HTTP_CSRF_TOKEN=token.generate_csrf('m'))
        self.common_test(response, status_code=STATUS_OK, code=codes.OK)
コード例 #16
0
    def test_feed(self):
        self.get_token()

        params = {
            AUTH_TOKEN_HEADER: self.token,
        }
        response = c.post('/api/polls/feed/', params,
                          HTTP_CSRF_TOKEN=token.generate_csrf('m'))
        self.common_test_ok(response)
コード例 #17
0
ファイル: tests.py プロジェクト: katalyzator/voxball
 def test_register_missing_email(self):
     response = c.post('/api/authe/register/', {
         'full_name': 'Temirulan Mussayev',
         'password': '******'
     },
                       HTTP_CSRF_TOKEN=token.generate_csrf('m'))
     self.common_test(response,
                      status_code=STATUS_OK,
                      code=codes.MISSING_REQUIRED_PARAMS)
コード例 #18
0
 def test_get_article_poll_article_not_found(self):
     self.get_token()
     params = {
         AUTH_TOKEN_HEADER: self.token,
         "article_id": 1
     }
     response = c.post('/api/polls/article/get/', params,
                       HTTP_CSRF_TOKEN=token.generate_csrf('m'))
     self.common_test(response, status_code=STATUS_OK,
                      code=codes.ARTICLE_NOT_FOUND)
コード例 #19
0
    def test_get_random_poll_not_found(self):
        self.get_token()

        params = {
            AUTH_TOKEN_HEADER: self.token,
        }
        response = c.post('/api/polls/get_random_poll/', params,
                          HTTP_CSRF_TOKEN=token.generate_csrf('m'))
        self.common_test(response, status_code=STATUS_OK,
                         code=codes.POLL_NOT_FOUND)
コード例 #20
0
ファイル: tests.py プロジェクト: katalyzator/voxball
    def test_category_delete_ok(self):
        user_info = self.get_token_and_user()

        Category.objects.create(id=1)

        params = {AUTH_TOKEN_HEADER: user_info['token'], 'category_id': 1}
        response = c.post('/api/moderators/category/delete/',
                          params,
                          HTTP_CSRF_TOKEN=token.generate_csrf('m'))
        self.common_test_ok(response)
コード例 #21
0
ファイル: tests.py プロジェクト: katalyzator/voxball
    def test_category_read_not_found(self):
        user_info = self.get_token_and_user()

        params = {AUTH_TOKEN_HEADER: user_info['token'], 'category_id': 1}
        response = c.post('/api/moderators/category/read/',
                          params,
                          HTTP_CSRF_TOKEN=token.generate_csrf('m'))
        self.common_test(response,
                         status_code=STATUS_OK,
                         code=codes.CATEGORY_NOT_FOUND)
コード例 #22
0
ファイル: tests.py プロジェクト: katalyzator/voxball
    def test_update_profile_bad_email3(self):
        auth_token = self.get_token()

        response = c.post('/api/authe/update_profile/', {
            AUTH_TOKEN_HEADER: auth_token,
            'email': 'mtemirulan@xcom',
            'full_name': 'Some Awesome Guy'
        },
                          HTTP_CSRF_TOKEN=token.generate_csrf('m'))
        self.common_test(response, status_code=STATUS_OK, code=codes.BAD_EMAIL)
コード例 #23
0
ファイル: tests.py プロジェクト: katalyzator/voxball
    def test_update_profile_bad_email2(self):
        auth_token = self.get_token()

        response = c.post('/api/authe/update_profile/', {
            AUTH_TOKEN_HEADER: auth_token,
            'email': 'sashachernov4@gmail',
            'full_name': 'Tim'
        },
                          HTTP_CSRF_TOKEN=token.generate_csrf('m'))
        self.common_test(response, status_code=STATUS_OK, code=codes.BAD_EMAIL)
コード例 #24
0
ファイル: tests.py プロジェクト: katalyzator/voxball
 def test_register_wrong_password1(self):
     response = c.post('/api/authe/register/', {
         'email': TEST_EMAIL,
         'full_name': 'Temirulan Mussayev',
         'password': '******'
     },
                       HTTP_CSRF_TOKEN=token.generate_csrf('m'))
     self.common_test(response,
                      status_code=STATUS_OK,
                      code=codes.PASSWORD_LENGTH_ERROR)
コード例 #25
0
 def test_get_article_poll_article_poll_none(self):
     self.get_token()
     article, _ = Article.objects.get_or_create(article_url=TEST_ARTICLE_URL)
     params = {
         AUTH_TOKEN_HEADER: self.token,
         "article_id": article.id
     }
     response = c.post('/api/polls/article/get/', params,
                       HTTP_CSRF_TOKEN=token.generate_csrf('m'))
     self.common_test(response, status_code=STATUS_OK,
                      code=codes.ARTICLE_POLL_NONE)
コード例 #26
0
ファイル: tests.py プロジェクト: katalyzator/voxball
    def test_activate_new_phone_code_not_found(self):
        auth_token = self.get_token()

        response = c.post('/api/authe/profile/activate_new_phone/', {
            AUTH_TOKEN_HEADER: auth_token,
            'code': CODE
        },
                          HTTP_CSRF_TOKEN=token.generate_csrf('m'))
        self.common_test(response,
                         status_code=STATUS_OK,
                         code=codes.ACTIVATION_CODE_NOT_FOUND)
コード例 #27
0
ファイル: tests.py プロジェクト: katalyzator/voxball
    def test_add_delete_category_found_ok(self):
        auth_token = self.get_token()

        response = c.post('/api/authe/profile/category/add_delete/', {
            AUTH_TOKEN_HEADER: auth_token,
            'category_id': '1'
        },
                          HTTP_CSRF_TOKEN=token.generate_csrf('m'))
        self.common_test(response,
                         status_code=STATUS_OK,
                         code=codes.CATEGORY_NOT_FOUND)
コード例 #28
0
ファイル: tests.py プロジェクト: katalyzator/voxball
    def test_update_user_categories_match_ok(self):
        auth_token = self.get_token()

        response = c.post('/api/authe/profile/categories/', {
            AUTH_TOKEN_HEADER: auth_token,
            'category_ids[]': ['1']
        },
                          HTTP_CSRF_TOKEN=token.generate_csrf('m'))
        self.common_test(response,
                         status_code=STATUS_OK,
                         code=codes.CATEGORIES_DOESNT_MATCH)
コード例 #29
0
ファイル: tests.py プロジェクト: katalyzator/voxball
    def test_update_profile_ok(self):
        auth_token = self.get_token()

        response = c.post('/api/authe/update_profile/', {
            AUTH_TOKEN_HEADER: auth_token,
            'email': TEST_EMAIL,
            'full_name': 'Temirulan Mussayev'
        },
                          HTTP_CSRF_TOKEN=token.generate_csrf('m'))

        self.common_test(response, status_code=STATUS_OK, code=codes.OK)
コード例 #30
0
ファイル: tests.py プロジェクト: katalyzator/voxball
    def test_change_password_ok(self):
        auth_token = self.get_token()

        response = c.post('/api/authe/change_password/', {
            AUTH_TOKEN_HEADER: auth_token,
            'current_password': TEST_PASSWORD,
            'new_password': '******'
        },
                          HTTP_CSRF_TOKEN=token.generate_csrf('m'))

        self.common_test(response, status_code=STATUS_OK, code=codes.OK)