52 |
52 |
return obj
|
53 |
53 |
|
54 |
54 |
|
55 |
|
def test_api_access_new(pub):
|
56 |
|
create_superuser(pub)
|
57 |
|
ApiAccess.wipe()
|
58 |
|
app = login(get_app(pub))
|
59 |
|
|
60 |
|
# go to the page and cancel
|
61 |
|
resp = app.get('/backoffice/settings/api-access/')
|
62 |
|
resp = resp.click('New API access')
|
63 |
|
resp = resp.forms[0].submit('cancel')
|
64 |
|
assert resp.location == 'http://example.net/backoffice/settings/api-access/'
|
65 |
|
|
66 |
|
# go to the page and add an API access
|
67 |
|
resp = app.get('/backoffice/settings/api-access/')
|
68 |
|
resp = resp.click('New API access')
|
69 |
|
resp.form['name'] = 'a new API access'
|
70 |
|
resp.form['description'] = 'description'
|
71 |
|
resp.form['access_identifier'] = 'new_access'
|
72 |
|
assert len(resp.form['access_key'].value) == 36
|
73 |
|
resp = resp.form.submit('submit')
|
74 |
|
assert resp.location == 'http://example.net/backoffice/settings/api-access/'
|
75 |
|
resp = resp.follow()
|
76 |
|
assert 'a new API access' in resp.text
|
77 |
|
resp = resp.click('a new API access')
|
78 |
|
assert 'API access - a new API access' in resp.text
|
79 |
|
|
80 |
|
# check name unicity
|
81 |
|
resp = app.get('/backoffice/settings/api-access/new')
|
82 |
|
resp.form['name'] = 'a new API access'
|
83 |
|
resp.form['access_identifier'] = 'changed'
|
84 |
|
resp = resp.form.submit('submit')
|
85 |
|
assert resp.html.find('div', {'class': 'error'}).text == 'This name is already used.'
|
86 |
|
|
87 |
|
# check access_identifier unicity
|
88 |
|
resp.form['name'] = 'new one'
|
89 |
|
resp.form['access_identifier'] = 'new_access'
|
90 |
|
resp = resp.form.submit('submit')
|
91 |
|
assert resp.html.find('div', {'class': 'error'}).text == 'This value is already used.'
|
92 |
|
|
93 |
|
|
94 |
55 |
def test_api_access_view(pub, api_access):
|
95 |
56 |
create_superuser(pub)
|
96 |
57 |
|