Exemple #1
0
    def test_login_view_and_template(self):
        response = self.client.get(reverse('login'))
        self.assertTemplateUsed(response, 'registration/login.html')
        self.assertEqual(response.resolver_match.func.__name__,
                         LoginView.as_view().__name__)

        response = self.client.post(reverse('login'), {
            'username': username,
            'password': password
        })
        self.assertEqual(response.resolver_match.func.__name__,
                         LoginView.as_view().__name__)
    def test_successfully_invited(self):
        self.client.logout()
        response = self.client.get(reverse('invite_users:successfully_invited'), follow=True)
        self.assertContains(response, "Please login to see this page.")
        self.assertEqual(response.resolver_match.func.__name__, LoginView.as_view().__name__)

        self.client.force_login(self.user)
        response = self.client.get(reverse('invite_users:successfully_invited'))
        self.assertContains(response, "You didn't even invite anyone.")
        self.assertTemplateUsed(response, 'invite_users/successfully_invited.html')
        self.assertEqual(response.resolver_match.func.__name__, SuccessView.as_view().__name__)
        self.assertEqual(response.status_code, 200)

        response = self.client.get(reverse('invite_users:invite_users'))
        emails = ['*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**',
                  '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**']
        form_data = {
            'form-TOTAL_FORMS': '11',
            'form-INITIAL_FORMS': '0',
            'form-MIN_NUM_FORMS': '1',
            'form-MAX_NUM_FORMS': '15',
            'additional_message': '',
        }
        for i in range(len(emails)):
            form_data['form-{}-email'.format(i)] = emails[i]
        response = self.client.post(reverse('invite_users:invite_users'), form_data, follow=True)
        self.assertTemplateUsed(response, 'invite_users/successfully_invited.html')
        self.assertContains(response, "You successfully invited")
        for email in emails:
            self.assertContains(response, email)
def redirect_to_login_with_expected_message(self, resolved_address, response,
                                            expected_message):
    self.assertEqual(response.status_code, 302)
    self.assertEqual(response['location'], '/login/?next=' + resolved_address)
    response = self.client.get(response['location'])
    # verify the login-required mixin
    self.assertEqual(response.resolver_match.func.__name__,
                     LoginView.as_view().__name__)
    self.assertContains(response, expected_message)
 def test_redirect_to_login_and_login_required(self):
     self.client.logout()
     response = self.client.get(reverse('invite_users:invite_users'))
     self.assertEqual(response.status_code, 302)
     self.assertEqual(response['location'], '/login/?next=' + reverse('invite_users:invite_users'))
     response = self.client.get(response['location'])
     # verify the login-required mixin
     self.assertEqual(response.resolver_match.func.__name__, LoginView.as_view().__name__)
     self.assertContains(response, 'Please login to see this page.')
Exemple #5
0
 def test_redirect_to_login_and_login_required(self):
     response = self.client.get(
         reverse('user_profile:user_profile_page',
                 kwargs={"username": user_name}))
     self.assertEqual(response.status_code, 302)
     self.assertEqual(
         response['location'],
         '/login/?next=' + reverse('user_profile:user_profile_page',
                                   kwargs={"username": user_name}))
     response = self.client.get(response['location'])
     self.assertEqual(response.resolver_match.func.__name__,
                      LoginView.as_view().__name__)
     self.assertContains(response, 'Please login to see this page.')
Exemple #6
0
def redirect_to_login_and_login_required(self, address_pattern, address_kwargs=None, get_kwargs=None,
                                         alternate_error_message=None):
    resolved_address = reverse(address_pattern, kwargs=address_kwargs)
    if get_kwargs:
        response = self.client.get(resolved_address, get_kwargs)
    else:
        response = self.client.get(resolved_address)
    self.assertEqual(response.status_code, 302)
    self.assertEqual(response['location'], '/login/?next=' + resolved_address)
    response = self.client.get(response['location'])
    # verify the login-required mixin
    self.assertEqual(response.resolver_match.func.__name__, LoginView.as_view().__name__)
    if alternate_error_message:
        self.assertContains(response, alternate_error_message)
    else:
        self.assertContains(response, 'Please login to see this page.')
Exemple #7
0
from django.conf.urls import patterns, include, url

from django.contrib import admin
from user_management.views import LoginView

admin.autodiscover()

urlpatterns = patterns('',
                       url(r'^admin/', include(admin.site.urls)),
                       url(r'^(?i)dashboard/$', include('dashboard.urls', namespace='dashboard')),
                       url(r'^(?i)user/', include('user_management.urls', namespace='user')),
                       url(r'^(?i)grant/', include('start_grant.urls', namespace='grant')),
                       url(r'^(?i)core/', include('core_connection.urls', namespace='core')),
                       url(r'^(?i)customer/', include('customer.urls', namespace='customer')),
                       url(r'^(?i)config/', include('rose_config.urls', namespace='config')),
                       url(r'^(?i)guarantor/', include('guarantor.urls', namespace='guarantor')),
                       url(r'^(?i)assign/', include('assign.urls', namespace='assign')),
                       url(r'^(?i)notification/', include('notification.urls', namespace='notification')),
                       url(r'^(?i)superior/', include('superior.urls', namespace='superior')),

                       url(r'^$', LoginView.as_view()),
)


Exemple #8
0
from django.conf.urls import url
from user_management.views import RegisterView, LoginView, ProfileView, AddFriendView, FriendListView, log_out_view
urlpatterns = [
    url(r'^register/$', RegisterView.as_view(), name='register'),
    url(r'^login/$', LoginView.as_view(), name='login'),
    url(r'^logout/$', log_out_view, name='logout'),
    url(r'^profile/$', ProfileView.as_view(), name='profile'),
    url(r'^add-friend/$', AddFriendView.as_view(), name='add-friend'),
    url(r'^friends/$', FriendListView.as_view(), name='friends')
]
Exemple #9
0
    def test_redirect_to_login_and_login_required(self):
        self.client.logout()
        # create
        response = self.client.get(
            reverse('issue:create',
                    kwargs={'project': self.project.name_short}))
        self.assertEqual(response.status_code, 302)
        self.assertEqual(
            response['location'], '/login/?next=' + reverse(
                'issue:create', kwargs={'project': self.project.name_short}))
        response = self.client.get(response['location'])
        # verify the login-required mixin
        self.assertEqual(response.resolver_match.func.__name__,
                         LoginView.as_view().__name__)
        self.assertContains(response, 'Please login to see this page.')

        # create issue for edit and detail tests
        issue = Issue(title="foo")
        issue.project = self.project
        issue.save()
        number = issue.number

        # edit
        response = self.client.get(
            reverse('issue:edit',
                    kwargs={
                        'project': self.project.name_short,
                        'sqn_i': number
                    }))
        self.assertEqual(response.status_code, 302)
        self.assertEqual(
            response['location'],
            '/login/?next=' + reverse('issue:edit',
                                      kwargs={
                                          'project': self.project.name_short,
                                          'sqn_i': number
                                      }))
        response = self.client.get(response['location'])
        # verify the login-required mixin
        self.assertEqual(response.resolver_match.func.__name__,
                         LoginView.as_view().__name__)
        self.assertContains(response, 'Please login to see this page.')

        # detail
        response = self.client.get(
            reverse('issue:detail',
                    kwargs={
                        'project': self.project.name_short,
                        'sqn_i': number
                    }))
        self.assertEqual(response.status_code, 302)
        self.assertEqual(
            response['location'],
            '/login/?next=' + reverse('issue:detail',
                                      kwargs={
                                          'project': self.project.name_short,
                                          'sqn_i': number
                                      }))
        response = self.client.get(response['location'])
        # verify the login-required mixin
        self.assertEqual(response.resolver_match.func.__name__,
                         LoginView.as_view().__name__)
        self.assertContains(response, 'Please login to see this page.')
        pass
"""
    file: user_management/urls
    purpose: Router for account's APIs
"""

from django.urls import path, include

from rest_framework.routers import DefaultRouter

from user_management.views import UserViewSet, UserRoleSet, LoginView

router = DefaultRouter()
router.register(r'users', UserViewSet)
router.register(r'roles', UserRoleSet)

urlpatterns = [
    path('', include(router.urls)),
    path('token/', LoginView.as_view(), name='get_token'),
]
from django.contrib import admin
from django.urls import path, include
from user_management.views import LoginView, LogoutView

urlpatterns = [
    path('login/', LoginView.as_view(), name='login'),
    path('logout/', LogoutView.as_view(), name='logout'),
    path('', admin.site.urls),
    path('api/v1/', include('api.urls'))
]
Exemple #12
0
from django.conf.urls import patterns, include, url

from django.contrib import admin
from user_management.views import LoginView

admin.autodiscover()

urlpatterns = patterns(
    '',
    url(r'^admin/', include(admin.site.urls)),
    url(r'^(?i)dashboard/$', include('dashboard.urls', namespace='dashboard')),
    url(r'^(?i)user/', include('user_management.urls', namespace='user')),
    url(r'^(?i)grant/', include('start_grant.urls', namespace='grant')),
    url(r'^(?i)core/', include('core_connection.urls', namespace='core')),
    url(r'^(?i)customer/', include('customer.urls', namespace='customer')),
    url(r'^(?i)config/', include('rose_config.urls', namespace='config')),
    url(r'^(?i)guarantor/', include('guarantor.urls', namespace='guarantor')),
    url(r'^(?i)assign/', include('assign.urls', namespace='assign')),
    url(r'^(?i)notification/',
        include('notification.urls', namespace='notification')),
    url(r'^(?i)superior/', include('superior.urls', namespace='superior')),
    url(r'^$', LoginView.as_view()),
)
Exemple #13
0
"""shano_sound URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/1.10/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  url(r'^$', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  url(r'^$', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.conf.urls import url, include
    2. Add a URL to urlpatterns:  url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import url, include
from django.contrib import admin
from user_management.views import LoginView


urlpatterns = [
    url(r'index/$', LoginView.as_view(), name='index'),
    url(r'', include('library_management.urls')),
    url(r'', include('user_management.urls')),
    url(r'^admin/', admin.site.urls),
    url(r'', include('user_management.urls')),
    url(r'', include('chat.urls')),
]