-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #74 from libris/feature/add-oauth-client
Feature/add oauth client
- Loading branch information
Showing
18 changed files
with
1,101 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ msgid "" | |
msgstr "" | ||
"Project-Id-Version: xl_auth 0.4.4\n" | ||
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" | ||
"POT-Creation-Date: 2017-10-25 13:18+0200\n" | ||
"POT-Creation-Date: 2017-10-25 14:02+0200\n" | ||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" | ||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | ||
"Language-Team: LANGUAGE <[email protected]>\n" | ||
|
@@ -29,7 +29,8 @@ msgstr "" | |
#: tests/end2end/test_deleting_permission.py:26 tests/end2end/test_editing_collection.py:158 | ||
#: tests/end2end/test_editing_permission.py:31 tests/end2end/test_editing_permission.py:66 | ||
#: tests/end2end/test_editing_user.py:189 tests/end2end/test_editing_user.py:215 | ||
#: xl_auth/templates/collections/home.html:42 xl_auth/templates/permissions/home.html:37 | ||
#: xl_auth/templates/clients/home.html:35 xl_auth/templates/collections/home.html:42 | ||
#: xl_auth/templates/permissions/home.html:37 | ||
msgid "Edit" | ||
msgstr "" | ||
|
||
|
@@ -42,6 +43,49 @@ msgstr "" | |
msgid "Successfully deleted permissions for \"%(username)s\" on collection \"%(code)s\"." | ||
msgstr "" | ||
|
||
#: tests/end2end/test_editing_client.py:82 tests/end2end/test_editing_client.py:115 | ||
#: tests/end2end/test_editing_collection.py:102 tests/end2end/test_registering_collection.py:102 | ||
#: xl_auth/client/forms.py:14 xl_auth/collection/forms.py:18 xl_auth/templates/clients/home.html:17 | ||
#: xl_auth/templates/users/home.html:18 xl_auth/templates/users/home.html:61 | ||
msgid "Name" | ||
msgstr "" | ||
|
||
#: tests/end2end/test_editing_client.py:82 tests/end2end/test_editing_client.py:148 | ||
#: tests/end2end/test_editing_client.py:215 tests/end2end/test_editing_client.py:248 | ||
#: tests/end2end/test_editing_collection.py:102 tests/end2end/test_editing_user.py:146 | ||
#: tests/end2end/test_registering_collection.py:79 tests/end2end/test_registering_collection.py:102 | ||
#: tests/forms/test_client.py:48 tests/forms/test_client.py:71 tests/forms/test_client.py:94 | ||
#: tests/forms/test_client.py:105 tests/forms/test_client.py:141 tests/forms/test_client.py:164 | ||
#: tests/forms/test_client.py:187 tests/forms/test_client.py:198 tests/forms/test_collection.py:21 | ||
#: tests/forms/test_collection.py:38 tests/forms/test_permission.py:31 | ||
#: tests/forms/test_permission.py:39 tests/forms/test_permission.py:47 | ||
#: tests/forms/test_permission.py:55 | ||
msgid "This field is required." | ||
msgstr "" | ||
|
||
#: tests/end2end/test_editing_client.py:115 tests/forms/test_client.py:60 | ||
#: tests/forms/test_client.py:153 | ||
msgid "Field must be between 3 and 64 characters long." | ||
msgstr "" | ||
|
||
#: tests/end2end/test_editing_client.py:148 tests/end2end/test_editing_client.py:181 | ||
#: xl_auth/client/forms.py:15 xl_auth/templates/clients/home.html:18 | ||
msgid "Description" | ||
msgstr "" | ||
|
||
#: tests/end2end/test_editing_client.py:182 tests/forms/test_client.py:83 | ||
#: tests/forms/test_client.py:176 | ||
msgid "Field must be between 3 and 350 characters long." | ||
msgstr "" | ||
|
||
#: tests/end2end/test_editing_client.py:215 xl_auth/client/forms.py:11 | ||
msgid "Redirect URIs" | ||
msgstr "" | ||
|
||
#: tests/end2end/test_editing_client.py:248 xl_auth/client/forms.py:12 | ||
msgid "Default scopes" | ||
msgstr "" | ||
|
||
#: tests/end2end/test_editing_collection.py:53 tests/end2end/test_registering_collection.py:52 | ||
msgid "category" | ||
msgstr "" | ||
|
@@ -63,20 +107,6 @@ msgstr "" | |
msgid "Code cannot be modified" | ||
msgstr "" | ||
|
||
#: tests/end2end/test_editing_collection.py:102 tests/end2end/test_registering_collection.py:102 | ||
#: xl_auth/collection/forms.py:18 xl_auth/templates/users/home.html:18 | ||
#: xl_auth/templates/users/home.html:61 | ||
msgid "Name" | ||
msgstr "" | ||
|
||
#: tests/end2end/test_editing_collection.py:102 tests/end2end/test_editing_user.py:146 | ||
#: tests/end2end/test_registering_collection.py:79 tests/end2end/test_registering_collection.py:102 | ||
#: tests/forms/test_collection.py:21 tests/forms/test_collection.py:38 | ||
#: tests/forms/test_permission.py:31 tests/forms/test_permission.py:39 | ||
#: tests/forms/test_permission.py:47 tests/forms/test_permission.py:55 | ||
msgid "This field is required." | ||
msgstr "" | ||
|
||
#: tests/end2end/test_editing_collection.py:124 tests/end2end/test_registering_collection.py:125 | ||
#: xl_auth/collection/forms.py:19 xl_auth/templates/collections/home.html:23 | ||
#: xl_auth/templates/collections/home.html:68 | ||
|
@@ -112,19 +142,19 @@ msgstr "" | |
msgid "Users" | ||
msgstr "" | ||
|
||
#: tests/end2end/test_editing_user.py:45 xl_auth/templates/permissions/home.html:30 | ||
#: xl_auth/templates/permissions/home.html:31 xl_auth/templates/permissions/home.html:32 | ||
#: xl_auth/templates/users/home.html:33 xl_auth/templates/users/home.html:76 | ||
#: xl_auth/templates/users/profile.html:58 xl_auth/templates/users/profile.html:61 | ||
#: xl_auth/templates/users/profile.html:65 | ||
#: tests/end2end/test_editing_user.py:45 xl_auth/templates/clients/home.html:29 | ||
#: xl_auth/templates/permissions/home.html:30 xl_auth/templates/permissions/home.html:31 | ||
#: xl_auth/templates/permissions/home.html:32 xl_auth/templates/users/home.html:33 | ||
#: xl_auth/templates/users/home.html:76 xl_auth/templates/users/profile.html:58 | ||
#: xl_auth/templates/users/profile.html:61 xl_auth/templates/users/profile.html:65 | ||
msgid "Yes" | ||
msgstr "" | ||
|
||
#: tests/end2end/test_editing_user.py:45 xl_auth/templates/permissions/home.html:30 | ||
#: xl_auth/templates/permissions/home.html:31 xl_auth/templates/permissions/home.html:32 | ||
#: xl_auth/templates/users/home.html:33 xl_auth/templates/users/home.html:76 | ||
#: xl_auth/templates/users/profile.html:58 xl_auth/templates/users/profile.html:61 | ||
#: xl_auth/templates/users/profile.html:65 | ||
#: tests/end2end/test_editing_user.py:45 xl_auth/templates/clients/home.html:31 | ||
#: xl_auth/templates/permissions/home.html:30 xl_auth/templates/permissions/home.html:31 | ||
#: xl_auth/templates/permissions/home.html:32 xl_auth/templates/users/home.html:33 | ||
#: xl_auth/templates/users/home.html:76 xl_auth/templates/users/profile.html:58 | ||
#: xl_auth/templates/users/profile.html:61 xl_auth/templates/users/profile.html:65 | ||
msgid "No" | ||
msgstr "" | ||
|
||
|
@@ -171,6 +201,10 @@ msgstr "" | |
msgid "Unknown username/email" | ||
msgstr "" | ||
|
||
#: tests/end2end/test_registering_client.py:31 xl_auth/templates/clients/home.html:11 | ||
msgid "New Client" | ||
msgstr "" | ||
|
||
#: tests/end2end/test_registering_collection.py:31 tests/end2end/test_registering_collection.py:171 | ||
#: xl_auth/templates/collections/home.html:15 | ||
msgid "New Collection" | ||
|
@@ -205,6 +239,16 @@ msgstr "" | |
msgid "Email already registered" | ||
msgstr "" | ||
|
||
#: tests/forms/test_client.py:25 tests/forms/test_client.py:118 tests/forms/test_collection.py:124 | ||
#: tests/forms/test_collection.py:135 tests/forms/test_permission.py:144 | ||
#: tests/forms/test_permission.py:174 tests/forms/test_user.py:63 tests/forms/test_user.py:106 | ||
#: tests/forms/test_user.py:132 tests/forms/test_user.py:169 xl_auth/client/forms.py:41 | ||
#: xl_auth/client/forms.py:68 xl_auth/collection/forms.py:41 xl_auth/collection/forms.py:73 | ||
#: xl_auth/permission/forms.py:59 xl_auth/permission/forms.py:100 xl_auth/user/forms.py:44 | ||
#: xl_auth/user/forms.py:97 xl_auth/user/forms.py:123 xl_auth/user/forms.py:150 | ||
msgid "You do not have sufficient privileges for this operation." | ||
msgstr "" | ||
|
||
#: tests/forms/test_collection.py:30 | ||
msgid "Field must be between 1 and 5 characters long." | ||
msgstr "" | ||
|
@@ -217,15 +261,6 @@ msgstr "" | |
msgid "Field must be between 2 and 255 characters long." | ||
msgstr "" | ||
|
||
#: tests/forms/test_collection.py:124 tests/forms/test_collection.py:135 | ||
#: tests/forms/test_permission.py:144 tests/forms/test_permission.py:174 tests/forms/test_user.py:63 | ||
#: tests/forms/test_user.py:106 tests/forms/test_user.py:132 tests/forms/test_user.py:169 | ||
#: xl_auth/collection/forms.py:41 xl_auth/collection/forms.py:73 xl_auth/permission/forms.py:59 | ||
#: xl_auth/permission/forms.py:100 xl_auth/user/forms.py:44 xl_auth/user/forms.py:97 | ||
#: xl_auth/user/forms.py:123 xl_auth/user/forms.py:150 | ||
msgid "You do not have sufficient privileges for this operation." | ||
msgstr "" | ||
|
||
#: tests/forms/test_permission.py:22 xl_auth/permission/forms.py:104 xl_auth/permission/views.py:61 | ||
#: xl_auth/permission/views.py:87 | ||
#, python-format | ||
|
@@ -269,6 +304,20 @@ msgstr "" | |
msgid "Replaced by %(replaced_by_code)s" | ||
msgstr "" | ||
|
||
#: xl_auth/client/forms.py:13 xl_auth/templates/clients/home.html:19 | ||
msgid "Confidential" | ||
msgstr "" | ||
|
||
#: xl_auth/client/views.py:44 | ||
#, python-format | ||
msgid "Client \"%(name)s\" created." | ||
msgstr "" | ||
|
||
#: xl_auth/client/views.py:68 | ||
#, python-format | ||
msgid "Thank you for updating client details for \"%(id)s\"." | ||
msgstr "" | ||
|
||
#: xl_auth/collection/forms.py:19 | ||
msgid "Bibliography" | ||
msgstr "" | ||
|
@@ -366,16 +415,33 @@ msgstr "" | |
msgid "Log out" | ||
msgstr "" | ||
|
||
#: xl_auth/templates/collections/edit.html:5 | ||
msgid "Edit Existing Collection" | ||
#: xl_auth/templates/clients/edit.html:5 | ||
msgid "Edit OAuth2 Client" | ||
msgstr "" | ||
|
||
#: xl_auth/templates/collections/edit.html:29 xl_auth/templates/permissions/edit.html:35 | ||
#: xl_auth/templates/users/administer.html:25 xl_auth/templates/users/change_password.html:21 | ||
#: xl_auth/templates/users/edit_details.html:17 | ||
#: xl_auth/templates/clients/edit.html:31 xl_auth/templates/collections/edit.html:29 | ||
#: xl_auth/templates/permissions/edit.html:35 xl_auth/templates/users/administer.html:25 | ||
#: xl_auth/templates/users/change_password.html:21 xl_auth/templates/users/edit_details.html:17 | ||
msgid "Save" | ||
msgstr "" | ||
|
||
#: xl_auth/templates/clients/home.html:4 xl_auth/templates/clients/home.html:8 | ||
msgid "OAuth2 Clients" | ||
msgstr "" | ||
|
||
#: xl_auth/templates/clients/home.html:20 xl_auth/templates/users/home.html:20 | ||
#: xl_auth/templates/users/home.html:63 | ||
msgid "Admin" | ||
msgstr "" | ||
|
||
#: xl_auth/templates/clients/register.html:5 | ||
msgid "Register New OAuth2 Client" | ||
msgstr "" | ||
|
||
#: xl_auth/templates/collections/edit.html:5 | ||
msgid "Edit Existing Collection" | ||
msgstr "" | ||
|
||
#: xl_auth/templates/collections/home.html:6 xl_auth/templates/collections/home.html:54 | ||
#: xl_auth/templates/collections/home.html:88 | ||
msgid "Go to" | ||
|
@@ -498,10 +564,6 @@ msgstr "" | |
msgid "Active Users" | ||
msgstr "" | ||
|
||
#: xl_auth/templates/users/home.html:20 xl_auth/templates/users/home.html:63 | ||
msgid "Admin" | ||
msgstr "" | ||
|
||
#: xl_auth/templates/users/home.html:37 xl_auth/templates/users/home.html:80 | ||
msgid "Edit Details" | ||
msgstr "" | ||
|
38 changes: 38 additions & 0 deletions
38
migrations/versions/bc2c31758e2a_add_oauth2_client_table.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
"""Add OAuth2 Client table. | ||
Revision ID: bc2c31758e2a | ||
Revises: b09534921ab0 | ||
Create Date: 2017-10-26 14:57:37.549116 | ||
""" | ||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = 'bc2c31758e2a' | ||
down_revision = 'b09534921ab0' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
"""Add OAuth2 Client table.""" | ||
op.create_table('clients', | ||
sa.Column('id', sa.Integer(), nullable=False), | ||
sa.Column('client_id', sa.String(length=64), nullable=False), | ||
sa.Column('client_secret', sa.String(length=256), nullable=False), | ||
sa.Column('created_by', sa.Integer(), nullable=False), | ||
sa.Column('is_confidential', sa.Boolean(), nullable=False), | ||
sa.Column('redirect_uris', sa.Text(), nullable=False), | ||
sa.Column('default_scopes', sa.Text(), nullable=False), | ||
sa.Column('name', sa.String(length=64), nullable=True), | ||
sa.Column('description', sa.String(length=400), nullable=True), | ||
sa.ForeignKeyConstraint(['created_by'], ['users.id'], ), | ||
sa.PrimaryKeyConstraint('id'), | ||
sa.UniqueConstraint('client_id'), | ||
sa.UniqueConstraint('client_secret')) | ||
|
||
|
||
def downgrade(): | ||
"""Drop OAuth2 Client table.""" | ||
op.drop_table('clients') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# -*- coding: utf-8 -*- | ||
"""Test deleting clients.""" | ||
|
||
from __future__ import absolute_import, division, print_function, unicode_literals | ||
|
||
from flask import url_for | ||
from flask_babel import gettext as _ | ||
|
||
from xl_auth.client.models import Client | ||
|
||
|
||
def test_superuser_can_delete_existing_client(superuser, client, testapp): | ||
"""Delete existing client.""" | ||
old_count = len(Client.query.all()) | ||
name = client.name | ||
# Goes to homepage | ||
res = testapp.get('/') | ||
# Fills out login form | ||
form = res.forms['loginForm'] | ||
form['username'] = superuser.email | ||
form['password'] = 'myPrecious' | ||
# Submits | ||
res = form.submit().follow() | ||
# Clicks Clients button | ||
# res = res.click(href=url_for('client.home')) | ||
# FIXME: No nav link yet | ||
assert res.lxml.xpath("//a[contains(@href,'{0}')]".format(url_for('client.home'))) == [] | ||
|
||
res = testapp.get('/clients/') | ||
# Clicks Delete button on a client | ||
res = res.click(href=url_for('client.delete', id=client.id)).follow() | ||
assert res.status_code == 200 | ||
# Client was deleted, so number of clients are 1 less than initial state | ||
assert _('Successfully deleted OAuth2 Client "%(name)s".', name=name) in res | ||
assert len(Client.query.all()) == old_count - 1 | ||
|
||
|
||
def test_user_cannot_delete_client(user, client, testapp): | ||
"""Attempt to delete a client.""" | ||
old_count = len(Client.query.all()) | ||
# Goes to homepage | ||
res = testapp.get('/') | ||
# Fills out login form | ||
form = res.forms['loginForm'] | ||
form['username'] = user.email | ||
form['password'] = 'myPrecious' | ||
# Submits | ||
res = form.submit().follow() | ||
|
||
# We see no Clients button | ||
assert res.lxml.xpath("//a[contains(@text,'{0}')]".format(_('Clients'))) == [] | ||
|
||
# Try to go there directly | ||
testapp.get('/clients/', status=403) | ||
|
||
# Try to delete | ||
testapp.delete(url_for('client.delete', id=client.id), status=403) | ||
|
||
# Nothing was deleted | ||
assert len(Client.query.all()) == old_count |
Oops, something went wrong.