Uname:Linux mail.sarafai.ru 6.1.0-43-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.162-1 (2026-02-08) x86_64

403WebShell
403Webshell
Server IP : 82.148.16.210  /  Your IP : 216.73.216.19
Web Server : nginx/1.29.5
System : Linux mail.sarafai.ru 6.1.0-43-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.162-1 (2026-02-08) x86_64
User : root ( 0)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /proc/636025/cwd/project/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/636025/cwd/project/tests.py
from random import randrange
from unittest import TestCase

from django.contrib.auth import get_user_model
from django.test import Client, SimpleTestCase
from django.urls import reverse, resolve
from django.views.generic import RedirectView

from project import settings


class TestLoginView(SimpleTestCase):
    databases = '__all__'

    def setUp(self):
        self.client = Client()
        self.username = "test%s@test.com" % randrange(1000, 9999)
        self.password = "password"
        self.user = get_user_model().objects.create_user(username=self.username,
                                                         email=self.username,
                                                         password=self.password)
        # EmailAddress.objects.create(user=user, email=self.username, primary=True, verified=True)

    def test_login(self):
        response = self.client.post(
                reverse(settings.LOGIN_URL),
                {
                    "login": self.username,
                    "password": self.password
                }
        )
        self.assertRedirects(response,
                             settings.LOGIN_REDIRECT_URL,
                             fetch_redirect_response=False)

    def test_wrong_login(self):
        response = self.client.post(
                reverse(settings.LOGIN_URL),
                {
                    "login": "bad@login.com",
                    "password": "wrong"
                }
        )
        #validation_error = 'The e-mail address and/or password you specified are not correct'
        validation_error = 'E-mail адрес и/или пароль не верны.'
        assert validation_error in response.content.decode('utf-8')

    def test_redirect_when_authenticated(self):
        self.client.force_login(self.user)
        resp = self.client.get(reverse(settings.LOGIN_URL))
        #url = settings.LOGIN_REDIRECT_URL + '/' + self.username + '/' + 'detail'
        url = settings.LOGIN_REDIRECT_URL
        self.assertRedirects(resp, url, fetch_redirect_response=False)



    # path('favicon.ico', RedirectView.as_view(url=settings.STATIC_URL + 'favicons/favicon.ico'), name='favicon_ico'),
    def test_url_favicon_ico(self):
        url = reverse('favicon_ico')
        self.assertEquals(resolve(url).func.view_class, RedirectView)

    # path('robots.txt', lambda r: HttpResponse("User-agent: *\n"
    #                                           "Disallow: /\n\n"
    #                                           "Host: https://zhriza.ru\n",
    #                                           content_type="text/plain")),
    def test_url_robots_txt(self):
        response = self.client.get(reverse('robots_txt'))
        #self.assertEquals(resolve(url).func.view_class, BlogPostPageView)
        self.assertEqual(response.status_code, 200)


Youez - 2016 - github.com/yon3zu
LinuXploit