-
Notifications
You must be signed in to change notification settings - Fork 15
/
test_quickstart_resourceserver.py
28 lines (22 loc) · 1.23 KB
/
test_quickstart_resourceserver.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from bottle import tob
from .bottle_tools import ServerTestBase
from tests.examples import quickstart_resourceserver
class test_quickstart(ServerTestBase):
def setUp(self):
import importlib
importlib.reload(quickstart_resourceserver)
super().setUp(quickstart_resourceserver.app)
def test_no_token(self):
resp = self.urlopen("/mail")
self.assertEqual(403, resp['code'], resp['body'])
def test_access_mail_granted(self):
resp = self.urlopen("/mail", env={'HTTP_AUTHORIZATION': "Bearer sample_token"})
self.assertEqual(200, resp['code'], resp['body'])
self.assertEqual(tob("Welcome john, you have permissioned clientA to use your mail"), resp['body'])
def test_access_mail_and_calendar_granted(self):
resp = self.urlopen("/mail_and_calendar", env={'HTTP_AUTHORIZATION': "Bearer sample_token"})
self.assertEqual(200, resp['code'], resp['body'])
self.assertEqual(tob("Welcome john, you have permissioned clientA to use your mail & calendar"), resp['body'])
def test_access_photos_not_granted(self):
resp = self.urlopen("/photos", env={'HTTP_AUTHORIZATION': "Bearer sample_token"})
self.assertEqual(403, resp['code'], resp['body'])