Esempio n. 1
0
    def test_fail_if_unauthorized_forbidden(self, mock_get_files, mock_connection):
        mock_connection.return_value = create_mock_connection()
        mock_get_files.return_value = [create_mock_draft_file('foo')]

        with assert_raises(HTTPError) as error:
            fail_if_unauthorized(self.node_settings, self.user.auth, 'bar')
            assert_equal(error.code, http.FORBIDDEN)
Esempio n. 2
0
    def test_fail_if_unauthorized_forbidden(self, mock_get_files, mock_connection):
        mock_connection.return_value = create_mock_connection()
        mock_get_files.return_value = [create_mock_draft_file('foo')]

        with assert_raises(HTTPError) as error:
            fail_if_unauthorized(self.node_settings, self.user.auth, 'bar')
            assert_equal(error.code, http.FORBIDDEN)
Esempio n. 3
0
 def test_fail_if_unauthorized_unauthorized(self, mock_get_files,
                                            mock_connection):
     with assert_raises(HTTPError) as error:
         user2 = AuthUserFactory()
         fail_if_unauthorized(self.node_settings, Auth(user2), 'draft')
         assert_equal(error.code, http.UNAUTHORIZED)
Esempio n. 4
0
    def test_fail_if_unauthorized_not_found(self):

        with assert_raises(HTTPError) as error:
            fail_if_unauthorized(self.node_settings, self.user.auth, None)
            assert_equal(error.code, http.NOT_FOUND)
Esempio n. 5
0
 def test_fail_if_unauthorized_unauthorized(self, mock_get_files, mock_connection):
     with assert_raises(HTTPError) as error:
         user2 = AuthUserFactory()
         fail_if_unauthorized(self.node_settings, Auth(user2), 'draft')
         assert_equal(error.code, http.UNAUTHORIZED)
Esempio n. 6
0
    def test_fail_if_unauthorized_not_found(self):

        with assert_raises(HTTPError) as error:
            fail_if_unauthorized(self.node_settings, self.user.auth, None)
            assert_equal(error.code, http.NOT_FOUND)