Skip to content

Commit b103347

Browse files
committed
Updating python dependencies
1 parent 7f2cf3d commit b103347

File tree

4 files changed

+47
-35
lines changed

4 files changed

+47
-35
lines changed

allure-docker-api/app.py

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
from flask_swagger_ui import get_swaggerui_blueprint
2424
from flask_jwt_extended import (
2525
JWTManager, jwt_required, create_access_token, create_refresh_token, current_user,
26-
get_jwt_identity, verify_jwt_in_request, jwt_refresh_token_required, get_raw_jwt,
27-
set_access_cookies, set_refresh_cookies, unset_jwt_cookies, verify_jwt_refresh_token_in_request
26+
get_jwt_identity, verify_jwt_in_request, get_jwt,
27+
set_access_cookies, set_refresh_cookies, unset_jwt_cookies
2828
)
2929

3030
dictConfig({
@@ -151,7 +151,7 @@ def __str__(self):
151151
REPORT_INDEX_FILE = 'index.html'
152152
DEFAULT_TEMPLATE = 'default.html'
153153
LANGUAGE_TEMPLATE = 'select_language.html'
154-
LANGUAGES = ["en", "ru", "zh", "de", "nl", "he", "br", "pl", "ja", "es", "kr", "fr"]
154+
LANGUAGES = ["en", "ru", "zh", "de", "nl", "he", "br", "pl", "ja", "es", "kr", "fr", "az"]
155155
GLOBAL_CSS = "https://stackpath.bootstrapcdn.com/bootswatch/4.3.1/cosmo/bootstrap.css"
156156
EMAILABLE_REPORT_CSS = GLOBAL_CSS
157157
EMAILABLE_REPORT_TITLE = "Emailable Report"
@@ -440,10 +440,10 @@ def generate_security_swagger_spec():
440440
'app_name': "Allure Docker Service"
441441
}
442442
)
443-
app.register_blueprint(SWAGGERUI_BLUEPRINT, url_prefix="/")
444-
app.register_blueprint(SWAGGERUI_BLUEPRINT, url_prefix=NATIVE_PREFIX)
445-
app.register_blueprint(SWAGGERUI_BLUEPRINT, url_prefix=SWAGGER_ENDPOINT)
446-
app.register_blueprint(SWAGGERUI_BLUEPRINT, url_prefix=SWAGGER_ENDPOINT_PATH)
443+
app.register_blueprint(SWAGGERUI_BLUEPRINT, name="main", url_prefix="/")
444+
app.register_blueprint(SWAGGERUI_BLUEPRINT, name="native", url_prefix=NATIVE_PREFIX)
445+
app.register_blueprint(SWAGGERUI_BLUEPRINT, name="swagger", url_prefix=SWAGGER_ENDPOINT)
446+
app.register_blueprint(SWAGGERUI_BLUEPRINT, name="swagger_path", url_prefix=SWAGGER_ENDPOINT_PATH)
447447
if URL_PREFIX:
448448
app.register_blueprint(SWAGGERUI_BLUEPRINT,
449449
url_prefix='{}{}'.format(NATIVE_PREFIX, SWAGGER_ENDPOINT))
@@ -456,9 +456,9 @@ def generate_security_swagger_spec():
456456
blacklist = set() #pylint: disable=invalid-name
457457
jwt = JWTManager(app) #pylint: disable=invalid-name
458458

459-
@jwt.token_in_blacklist_loader
460-
def check_if_token_in_blacklist(decrypted_token):
461-
jti = decrypted_token['jti']
459+
@jwt.token_in_blocklist_loader
460+
def check_if_token_in_blacklist(jwt_header, jwt_data):
461+
jti = jwt_data['jti']
462462
return jti in blacklist
463463

464464
@jwt.invalid_token_loader
@@ -478,8 +478,8 @@ def unauthorized_loader(msg):
478478
}), 401
479479

480480
@jwt.expired_token_loader
481-
def my_expired_token_callback(expired_token):
482-
token_type = expired_token['type']
481+
def my_expired_token_callback(jwt_headers, jwt_payload):
482+
token_type = jwt_payload['type']
483483
return jsonify({
484484
'meta_data': {
485485
'message': 'The {} token has expired'.format(token_type),
@@ -488,7 +488,7 @@ def my_expired_token_callback(expired_token):
488488
}), 401
489489

490490
@jwt.revoked_token_loader
491-
def revoked_token_loader():
491+
def revoked_token_loader(jwt_header, jwt_payload):
492492
return jsonify({
493493
'meta_data': {
494494
'message': 'Revoked Token'
@@ -500,7 +500,7 @@ def jwt_required(fn): #pylint: disable=invalid-name, function-redefined
500500
def wrapper(*args, **kwargs):
501501
if ENABLE_SECURITY_LOGIN:
502502
if is_endpoint_protected(request.endpoint):
503-
verify_jwt_in_request()
503+
verify_jwt_in_request(refresh=False)
504504
return fn(*args, **kwargs)
505505
return wrapper
506506

@@ -509,12 +509,13 @@ def jwt_refresh_token_required(fn): #pylint: disable=invalid-name, function-rede
509509
def wrapper(*args, **kwargs):
510510
if ENABLE_SECURITY_LOGIN:
511511
if is_endpoint_protected(request.endpoint):
512-
verify_jwt_refresh_token_in_request()
512+
verify_jwt_in_request(refresh=True)
513513
return fn(*args, **kwargs)
514514
return wrapper
515515

516-
@jwt.user_loader_callback_loader
517-
def user_loader_callback(identity):
516+
@jwt.user_lookup_loader
517+
def user_loader_callback(jwt_header, jwt_data):
518+
identity = jwt_data['sub']
518519
if identity not in USERS_INFO:
519520
return None
520521
return UserAccess(
@@ -619,7 +620,7 @@ def logout_endpoint():
619620
resp = jsonify(body)
620621
return resp, 404
621622
try:
622-
jti = get_raw_jwt()['jti']
623+
jti = get_jwt()['jti']
623624
blacklist.add(jti)
624625
return jsonify({'meta_data': {'message' : 'Successfully logged out'}}), 200
625626
except Exception as ex:
@@ -644,7 +645,7 @@ def logout_refresh_token_endpoint():
644645
resp = jsonify(body)
645646
return resp, 404
646647
try:
647-
jti = get_raw_jwt()['jti']
648+
jti = get_jwt()['jti']
648649
blacklist.add(jti)
649650
resp = jsonify({'meta_data': {'message' : 'Successfully logged out'}})
650651
unset_jwt_cookies(resp)
@@ -835,7 +836,7 @@ def latest_report_endpoint():
835836
resp.status_code = 404
836837
return resp
837838

838-
project_report_latest_path = '/latest/{}'.format(REPORT_INDEX_FILE)
839+
project_report_latest_path = 'latest/{}'.format(REPORT_INDEX_FILE)
839840
url = url_for('get_reports_endpoint', project_id=project_id,
840841
path=project_report_latest_path, redirect='false', _external=True)
841842
return redirect(url)
@@ -1257,7 +1258,7 @@ def report_export_endpoint():
12571258
data,
12581259
mimetype='application/zip',
12591260
as_attachment=True,
1260-
attachment_filename='allure-docker-service-report.zip'
1261+
download_name='allure-docker-service-report.zip'
12611262
)
12621263
except Exception as ex:
12631264
body = {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#!/bin/bash
2-
python $ROOT/allure-docker-api/app.py
2+
python${PYTHON_VERSION} $ROOT/allure-docker-api/app.py

docker-custom/Dockerfile.bionic-custom

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@ ARG ALLURE_RELEASE=2.27.0
77
ARG ALLURE_REPO=https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline
88
ARG UID=1000
99
ARG GID=1000
10+
ARG PYTHON_VERSION=3.8
1011

1112
######
1213

13-
FROM python:3.6-alpine AS dev_stage
14+
FROM python:${PYTHON_VERSION}-alpine AS dev_stage
1415
RUN apk update
1516
RUN apk add build-base
1617
RUN pip install -U pylint
17-
RUN pip install -Iv setuptools==47.1.1 wheel==0.34.2 waitress==1.4.4 && \
18-
pip install -Iv Flask==1.1.2 Flask-JWT-Extended==3.24.1 flask-swagger-ui==3.36.0 requests==2.23.0
18+
RUN pip install --upgrade pip setuptools wheel waitress && \
19+
pip install -Iv Flask==3.0.2 Flask-JWT-Extended==4.6.0 flask-swagger-ui==4.11.1 requests==2.31.0
1920

2021
ENV ROOT_DIR=/code
2122
RUN mkdir -p $ROOT_DIR
@@ -34,6 +35,7 @@ ARG ALLURE_RELEASE
3435
ARG ALLURE_REPO
3536
ARG UID
3637
ARG GID
38+
ARG PYTHON_VERSION=3.8
3739

3840
LABEL org.label-schema.build-date=${BUILD_DATE} \
3941
org.label-schema.docker.dockerfile="docker-custom/Dockerfile.bionic-custom" \
@@ -47,18 +49,20 @@ LABEL org.label-schema.build-date=${BUILD_DATE} \
4749
org.label-schema.vcs-url="https://github.com/fescobar/allure-docker-service" \
4850
org.label-schema.arch=${ARCH} \
4951
authors="Frank Escobar <[email protected]>, Raymond Mouthaan <[email protected]>"
50-
5152
RUN apt-get update && \
53+
apt-get install -y software-properties-common && \
54+
add-apt-repository ppa:deadsnakes/ppa && \
55+
apt-get update && \
5256
apt-get install -y --no-install-recommends \
5357
tzdata \
5458
nano \
55-
python3 \
59+
python${PYTHON_VERSION} \
5660
python3-pip \
5761
unzip && \
5862
ln -s `which python3` /usr/bin/python && \
5963
pip3 install --upgrade pip && \
60-
pip install -Iv setuptools==47.1.1 wheel==0.34.2 waitress==1.4.4 && \
61-
pip install -Iv Flask==1.1.2 Flask-JWT-Extended==3.25.0 flask-swagger-ui==3.36.0 requests==2.23.0 && \
64+
python${PYTHON_VERSION} -m pip install --upgrade pip setuptools wheel waitress && \
65+
python${PYTHON_VERSION} -m pip install -v Flask==3.0.2 Flask-JWT-Extended==4.6.0 flask-swagger-ui==4.11.1 requests==2.31.0 && \
6266
curl ${ALLURE_REPO}/${ALLURE_RELEASE}/allure-commandline-${ALLURE_RELEASE}.zip -L -o /tmp/allure-commandline.zip && \
6367
unzip -q /tmp/allure-commandline.zip -d / && \
6468
apt-get remove -y unzip && \
@@ -70,6 +74,7 @@ RUN apt-get update && \
7074
RUN groupadd --gid ${GID} allure \
7175
&& useradd --uid ${UID} --gid allure --shell /bin/bash --create-home allure
7276

77+
ENV PYTHON_VERSION=${PYTHON_VERSION}
7378
ENV ROOT=/app
7479
ENV ALLURE_HOME=/allure-$ALLURE_RELEASE
7580
ENV ALLURE_HOME_SL=/allure

docker/Dockerfile.bionic

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,16 @@ ARG ALLURE_REPO=https://repo.maven.apache.org/maven2/io/qameta/allure/allure-com
88
ARG QEMU_ARCH
99
ARG UID=1000
1010
ARG GID=1000
11+
ARG PYTHON_VERSION=3.8
1112

1213
######
1314

14-
FROM python:3.6-alpine AS dev_stage
15+
FROM python:${PYTHON_VERSION}-alpine AS dev_stage
1516
RUN apk update
1617
RUN apk add build-base
1718
RUN pip install -U pylint
18-
RUN pip install -Iv setuptools==47.1.1 wheel==0.34.2 waitress==1.4.4 && \
19-
pip install -Iv Flask==1.1.2 Flask-JWT-Extended==3.24.1 flask-swagger-ui==3.36.0 requests==2.23.0
19+
RUN pip install --upgrade pip setuptools wheel waitress && \
20+
pip install -Iv Flask==3.0.2 Flask-JWT-Extended==4.6.0 flask-swagger-ui==4.11.1 requests==2.31.0
2021

2122
ENV ROOT_DIR=/code
2223
RUN mkdir -p $ROOT_DIR
@@ -36,6 +37,7 @@ ARG ALLURE_REPO
3637
ARG QEMU_ARCH
3738
ARG UID
3839
ARG GID
40+
ARG PYTHON_VERSION=3.8
3941

4042
LABEL org.label-schema.build-date=${BUILD_DATE} \
4143
org.label-schema.docker.dockerfile="docker/Dockerfile.bionic" \
@@ -54,17 +56,20 @@ LABEL org.label-schema.build-date=${BUILD_DATE} \
5456
COPY tmp/qemu-$QEMU_ARCH-static /usr/bin/qemu-$QEMU_ARCH-static
5557

5658
RUN apt-get update && \
59+
apt-get install -y software-properties-common && \
60+
add-apt-repository ppa:deadsnakes/ppa && \
61+
apt-get update && \
5762
apt-get install -y --no-install-recommends \
5863
tzdata \
5964
nano \
60-
python3 \
65+
python${PYTHON_VERSION} \
6166
python3-pip \
6267
python3-dev \
6368
unzip && \
6469
ln -s `which python3` /usr/bin/python && \
6570
pip3 install --upgrade pip && \
66-
pip install -Iv setuptools==47.1.1 wheel==0.34.2 waitress==1.4.4 && \
67-
pip install -Iv Flask==1.1.2 Flask-JWT-Extended==3.25.0 flask-swagger-ui==3.36.0 requests==2.23.0 && \
71+
python${PYTHON_VERSION} -m pip install --upgrade pip setuptools wheel waitress && \
72+
python${PYTHON_VERSION} -m pip install -v Flask==3.0.2 Flask-JWT-Extended==4.6.0 flask-swagger-ui==4.11.1 requests==2.31.0 && \
6873
curl ${ALLURE_REPO}/${ALLURE_RELEASE}/allure-commandline-${ALLURE_RELEASE}.zip -L -o /tmp/allure-commandline.zip && \
6974
unzip -q /tmp/allure-commandline.zip -d / && \
7075
apt-get remove -y unzip && \
@@ -76,6 +81,7 @@ RUN apt-get update && \
7681
RUN groupadd --gid ${GID} allure \
7782
&& useradd --uid ${UID} --gid allure --shell /bin/bash --create-home allure
7883

84+
ENV PYTHON_VERSION=${PYTHON_VERSION}
7985
ENV ROOT=/app
8086
ENV ALLURE_HOME=/allure-$ALLURE_RELEASE
8187
ENV ALLURE_HOME_SL=/allure

0 commit comments

Comments
 (0)