From 35cb450f1f59428e8c4c943c51a278415a4a3543 Mon Sep 17 00:00:00 2001 From: Evert Date: Mon, 11 Dec 2017 15:37:15 +0200 Subject: [PATCH] Revert the tests commit --- tests/LandingPage/test_views.py | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/tests/LandingPage/test_views.py b/tests/LandingPage/test_views.py index 76de993..998dbdc 100644 --- a/tests/LandingPage/test_views.py +++ b/tests/LandingPage/test_views.py @@ -1,8 +1,7 @@ from django.test import TestCase,Client,override_settings import responses -from LandingPage.models import ExternalUser +from LandingPage.models import User from urllib import parse -from django.contrib.auth import get_user_model @override_settings( AUTH_TOKEN_ENDPOINT='http://icynet.test/api/', @@ -16,7 +15,7 @@ class TestLogin(TestCase): # Set up responses to control network flow with responses.RequestsMock() as rm: rm.add(responses.POST,'http://icynet.test/api/token',json={'access_token':'1accesstoken1'}) - rm.add(responses.GET,'http://icynet.test/api/user',json={'uuid':'935a41b5-b38d-42c3-96ef-653402fc44ca','email':'johnsmith@gmail.com','display_name':'Mr. Smith','username':'mrsmith'}) + rm.add(responses.GET,'http://icynet.test/api/user',json={'uuid':'935a41b5-b38d-42c3-96ef-653402fc44ca','email':'johnsmith@gmail.com','display_name':'Mr. Smith','username':'jsmith'}) # Make initial request to redirect endpoint client = Client() @@ -27,23 +26,19 @@ class TestLogin(TestCase): self.assertEqual(query['client_id'][0],'clid') self.assertEqual(query['response_type'][0],'code') self.assertEqual(query['redirect_uri'][0],'http://redirect.test') - self.assertSetEqual(set(query['scope'][0].split()),set(['email','privilege'])) + self.assertEqual(query['scope'][0],'email privilege') # Make connection to the real endpoint resp = client.get('/login/redirect?state=%s&code=%s'%(state, 'code')) self.assertEqual(resp.status_code, 302) # Check that the database is all good - users = ExternalUser.objects.all() + users = User.objects.all() self.assertEqual(len(users), 1) user = users[0] self.assertEqual(user.icy_id,'935a41b5-b38d-42c3-96ef-653402fc44ca') - self.assertEqual(user.user.email,'johnsmith@gmail.com') - self.assertEqual(user.user.username,'mrsmith') + self.assertEqual(user.email,'johnsmith@gmail.com') self.assertEqual(user.display_name, 'Mr. Smith') - - # Check that the user has been logged in - self.assertEqual(client.get('/').context['user'], user.user) def test_reject_bad_state(self): with responses.RequestsMock() as rm: @@ -55,10 +50,10 @@ class TestLogin(TestCase): # Set up responses to control network flow with responses.RequestsMock() as rm: rm.add(responses.POST,'http://icynet.test/api/token',json={'access_token':'1accesstoken1'}) - rm.add(responses.GET,'http://icynet.test/api/user',json={'uuid':'935a41b5-b38d-42c3-96ef-653402fc44ca','email':'johnsmith@gmail.com','display_name':'Mr. Smith'}) + rm.add(responses.GET,'http://icynet.test/api/user',json={'uuid':'935a41b5-b38d-42c3-96ef-653402fc44ca','email':'johnsmith@gmail.com','display_name':'Mr. Smith','username':'jsmith'}) # Set up the database - user = ExternalUser(user=get_user_model().objects.create_user(username='mrsmith',email='johnsmith@gmail.com'),icy_id='935a41b5-b38d-42c3-96ef-653402fc44ca',display_name='Mr. Smith') + user = User(icy_id='935a41b5-b38d-42c3-96ef-653402fc44ca',email='johnsmith@gmail.com',display_name='Mr. Smith') user.save() # Make initial request to redirect endpoint @@ -71,15 +66,12 @@ class TestLogin(TestCase): self.assertEqual(resp.status_code, 302) # Check that the database is all good - users = ExternalUser.objects.all() + users = User.objects.all() self.assertEqual(len(users), 1) user = users[0] self.assertEqual(user.icy_id,'935a41b5-b38d-42c3-96ef-653402fc44ca') - self.assertEqual(user.user.email,'johnsmith@gmail.com') + self.assertEqual(user.email,'johnsmith@gmail.com') self.assertEqual(user.display_name, 'Mr. Smith') - - # Check that the user has been logged in - self.assertEqual(client.get('/').context['user'], user.user) def test_states_unique(self): with responses.RequestsMock() as rm: