Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
dcbd582
Merge pull request #1 from SAP/master
chengshifan Nov 11, 2020
d69689a
enable redirect to origin page after login
chengshifan Nov 11, 2020
267b402
bug fixed
chengshifan Nov 11, 2020
8038339
bug fixed
chengshifan Nov 11, 2020
72da589
bug fixed
chengshifan Nov 11, 2020
3beedf9
python2 to python3
chengshifan Nov 16, 2020
6599326
python2 to python3 dockerfile change
chengshifan Nov 16, 2020
cdf9b8a
add decode and encode in registry-auth
chengshifan Nov 16, 2020
c29fbca
bug fixed
chengshifan Nov 16, 2020
4786114
bug fixed
chengshifan Nov 16, 2020
03cd528
bug fixed
chengshifan Nov 16, 2020
79d2a42
trigger job
chengshifan Nov 16, 2020
b50a601
try
chengshifan Nov 16, 2020
10ee16e
add decode
chengshifan Nov 16, 2020
8d2f4ee
add python3
chengshifan Nov 16, 2020
9b6d8d5
fixed issue
chengshifan Nov 18, 2020
6d2ead0
fixed issues
chengshifan Nov 18, 2020
b6b073d
fixed problems
chengshifan Nov 18, 2020
2289401
fixed problems
chengshifan Nov 18, 2020
5ebc373
fixed problems
chengshifan Nov 18, 2020
13d5f15
fixed problems
chengshifan Nov 18, 2020
70fc6d9
fix test utils
iberryful Nov 19, 2020
0554812
Merge pull request #2 from iberryful/py2-3
chengshifan Nov 19, 2020
9fc1653
fix assert exception
iberryful Nov 20, 2020
85b8816
fix test get headers
iberryful Nov 20, 2020
a31b04b
fix base64 encode
iberryful Nov 20, 2020
fb7751a
Merge pull request #3 from iberryful/py2-3
chengshifan Nov 20, 2020
07baa46
fix github-review test
iberryful Nov 20, 2020
83c6982
fix github-review test
iberryful Nov 20, 2020
467fff3
remove unused code
chengshifan Nov 20, 2020
a4bf7e8
Merge pull request #4 from iberryful/py2-3
chengshifan Nov 20, 2020
1b02f34
change base image for e2e test
chengshifan Nov 20, 2020
bd455dd
set pip as pip3
chengshifan Nov 20, 2020
37b2c5f
add `helm repo update`
chengshifan Nov 20, 2020
7ee2e83
Merge branch 'master' into master
chengshifan Nov 20, 2020
3c653fe
remove `helm repo update`
chengshifan Nov 20, 2020
3a3cf57
set python as python3
chengshifan Nov 20, 2020
6092bc5
set pip as pip3
chengshifan Nov 20, 2020
cd5b7ee
replace jwt with pyjwt
chengshifan Nov 23, 2020
01fb5c8
remove tab
chengshifan Nov 25, 2020
699d52c
remove useless parenthesis
chengshifan Nov 25, 2020
517c6cf
fix(integration-test): fix rsa public key path
iberryful Nov 26, 2020
b251e9e
fix(integration-test): fix rsa public key path
iberryful Nov 26, 2020
f17bba7
fix(integration-test): fix rsa public key path
iberryful Nov 26, 2020
e4d49bc
Merge pull request #7 from iberryful/py2-3
iberryful Nov 26, 2020
4742792
remove `apt-get remove/autoremove` & `rm -rf`
chengshifan Nov 26, 2020
310b59b
rename python to python3
chengshifan Nov 27, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions infrabox/generator/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM alpine:3.6

RUN apk add --no-cache python2
RUN apk add --no-cache python3

COPY infrabox/generator /generator

CMD python /generator/generator.py
CMD python3 /generator/generator.py
3 changes: 3 additions & 0 deletions infrabox/test-registry/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ FROM quay.io/infrabox/images-test:build_$INFRABOX_BUILD_NUMBER

ENV PYTHONPATH=/

ENV LC_ALL=C.UTF-8
ENV LANG=C.UTF-8

COPY infrabox/test-registry/ /test/
COPY infrabox/test/utils/id_rsa /var/run/secrets/infrabox.net/rsa/id_rsa
COPY src/utils/wait-for-webserver.sh /wait-for-webserver.sh
Expand Down
2 changes: 1 addition & 1 deletion infrabox/test-registry/Dockerfile_auth
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ COPY src/pyinfraboxutils /pyinfraboxutils
COPY src/pyinfrabox /pyinfrabox
COPY infrabox/test/utils/id_rsa.pub /var/run/secrets/infrabox.net/rsa/id_rsa.pub

CMD python /server.py
CMD python3 /server.py
5 changes: 3 additions & 2 deletions infrabox/test-registry/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@

class InputTests(TestCase):
def get(self, url, password='b514af82-3c4f-4bb5-b1da-a89a0ced5e6f'):
auth = base64.b64encode('infrabox:%s' % encode_project_token(password, '2514af82-3c4f-4bb5-b1da-a89a0ced5e6f', 'myproject'))
basic = 'infrabox:%s' % encode_project_token(password, '2514af82-3c4f-4bb5-b1da-a89a0ced5e6f', 'myproject')
auth = base64.b64encode(basic.encode('utf-8')).decode('utf-8')
headers = {'authorization': "Basic " + auth}
return requests.get(url, headers=headers)

Expand All @@ -34,7 +35,7 @@ class Test(TestCase):
image_path = project_id + '/image_name'

def _get_headers(self):
auth = base64.b64encode('infrabox:%s' % encode_project_token(self.token, self.project_id, 'myproject'))
auth = base64.b64encode(('infrabox:%s' % encode_project_token(self.token, self.project_id, 'myproject')).encode('utf-8')).decode('utf-8')
headers = {'authorization': "Basic " + auth}
return headers

Expand Down
2 changes: 1 addition & 1 deletion infrabox/test/collector-api/temp_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def get(url, headers): # pragma: no cover
r = TestClient.app.get(url, headers=headers)

if r.mimetype == 'application/json':
j = json.loads(r.data)
j = json.loads(r.data.decode('utf-8'))
return j

return r
Expand Down
24 changes: 15 additions & 9 deletions infrabox/test/e2e/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
FROM ubuntu:18.04
FROM ubuntu:20.04

ENV DEBIAN_FRONTEND=noninteractive
ARG HELM_VERSION=2.12.3

RUN apt-get update -y && apt-get install -y \
curl \
python-pip \
pkg-config \
libpq-dev \
python3-dev \
python3-pip \
postgresql-client \
python-xmlrunner \
python-requests \
python-psycopg2 \
python-jwt \
python-crypto \
python-cryptography \
git
python3-crypto \
python3-cryptography \
git \
&& pip3 install \
xmlrunner \
requests==2.18.4 \
psycopg2 \
PyJWT

RUN mkdir /project
WORKDIR /project
Expand Down
9 changes: 6 additions & 3 deletions infrabox/test/e2e/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ _getDependencies() {
# pip install infraboxcli
git clone https://github.com/SAP/InfraBox-cli.git /cli
pushd /cli
pip install -e .
pip3 install -e .
infrabox version
git rev-parse HEAD
popd
Expand Down Expand Up @@ -139,12 +139,15 @@ _installNginxIngress() {
_installInfrabox() {
cd /infrabox/context/deploy/infrabox

ssh-keygen -N '' -t rsa -f id_rsa
ssh-keygen -N '' -t rsa -m pem -f id_rsa
ssh-keygen -f id_rsa.pub -e -m pem > id_rsa.pem

mkdir -p /var/run/secrets/infrabox.net/rsa/
cp id_rsa* /var/run/secrets/infrabox.net/rsa/

export INFRABOX_RSA_PRIVATE_KEY_PATH=/var/run/secrets/infrabox.net/rsa/id_rsa
export INFRABOX_RSA_PUBLIC_KEY_PATH=/var/run/secrets/infrabox.net/rsa/id_rsa.pem

echo "## Install infrabox"

PW=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
Expand Down Expand Up @@ -198,7 +201,7 @@ _runTests() {
pushd /infrabox/context/infrabox/test/e2e

set +e
python test.py
python3 test.py
rc=$?

cp results.xml /infrabox/upload/testresult
Expand Down
15 changes: 12 additions & 3 deletions infrabox/test/github-review/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,12 @@ def side_effect(_1, _2, _3):

requests_post.assert_called_with(
'status_url',
data='{"state": "pending", "target_url": "GITHUB_URL/dashboard/#/project/projectname/build/123/123/job/jobname", "description": "%s", "context": "Job: jobname"}' % ("project_id:%s job_id:%s" % (self.job_data['project_id'], self.job_data['id']) ),
json={
"target_url": "GITHUB_URL/dashboard/#/project/projectname/build/123/123/job/jobname",
"state": "pending",
"context": "Job: jobname",
"description": "project_id:%s job_id:%s" % (self.job_data['project_id'], self.job_data['id'])
},
headers={'Authorization': 'token token', 'User-Agent': 'InfraBox'},
timeout=10,
verify=False)
Expand All @@ -149,10 +154,14 @@ def side_effect(_1, _2, _3):

execute_sql.side_effect = side_effect
handle_job_update(None, self.event)
data = '{"state": "%s", "target_url": "GITHUB_URL/dashboard/#/project/projectname/build/123/123/job/jobname", "description": "%s", "context": "Job: jobname"}' % (self.expected_github_status, "project_id:%s job_id:%s" % (self.job_data['project_id'], self.job_data['id']))
requests_post.assert_called_with(
'status_url',
data=data,
json={
"target_url": "GITHUB_URL/dashboard/#/project/projectname/build/123/123/job/jobname",
"context": "Job: jobname",
"state": self.expected_github_status,
"description": "project_id:%s job_id:%s" % (self.job_data['project_id'], self.job_data['id'])
},
headers={'Authorization': 'token token',
'User-Agent': 'InfraBox'},
timeout=10,
Expand Down
8 changes: 4 additions & 4 deletions infrabox/test/registry-auth/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ def test_header_invalid_token(self):
self.assertEqual(r['status'], 401)

def test_header_no_password(self):
h = {'Authorization': 'Basic %s' % base64.b64encode('infrabox')}
h = {'Authorization': 'Basic %s' % base64.b64encode('infrabox'.encode("utf-8"))}
r = self.get('/v2', h)
self.assertEqual(r['status'], 401)

def test_header_no_password_2(self):
h = {'Authorization': 'Basic %s' % base64.b64encode('infrabox:2')}
h = {'Authorization': 'Basic %s' % base64.b64encode('infrabox:2'.encode("utf-8"))}
r = self.get('/v2', h)
self.assertEqual(r['status'], 401)

Expand Down Expand Up @@ -121,7 +121,7 @@ def get_project_headers(self, project_token=None): # pragma: no cover
project_token = self.project_token

token = encode_project_token(project_token, self.project_id, 'myproject')
h = {'Authorization': 'Basic %s' % base64.b64encode('infrabox:%s' % token)}
h = {'Authorization': 'Basic %s' % base64.b64encode(('infrabox:%s' % token).encode("utf-8")).decode('utf-8')}
return h

def get(self, url, headers=None, method='GET'): # pragma: no cover
Expand All @@ -131,7 +131,7 @@ def get(self, url, headers=None, method='GET'): # pragma: no cover
r = self.app.get(url, headers=headers)

if r.mimetype == 'application/json':
return json.loads(r.data)
return json.loads(r.data.decode('utf-8'))

return r

Expand Down
2 changes: 1 addition & 1 deletion src/api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ COPY src/openpolicyagent /infrabox/openpolicyagent
COPY src/pyinfraboxutils /infrabox/pyinfraboxutils
COPY src/pyinfrabox /infrabox/pyinfrabox

CMD python /infrabox/api/server.py
CMD python3 /infrabox/api/server.py
4 changes: 2 additions & 2 deletions src/api/handlers/account/saml.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from urlparse import urlparse
from urllib.parse import urlparse

from flask import g, request, abort, redirect, make_response

Expand Down Expand Up @@ -36,7 +36,7 @@ def init_saml_auth():
def get_attribute_dict(saml_auth):
attributes = {}
nested_attribute_dict = saml_auth.get_attributes()
for attribute_name, nested_attribute in nested_attribute_dict.items():
for attribute_name, nested_attribute in list(nested_attribute_dict.items()):
if len(nested_attribute) > 0:
attributes[attribute_name] = nested_attribute[0]
attributes["NameID"] = saml_auth.get_nameid()
Expand Down
2 changes: 1 addition & 1 deletion src/api/handlers/admin/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def get(self):
result[j['name']]['jobs'] = j['cnt']

response = []
for _, v in result.iteritems():
for _, v in result.items():
response.append(v)

return response
20 changes: 10 additions & 10 deletions src/api/handlers/job_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import json
import uuid
import copy
import urllib
import urllib.request, urllib.parse, urllib.error
import random
from datetime import datetime
from io import BytesIO
Expand Down Expand Up @@ -344,8 +344,8 @@ def get_secret(name):
root_url = get_root_url("global")

# Default env vars
project_name = urllib.quote_plus(data['project']['name']).replace('+', '%20')
job_name = urllib.quote_plus(data['job']['name']).replace('+', '%20')
project_name = urllib.parse.quote_plus(data['project']['name']).replace('+', '%20')
job_name = urllib.parse.quote_plus(data['job']['name']).replace('+', '%20')
build_url = "%s/dashboard/#/project/%s/build/%s/%s" % (root_url,
project_name,
data['build']['build_number'],
Expand Down Expand Up @@ -390,14 +390,14 @@ def get_secret(name):
data['env_vars']['INFRABOX_GITHUB_PULL_REQUEST'] = "true"

if env_vars:
for name, value in env_vars.iteritems():
for name, value in env_vars.items():
try:
data['env_vars'][name] = str(value)
except UnicodeEncodeError:
data['env_vars'][name] = value.encode('utf-8')

if env_var_refs:
for name, value in env_var_refs.iteritems():
for name, value in env_var_refs.items():
secret = get_secret(value)

if secret is None:
Expand Down Expand Up @@ -467,7 +467,7 @@ def post(self):
project_id = g.token['project']['id']
job_name = g.token['job']['name']

for f, _ in request.files.items():
for f, _ in list(request.files.items()):
template = 'project_%s_job_%s_%s'
key = template % (project_id, job_name, f)
key = key.replace('/', '_')
Expand Down Expand Up @@ -520,7 +520,7 @@ class Output(Resource):
def post(self):
job_id = g.token['job']['id']

for f, _ in request.files.items():
for f, _ in list(request.files.items()):
key = "%s/%s" % (job_id, f)

stream = request.files[f].stream
Expand Down Expand Up @@ -942,7 +942,7 @@ def post(self):
stats = request.json['stats']
s = 0
c = 0
for _, values in stats.items():
for _, values in list(stats.items()):
for v in values:
c += 1
s += v['cpu']
Expand Down Expand Up @@ -1000,7 +1000,7 @@ def _remove_file(response):
delete_file(path)
return response

for name, f in request.files.iteritems():
for name, f in request.files.items():
try:
if not allowed_file(f.filename, ("json",)):
abort(400, "Filetype not allowed")
Expand Down Expand Up @@ -1049,7 +1049,7 @@ def _remove_file(response):
delete_file(path)
return response

for _, f in request.files.iteritems():
for _, f in request.files.items():
if not allowed_file(f.filename, ("json")):
abort(400, "Filetype not allowed")

Expand Down
10 changes: 5 additions & 5 deletions src/api/handlers/project.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import uuid
import urllib
import urllib.request, urllib.parse, urllib.error
import os
import json
import mimetypes
Expand Down Expand Up @@ -49,16 +49,16 @@ def no_cache(*args, **kwargs):
return update_wrapper(no_cache, view)

def get_badge(subject, status, color):
subject = urllib.quote(subject)
status = urllib.quote(status)
color = urllib.quote(color)
subject = urllib.parse.quote(subject)
status = urllib.parse.quote(status)
color = urllib.parse.quote(color)

url = 'https://img.shields.io/static/v1.svg?label=%s&message=%s&color=%s' % (subject, status, color)

resp = requests.get(url)

excluded_headers = ['content-encoding', 'content-length', 'transfer-encoding', 'connection']
headers = [(name, value) for (name, value) in resp.raw.headers.items()
headers = [(name, value) for (name, value) in list(resp.raw.headers.items())
if name.lower() not in excluded_headers]

return Response(resp.content, resp.status_code, headers)
Expand Down
2 changes: 1 addition & 1 deletion src/api/run_dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ sigint_handler()
trap sigint_handler SIGINT

while true; do
python $DIR/server.py &
python3 $DIR/server.py &
PID=$!
inotifywait -e modify -e move -e create --exclude='.*__pycache__.*' -r $watch
kill $PID
Expand Down
2 changes: 1 addition & 1 deletion src/api/run_with_dummy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@ export INFRABOX_LEGAL_PRIVACY_URL=https://www.sap.com/about/legal/privacy.html
export INFRABOX_LEGAL_TERMS_OF_USE_URL=https://www.sap.com/corporate/en/legal/terms-of-use.html


python server.py
python3 server.py
2 changes: 1 addition & 1 deletion src/checker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ COPY src/pyinfraboxutils /pyinfraboxutils

ENV PYTHONPATH=/

ENTRYPOINT ["python", "checker/checker.py"]
ENTRYPOINT ["python3", "checker/checker.py"]
2 changes: 1 addition & 1 deletion src/cluster-status/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ COPY src/pyinfrabox /pyinfrabox

ENV PYTHONPATH=/

CMD python /server.py
CMD python3 /server.py
2 changes: 1 addition & 1 deletion src/collector-api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ COPY src/collector-api /collector
COPY src/pyinfraboxutils /pyinfraboxutils
COPY src/pyinfrabox /pyinfrabox

CMD python /collector/server.py
CMD python3 /collector/server.py
2 changes: 1 addition & 1 deletion src/db/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ COPY src/pyinfraboxutils /pyinfraboxutils

ENV PYTHONPATH=/

CMD python db/migrate.py
CMD python3 db/migrate.py
2 changes: 1 addition & 1 deletion src/docker-registry/auth/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ COPY src/pyinfrabox /pyinfrabox

ENV PYTHONPATH=/

CMD python /server.py
CMD python3 /server.py
4 changes: 2 additions & 2 deletions src/docker-registry/nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM nginx:1.15-alpine
RUN apk add --no-cache curl python py-pip openssl && \
pip install htpasswd && \
RUN apk add --no-cache curl python3 py-pip openssl && \
pip3 install htpasswd && \
apk del py-pip

COPY src/docker-registry/nginx/nginx.conf /etc/nginx/nginx.conf
Expand Down
2 changes: 1 addition & 1 deletion src/docker-registry/nginx/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh -e

HTPASSWD_PATH=/home/nginx/nginx.htpasswd python get_admin_pw.py
HTPASSWD_PATH=/home/nginx/nginx.htpasswd python3 get_admin_pw.py

sed -i -e "s/auth-host-placeholder/$INFRABOX_AUTH_HOST/g" /etc/nginx/nginx.conf
sed -i -e "s/registry-host-placeholder/$INFRABOX_REGISTRY_HOST/g" /etc/nginx/nginx.conf
Expand Down
2 changes: 1 addition & 1 deletion src/docker-registry/nginx/get_admin_pw.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@
with htpasswd.Basic(os.environ['HTPASSWD_PATH'], mode="md5") as userdb:
try:
userdb.add(admin_user, admin_password)
except htpasswd.basic.UserExists, e:
except htpasswd.basic.UserExists as e:
print(e)
Loading