-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
83 additions
and
0 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
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
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,17 @@ | ||
import logging | ||
from flask import current_app as app, Blueprint, jsonify | ||
|
||
from layman.authz.role_service import get_all_roles | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
bp = Blueprint('rest_roles', __name__) | ||
|
||
|
||
@bp.route('', methods=['GET']) | ||
def get(): | ||
app.logger.info(f"GET Roles") | ||
|
||
roles = get_all_roles() | ||
|
||
return jsonify(roles), 200 |
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
Empty file.
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,30 @@ | ||
import requests | ||
import pytest | ||
|
||
from layman import app, settings | ||
from test_tools import role_service | ||
from test_tools.util import url_for | ||
|
||
|
||
@pytest.mark.usefixtures('ensure_layman') | ||
def test_get_roles(): | ||
rolename = 'TEST_GET_ROLES_ROLE' | ||
|
||
with app.app_context(): | ||
# roles.GET | ||
url = url_for('rest_roles.get') | ||
assert url.endswith('/' + settings.REST_ROLES_PREFIX) | ||
|
||
# Without role | ||
response = requests.get(url, timeout=settings.DEFAULT_CONNECTION_TIMEOUT) | ||
assert response.status_code == 200, response.json() | ||
assert response.json() == [settings.RIGHTS_EVERYONE_ROLE] | ||
|
||
# With role | ||
with app.app_context(): | ||
role_service.ensure_role(rolename) | ||
response = requests.get(url, timeout=settings.DEFAULT_CONNECTION_TIMEOUT) | ||
assert response.status_code == 200, response.json() | ||
assert response.json() == [rolename, settings.RIGHTS_EVERYONE_ROLE] | ||
|
||
role_service.delete_role(rolename) |