From 59dde65e966d870c7e178c4e749f0dbf974c3a74 Mon Sep 17 00:00:00 2001 From: Benjamin Bertrand <benjamin.bertrand@esss.se> Date: Fri, 3 Nov 2017 13:16:32 +0100 Subject: [PATCH] Rename application to CSEntry --- .env | 2 +- Dockerfile | 8 +++--- Makefile | 8 +++--- README.rst | 14 +++++----- app/api/main.py | 26 +++++++++---------- app/decorators.py | 6 ++--- app/factory.py | 6 ++--- app/main/views.py | 6 ++--- app/models.py | 8 +++--- app/settings.py | 4 +-- app/static/css/{inventory.css => csentry.css} | 0 app/static/js/{inventory.js => csentry.js} | 0 app/templates/404.html | 2 +- app/templates/500.html | 2 +- app/templates/admin/index.html | 4 +-- app/templates/base.html | 8 +++--- app/templates/create_qrcodes.html | 4 +-- app/templates/index.html | 6 ++--- app/templates/qrcodes.html | 2 +- app/templates/users/login.html | 2 +- app/templates/users/profile.html | 2 +- app/templates/view_item.html | 2 +- app/utils.py | 8 +++--- docker-compose.yml | 6 ++--- environment.yml | 2 +- postgres/create-test-db.sh | 2 +- tests/functional/conftest.py | 12 ++++----- tests/functional/test_web.py | 10 +++---- 28 files changed, 81 insertions(+), 81 deletions(-) rename app/static/css/{inventory.css => csentry.css} (100%) rename app/static/js/{inventory.js => csentry.js} (100%) diff --git a/.env b/.env index b6c313d..e028ff2 100644 --- a/.env +++ b/.env @@ -1,4 +1,4 @@ POSTGRES_USER=ics POSTGRES_PASSWORD=icspwd -POSTGRES_DB=inventory_db +POSTGRES_DB=csentry_db PGDATA_VOLUME=./data diff --git a/Dockerfile b/Dockerfile index 0d66256..e34a3ea 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,15 +11,15 @@ RUN apt-get update && apt-get install -y \ gcc \ && rm -rf /var/lib/apt/lists/* -# Install inventory requirements +# Install CSEntry requirements COPY environment.yml /app/environment.yml RUN conda config --add channels conda-forge \ - && conda env create -n inventory -f environment.yml \ + && conda env create -n csentry -f environment.yml \ && rm -rf /opt/conda/pkgs/* # Install the app COPY . /app/ RUN chown -R ics:ics /app/* -# activate the inventory environment -ENV PATH /opt/conda/envs/inventory/bin:$PATH +# activate the csentry environment +ENV PATH /opt/conda/envs/csentry/bin:$PATH diff --git a/Makefile b/Makefile index b4656cf..4f6e4c5 100644 --- a/Makefile +++ b/Makefile @@ -2,13 +2,13 @@ OWNER := europeanspallationsource GIT_TAG := $(shell git describe --always) -IMAGE := ics-inventory +IMAGE := csentry help: # http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html - @echo "ics-inventory" - @echo "=============" + @echo "CSEntry" + @echo "=======" @echo @grep -E '^[a-zA-Z0-9_%/-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' @@ -24,7 +24,7 @@ push: ## push the latest and git tag image clean: ## remove the image with git tag and the test database -docker rmi $(OWNER)/$(IMAGE):$(GIT_TAG) - -docker rm -f inventory_postgres + -docker rm -f csentry_postgres refresh: ## pull the latest image from Docker Hub # skip if error: image might not be on dockerhub yet diff --git a/README.rst b/README.rst index 338cf8b..4992db3 100644 --- a/README.rst +++ b/README.rst @@ -1,7 +1,7 @@ -ICS inventory -============= +CSEntry +======= -ICS inventory web server. +Control System Entry web server. Development @@ -68,11 +68,11 @@ Backup & restore To dump the database:: - $ docker run --rm --link inventory_postgres:postgres --net inventory_default -e PGPASSWORD="<inventory_password>" - postgres:9.6 pg_dump -h postgres -U inventory inventory_db | gzip > inventory_db.dump.gz + $ docker run --rm --link csentry_postgres:postgres --net csentry_default -e PGPASSWORD="<csentry_password>" + postgres:9.6 pg_dump -h postgres -U csentry csentry_db | gzip > csentry_db.dump.gz To restore the database:: - $ gunzip -c inventory_db.dump.g | docker run --rm --link inventory_postgres:postgres --net inventory_default - -e PGPASSWORD="<inventory_password>" -i postgres:9.6 psql -h postgres -U inventory inventory_db + $ gunzip -c csentry_db.dump.g | docker run --rm --link csentry_postgres:postgres --net csentry_default + -e PGPASSWORD="<csentry_password>" -i postgres:9.6 psql -h postgres -U csentry csentry_db diff --git a/app/api/main.py b/app/api/main.py index b2da8f6..e2cf9ca 100644 --- a/app/api/main.py +++ b/app/api/main.py @@ -31,7 +31,7 @@ def get_item_by_id_or_ics_id(id_): else: item = Item.query.get(item_id) if item is None: - raise utils.InventoryError(f"Item id '{id_}' not found", status_code=404) + raise utils.CSEntryError(f"Item id '{id_}' not found", status_code=404) return item @@ -51,21 +51,21 @@ def get_generic_model(model, args): def create_generic_model(model, mandatory_field='name'): data = request.get_json() if data is None: - raise utils.InventoryError('Body should be a JSON object') + raise utils.CSEntryError('Body should be a JSON object') current_app.logger.debug(f'Received: {data}') if mandatory_field not in data: - raise utils.InventoryError(f"Missing mandatory field '{mandatory_field}'", status_code=422) + raise utils.CSEntryError(f"Missing mandatory field '{mandatory_field}'", status_code=422) try: instance = model(**data) except TypeError as e: message = str(e).replace('__init__() got an ', '') - raise utils.InventoryError(message) + raise utils.CSEntryError(message) db.session.add(instance) try: db.session.commit() except sa.exc.IntegrityError as e: db.session.rollback() - raise utils.InventoryError('IntegrityError', status_code=409) + raise utils.CSEntryError('IntegrityError', status_code=409) return jsonify(instance.to_dict()), 201 @@ -73,12 +73,12 @@ def create_generic_model(model, mandatory_field='name'): def login(): data = request.get_json() if data is None: - raise utils.InventoryError('Body should be a JSON object') + raise utils.CSEntryError('Body should be a JSON object') try: username = data['username'] password = data['password'] except KeyError: - raise utils.InventoryError('Missing mandatory field (username or password)', status_code=422) + raise utils.CSEntryError('Missing mandatory field (username or password)', status_code=422) response = ldap_manager.authenticate(username, password) if response.status == AuthenticationResponseStatus.success: current_app.logger.debug(f'{username} successfully logged in') @@ -89,7 +89,7 @@ def login(): response.user_groups) payload = {'access_token': create_access_token(identity=user.id)} return jsonify(payload), 200 - raise utils.InventoryError('Invalid credentials', status_code=401) + raise utils.CSEntryError('Invalid credentials', status_code=401) @bp.route('/items') @@ -141,19 +141,19 @@ def patch_item(id_): """ data = request.get_json() if data is None: - raise utils.InventoryError('Body should be a JSON object') + raise utils.CSEntryError('Body should be a JSON object') if not data: - raise utils.InventoryError('At least one field is required', status_code=422) + raise utils.CSEntryError('At least one field is required', status_code=422) for key in data.keys(): if key not in ('ics_id', 'manufacturer', 'model', 'location', 'status', 'parent'): - raise utils.InventoryError(f"Invalid field '{key}'", status_code=422) + raise utils.CSEntryError(f"Invalid field '{key}'", status_code=422) item = get_item_by_id_or_ics_id(id_) # Only allow to set ICS id if it's null if item.ics_id is None: item.ics_id = data.get('ics_id') elif 'ics_id' in data: - raise utils.InventoryError("'ics_id' can't be changed", status_code=422) + raise utils.CSEntryError("'ics_id' can't be changed", status_code=422) item.manufacturer = utils.convert_to_model(data.get('manufacturer', item.manufacturer), Manufacturer) item.model = utils.convert_to_model(data.get('model', item.model), Model) item.location = utils.convert_to_model(data.get('location', item.location), Location) @@ -174,7 +174,7 @@ def patch_item(id_): db.session.commit() except sa.exc.IntegrityError as e: db.session.rollback() - raise utils.InventoryError('IntegrityError', status_code=409) + raise utils.CSEntryError('IntegrityError', status_code=409) return jsonify(item.to_dict()) diff --git a/app/decorators.py b/app/decorators.py index bdf40ab..90da276 100644 --- a/app/decorators.py +++ b/app/decorators.py @@ -13,7 +13,7 @@ from functools import wraps from flask import current_app, abort from flask_login import current_user from flask_jwt_extended import get_current_user -from .utils import InventoryError +from .utils import CSEntryError def jwt_groups_accepted(*groups): @@ -38,9 +38,9 @@ def jwt_groups_accepted(*groups): def decorated_view(*args, **kwargs): user = get_current_user() if user is None: - raise InventoryError('Invalid indentity', status_code=403) + raise CSEntryError('Invalid indentity', status_code=403) if not user.is_member_of_one_group(groups): - raise InventoryError("User doesn't have the required group", status_code=403) + raise CSEntryError("User doesn't have the required group", status_code=403) return fn(*args, **kwargs) return decorated_view return wrapper diff --git a/app/factory.py b/app/factory.py index 7ffe7fc..be964e4 100644 --- a/app/factory.py +++ b/app/factory.py @@ -51,7 +51,7 @@ def create_app(config=None): mail_handler = SMTPHandler(app.config['MAIL_SERVER'], fromaddr=app.config['EMAIL_SENDER'], toaddrs=app.config['ADMIN_EMAILS'], - subject='Inventory: ERROR raised', + subject='CSEntry: ERROR raised', credentials=app.config['MAIL_CREDENTIALS']) mail_handler.setFormatter(logging.Formatter(""" Message type: %(levelname)s @@ -77,7 +77,7 @@ def create_app(config=None): app.logger.setLevel(logging.DEBUG) handler.setLevel(logging.DEBUG) app.logger.addHandler(handler) - app.logger.info('Inventory created!') + app.logger.info('CSEntry created!') app.logger.info('Settings:\n{}'.format( '\n'.join(['{}: {}'.format(key, value) for key, value in app.config.items() if key not in ('SECRET_KEY', 'LDAP_BIND_USER_PASSWORD')]))) @@ -107,7 +107,7 @@ def create_app(config=None): app.wsgi_app = WhiteNoise(app.wsgi_app, root='static/') app.wsgi_app.add_files( - root='/opt/conda/envs/inventory/lib/python3.6/site-packages/flask_bootstrap/static/', + root='/opt/conda/envs/csentry/lib/python3.6/site-packages/flask_bootstrap/static/', prefix='bootstrap/' ) diff --git a/app/main/views.py b/app/main/views.py index f85bb39..4bde378 100644 --- a/app/main/views.py +++ b/app/main/views.py @@ -33,8 +33,8 @@ def internal_error(error): return render_template('500.html'), 500 -@bp.app_errorhandler(utils.InventoryError) -def handle_inventory_error(error): +@bp.app_errorhandler(utils.CSEntryError) +def handle_csentry_error(error): response = jsonify(error.to_dict()) response.status_code = error.status_code return response @@ -108,7 +108,7 @@ def retrieve_qrcodes_name(kind): try: model = globals()[kind] except KeyError: - raise utils.InventoryError(f"Unknown model '{kind}'", status_code=422) + raise utils.CSEntryError(f"Unknown model '{kind}'", status_code=422) items = db.session.query(model).order_by(model.name) data = [[item.name] for item in items] return jsonify(data=data) diff --git a/app/models.py b/app/models.py index 588c9dd..dce36d8 100644 --- a/app/models.py +++ b/app/models.py @@ -121,16 +121,16 @@ class User(db.Model, UserMixin): @property def is_admin(self): - return current_app.config['INVENTORY_LDAP_GROUPS']['admin'] in self.groups + return current_app.config['CSENTRY_LDAP_GROUPS']['admin'] in self.groups def is_member_of_one_group(self, groups): """Return True if the user is at least member of one of the given groups""" - names = [current_app.config['INVENTORY_LDAP_GROUPS'].get(group) for group in groups] + names = [current_app.config['CSENTRY_LDAP_GROUPS'].get(group) for group in groups] return bool(set(self.groups) & set(names)) def is_member_of_all_groups(self, groups): """Return True if the user is member of all the given groups""" - names = [current_app.config['INVENTORY_LDAP_GROUPS'].get(group) for group in groups] + names = [current_app.config['CSENTRY_LDAP_GROUPS'].get(group) for group in groups] return set(names).issubset(self.groups) def __str__(self): @@ -231,7 +231,7 @@ class Item(db.Model): """Ensure the ICS id field matches the required format""" if string is not None: if ICS_ID_RE.fullmatch(string) is None: - raise utils.InventoryError('ICS id shall match [A-Z]{3}[0-9]{3}', status_code=422) + raise utils.CSEntryError('ICS id shall match [A-Z]{3}[0-9]{3}', status_code=422) return string def to_dict(self, extra=False): diff --git a/app/settings.py b/app/settings.py index 3a7cc2a..cab395a 100644 --- a/app/settings.py +++ b/app/settings.py @@ -12,7 +12,7 @@ This module implements the app default settings. import os from datetime import timedelta -SQLALCHEMY_DATABASE_URI = 'postgresql://ics:icspwd@postgres/inventory_db' +SQLALCHEMY_DATABASE_URI = 'postgresql://ics:icspwd@postgres/csentry_db' SQLALCHEMY_TRACK_MODIFICATIONS = False BOOTSTRAP_SERVE_LOCAL = True SECRET_KEY = (os.environ.get('SECRET_KEY') or @@ -41,7 +41,7 @@ LDAP_GROUP_MEMBERS_ATTR = 'member' LDAP_GET_USER_ATTRIBUTES = ['cn', 'sAMAccountName', 'mail'] LDAP_GET_GROUP_ATTRIBUTES = ['cn'] -INVENTORY_LDAP_GROUPS = { +CSENTRY_LDAP_GROUPS = { 'admin': 'ICS Control System Infrastructure group', 'create': 'ICS Employees', } diff --git a/app/static/css/inventory.css b/app/static/css/csentry.css similarity index 100% rename from app/static/css/inventory.css rename to app/static/css/csentry.css diff --git a/app/static/js/inventory.js b/app/static/js/csentry.js similarity index 100% rename from app/static/js/inventory.js rename to app/static/js/csentry.js diff --git a/app/templates/404.html b/app/templates/404.html index 6d26798..35155ba 100644 --- a/app/templates/404.html +++ b/app/templates/404.html @@ -1,6 +1,6 @@ {%- extends "base.html" %} -{% block title %}Page Not Found - ICS Inventory{% endblock %} +{% block title %}Page Not Found - CSEntry{% endblock %} {% block main %} <h1>Page Not Found</h1> diff --git a/app/templates/500.html b/app/templates/500.html index 8be15a0..175b857 100644 --- a/app/templates/500.html +++ b/app/templates/500.html @@ -1,6 +1,6 @@ {%- extends "base.html" %} -{% block title %}Internal Server Error - ICS Inventory{% endblock %} +{% block title %}Internal Server Error - CSEntry{% endblock %} {% block main %} <h1>Internal Server Error</h1> diff --git a/app/templates/admin/index.html b/app/templates/admin/index.html index b121f3f..996ac40 100644 --- a/app/templates/admin/index.html +++ b/app/templates/admin/index.html @@ -1,10 +1,10 @@ {% extends "admin/master.html" %} -{% block title %}Admin - ICS Inventory{% endblock %} +{% block title %}Admin - CSEntry{% endblock %} {% block body %} <h2>Use the admin interface with care</h2> <!-- flask-admin uses bootstrap 3 --> -<a class="btn btn-primary" href="{{ url_for('main.index') }}">ICS Inventory</a> +<a class="btn btn-primary" href="{{ url_for('main.index') }}">CSEntry</a> {% endblock %} diff --git a/app/templates/base.html b/app/templates/base.html index bd87084..19ed9bd 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -5,15 +5,15 @@ {% block styles %} {{super()}} <link href="{{ url_for('static', filename='css/dataTables.bootstrap4.min.css') }}" rel="stylesheet"> - <link href="{{ url_for('static', filename='css/inventory.css') }}" rel="stylesheet"> + <link href="{{ url_for('static', filename='css/csentry.css') }}" rel="stylesheet"> {% endblock %} -{% block title %}ICS Inventory{% endblock %} +{% block title %}CSEntry{% endblock %} {% block navbar %} <!-- Fixed navbar --> <div class="navbar fixed-top navbar-expand-lg navbar-light bg-light" role="navigation"> - <a class="navbar-brand" href="{{ url_for('main.index') }}">ICS Inventory</a> + <a class="navbar-brand" href="{{ url_for('main.index') }}">CSEntry</a> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"> @@ -69,5 +69,5 @@ <script type=text/javascript> $SCRIPT_ROOT = {{ request.script_root|tojson|safe }}; </script> - {% block inventory_scripts %}{% endblock %} + {% block csentry_scripts %}{% endblock %} {% endblock %} diff --git a/app/templates/create_qrcodes.html b/app/templates/create_qrcodes.html index a785be8..9b535d8 100644 --- a/app/templates/create_qrcodes.html +++ b/app/templates/create_qrcodes.html @@ -1,7 +1,7 @@ {%- extends "base.html" %} {% import "bootstrap/wtf.html" as wtf %} -{% block title %}Create QR Codes - ICS Inventory{% endblock %} +{% block title %}Create QR Codes - CSEntry{% endblock %} {% block main %} <h2>Create QR Codes</h2> @@ -29,6 +29,6 @@ </table> {%- endblock %} -{% block inventory_scripts %} +{% block csentry_scripts %} <script src="{{ url_for('static', filename='js/qrcodes.js') }}"></script> {% endblock %} diff --git a/app/templates/index.html b/app/templates/index.html index f76de15..43c0d82 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -2,7 +2,7 @@ {% block main %} <div class="jumbotron"> - <h1 class="display-4">Welcome to the ICS Inventory!</h1> + <h1 class="display-4">Welcome to CSEntry!</h1> </div> <table id="items_table" class="table table-bordered table-hover table-sm"> <thead> @@ -22,6 +22,6 @@ </table> {%- endblock %} -{% block inventory_scripts %} - <script src="{{ url_for('static', filename='js/inventory.js') }}"></script> +{% block csentry_scripts %} + <script src="{{ url_for('static', filename='js/csentry.js') }}"></script> {% endblock %} diff --git a/app/templates/qrcodes.html b/app/templates/qrcodes.html index 3a0bbd1..91aa071 100644 --- a/app/templates/qrcodes.html +++ b/app/templates/qrcodes.html @@ -1,6 +1,6 @@ {%- extends "base.html" %} -{% block title %}QR Codes - ICS Inventory{% endblock %} +{% block title %}QR Codes - CSEntry{% endblock %} {% block main %} {% for name, images in codes.items() %} diff --git a/app/templates/users/login.html b/app/templates/users/login.html index 60a6cc5..4e5f426 100644 --- a/app/templates/users/login.html +++ b/app/templates/users/login.html @@ -1,7 +1,7 @@ {% import "bootstrap/wtf.html" as wtf %} {% extends "base.html" %} -{% block title %}Login - ICS Inventory{% endblock %} +{% block title %}Login - CSEntry{% endblock %} {% block main %} <div class="col-sm-offset-2 col-sm-4"> diff --git a/app/templates/users/profile.html b/app/templates/users/profile.html index fc384b0..70c69e1 100644 --- a/app/templates/users/profile.html +++ b/app/templates/users/profile.html @@ -1,7 +1,7 @@ {% import "bootstrap/wtf.html" as wtf %} {% extends "base.html" %} -{% block title %}Profile - ICS Inventory{% endblock %} +{% block title %}Profile - CSEntry{% endblock %} {% block main %} <h2>{{ user.username }}</h2> diff --git a/app/templates/view_item.html b/app/templates/view_item.html index d38b1d3..2c039be 100644 --- a/app/templates/view_item.html +++ b/app/templates/view_item.html @@ -1,7 +1,7 @@ {%- extends "base.html" %} {% from "_helpers.html" import link_to_item, link_to_items %} -{% block title %}View Item - ICS Inventory{% endblock %} +{% block title %}View Item - CSEntry{% endblock %} {% block main %} <h2>Item {{ item['ics_id'] }}</h2> diff --git a/app/utils.py b/app/utils.py index a369fbf..7f99294 100644 --- a/app/utils.py +++ b/app/utils.py @@ -15,8 +15,8 @@ import io import sqlalchemy as sa -class InventoryError(Exception): - """InventoryError class +class CSEntryError(Exception): + """CSEntryError class Exception used to pass useful information to the client side (API or AJAX) """ @@ -72,7 +72,7 @@ def convert_to_model(item, model): if not isinstance(item, model): instance = model.query.filter_by(name=item).first() if instance is None: - raise InventoryError(f'{item} is not a valid {model.__name__.lower()}') + raise CSEntryError(f'{item} is not a valid {model.__name__.lower()}') return instance return item @@ -118,5 +118,5 @@ def get_query(query, args): try: query = query.filter_by(**kwargs) except (sa.exc.InvalidRequestError, AttributeError) as e: - raise InventoryError('Invalid query arguments', status_code=422) + raise CSEntryError('Invalid query arguments', status_code=422) return query diff --git a/docker-compose.yml b/docker-compose.yml index 3d94e01..28cc8fc 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,14 +1,14 @@ version: '2' services: web: - image: europeanspallationsource/ics-inventory:latest - container_name: inventory_web + image: europeanspallationsource/csentry:latest + container_name: csentry_web command: pytest --cov=app -v depends_on: - postgres postgres: image: postgres:9.6 - container_name: inventory_postgres + container_name: csentry_postgres expose: - "5432" volumes: diff --git a/environment.yml b/environment.yml index f00e2bb..f8a6e16 100644 --- a/environment.yml +++ b/environment.yml @@ -1,4 +1,4 @@ -name: inventory +name: csentry channels: !!python/tuple - conda-forge - defaults diff --git a/postgres/create-test-db.sh b/postgres/create-test-db.sh index da67a98..8c723ce 100755 --- a/postgres/create-test-db.sh +++ b/postgres/create-test-db.sh @@ -3,5 +3,5 @@ set -e psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" -d "$POSTGRES_DB" <<-EOSQL - CREATE DATABASE inventory_db_test; + CREATE DATABASE csentry_db_test; EOSQL diff --git a/tests/functional/conftest.py b/tests/functional/conftest.py index ff9104c..71a747f 100644 --- a/tests/functional/conftest.py +++ b/tests/functional/conftest.py @@ -22,10 +22,10 @@ def app(request): config = { 'TESTING': True, 'WTF_CSRF_ENABLED': False, - 'SQLALCHEMY_DATABASE_URI': 'postgresql://ics:icspwd@postgres/inventory_db_test', - 'INVENTORY_LDAP_GROUPS': { - 'admin': 'Inventory Admin', - 'create': 'Inventory User', + 'SQLALCHEMY_DATABASE_URI': 'postgresql://ics:icspwd@postgres/csentry_db_test', + 'CSENTRY_LDAP_GROUPS': { + 'admin': 'CSEntry Admin', + 'create': 'CSEntry User', } } app = create_app(config=config) @@ -105,11 +105,11 @@ def patch_ldap_authenticate(monkeypatch): if username == 'admin' and password == 'adminpasswd': response.status = AuthenticationResponseStatus.success response.user_info = {'cn': 'Admin User', 'mail': 'admin@example.com'} - response.user_groups = [{'cn': 'Inventory Admin'}] + response.user_groups = [{'cn': 'CSEntry Admin'}] elif username == 'user_rw' and password == 'userrw': response.status = AuthenticationResponseStatus.success response.user_info = {'cn': 'User RW', 'mail': 'user_rw@example.com'} - response.user_groups = [{'cn': 'Inventory User'}] + response.user_groups = [{'cn': 'CSEntry User'}] elif username == 'user_ro' and password == 'userro': response.status = AuthenticationResponseStatus.success response.user_info = {'cn': 'User RO', 'mail': 'user_ro@example.com'} diff --git a/tests/functional/test_web.py b/tests/functional/test_web.py index 5ac595b..f26a201 100644 --- a/tests/functional/test_web.py +++ b/tests/functional/test_web.py @@ -42,19 +42,19 @@ def logged_client(request, app): def test_login_logout(client): response = login(client, 'unknown', 'invalid') - assert b'<title>Login - ICS Inventory</title>' in response.data + assert b'<title>Login - CSEntry</title>' in response.data response = login(client, 'user_rw', 'invalid') - assert b'<title>Login - ICS Inventory</title>' in response.data + assert b'<title>Login - CSEntry</title>' in response.data response = login(client, 'user_rw', 'userrw') - assert b'Welcome to the ICS Inventory!' in response.data + assert b'Welcome to CSEntry!' in response.data assert b'User RW' in response.data response = logout(client) - assert b'<title>Login - ICS Inventory</title>' in response.data + assert b'<title>Login - CSEntry</title>' in response.data def test_index(logged_client): response = logged_client.get('/') - assert b'Welcome to the ICS Inventory!' in response.data + assert b'Welcome to CSEntry!' in response.data assert b'User RO' in response.data -- GitLab