<commit_before># Copyright (c) 2008 Participatory Culture Foundation
# See LICENSE for details.

import os

from django.conf import settings
from django.http import HttpRequest

from channelguide import db, util
from channelguide.guide import tables
from channelguide.guide.auth import login, logout, SESSION_KEY
from channelguide.guide.models import (Channel, UserAuthToken, User,
        ModeratorAction)
from channelguide.testframework import TestCase

class AuthTest(TestCase):
    def setUp(self):
        TestCase.setUp(self)
        self.user = self.make_user('joe', 'password')

    def check_password(self):
        self.assert_(self.user.check_password('password'))
        self.assert_(not self.user.check_password('<PASSWORD>'))

    def test_middleware_cookie(self):
        request = self.process_request()
        login(request, self.user)
        response = self.process_response(request)
        request = self.process_request(cookies_from=response.cookies)
        self.assert_(request.user.is_authenticated())
        self.assertEquals(request.user.username, 'joe')
        logout(request)
        response = self.process_response(request)
        request = self.process_request(cookies_from=response.cookies)
        self.assert_(not request.user.is_authenticated())
        self.process_response(request)

    def test_middleware_basic(self):
        request = HttpRequest()
        request.META['HTTP_AUTHORIZATION'] = 'basic %s' % 'joe:password'.encode(
            'base64')
        self.process_request(request=request)
        self.assert_(request.user.is_authenticated())
        self.assertEquals(request.user.username, 'joe')
        
    def test_corrupt_cookie(self):
        request = self.process_request(cookies_from={SESSION_KEY:'corrupt'})
        self.assert_(not request.user.is_authenticated())
        self.process_response(request)<commit_msg>take out test for basic authentication<commit_after># Copyright (c) 2008 Participatory Culture Foundation
# See LICENSE for details.

import os

from django.conf import settings
from django.http import HttpRequest

from channelguide import db, util
from channelguide.guide import tables
from channelguide.guide.auth import login, logout, SESSION_KEY
from channelguide.guide.models import (Channel, UserAuthToken, User,
        ModeratorAction)
from channelguide.testframework import TestCase

class AuthTest(TestCase):
    def setUp(self):
        TestCase.setUp(self)
        self.user = self.make_user('joe', 'password')

    def check_password(self):
        self.assert_(self.user.check_password('password'))
        self.assert_(not self.user.check_password('<PASSWORD>'))

    def test_middleware(self):
        request = self.process_request()
        login(request, self.user)
        response = self.process_response(request)
        request = self.process_request(cookies_from=response.cookies)
        self.assert_(request.user.is_authenticated())
        self.assertEquals(request.user.username, 'joe')
        logout(request)
        response = self.process_response(request)
        request = self.process_request(cookies_from=response.cookies)
        self.assert_(not request.user.is_authenticated())
        self.process_response(request)
        
    def test_corrupt_cookie(self):
        request = self.process_request(cookies_from={SESSION_KEY:'corrupt'})
        self.assert_(not request.user.is_authenticated())
        self.process_response(request)
{'fraction_non_alphanumeric': 0.09748336708128436, 'fraction_numerical': 0.0028926815157651145, 'mean_word_length': 3.763085399449036, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6937506', 'n_tokens_mistral': 990, 'n_tokens_neox': 949, 'n_words': 193}