Skip to content

Commit 160ccb2

Browse files
author
James Fuqian
authored
[BB2-1283, BB2-1313] Django Upgrade 2.2.28 to 3.2.13 Python37 (#1027)
* first cut p37 django upgrade * missed whl * pip upgrade in CI docker. * remove source dist for cryptography-37.0.2.tar.gz * store the custom migration sql scripts to be handy on the target EC2 * pip upgrade on CI docker venv. * pip install cryptography==37.0.2 * fix LGTM encoding warning in source code text. * manually provision cryptography-37.0.2-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl(the binary used on CI docker) in vendor folder. * added debugging and tracing.. * added debugging and tracing.. * fix dotenv import ... * clean up. * bump django to 3.2.14 to address C vuln CVE-2022-34265 * bump django_storages from 1.7.1 to 1.12.3 to resolve django.util.six reference. * restore base settings DEBUG flag setting. * change Django DEBUG flag default to False - to be safer.
1 parent 9e823f1 commit 160ccb2

File tree

163 files changed

+1282
-1092
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

163 files changed

+1282
-1092
lines changed

Dockerfile.selenium

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ FROM selenium/standalone-chrome-debug
22

33
ENV PYTHONUNBUFFERED 1
44
USER root
5-
RUN apt-get update && apt-get install -yq python3.8 python3-pip git
6-
RUN pip3 install --upgrade pip
7-
RUN pip3 install selenium psycopg2-binary==2.8.6 pyyaml==5.4.1 Pillow==9.0.1
5+
# libpq-dev: ubuntu dev lib for psypsycopg2 sdist build
6+
RUN apt-get update && apt-get install -yq python3.7 python3-pip git libpq-dev libffi-dev
87
RUN mkdir /code
98
ADD . /code/
109
WORKDIR /code
10+
RUN ln -s /usr/bin/python3 /usr/local/bin/python
11+
RUN pip install --upgrade pip
12+
RUN pip install selenium
13+
RUN pip install pyyaml==6.0 Pillow==9.0.1
1114
RUN make reqs-install-dev
12-
RUN ln -s /usr/bin/python3 /usr/local/bin/python

Dockerfiles/Dockerfile.selenium-jenkins

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ RUN mkdir /code
77
ADD . /code/
88
WORKDIR /code
99

10+
RUN pip install --upgrade pip
11+
1012
RUN apt-get update && apt-get install -yq git unzip curl
1113

1214
# Install Chrome for Selenium

Jenkinsfiles/Jenkinsfile.cbc-run-multi-pr-checks

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ pipeline {
3636
sh """
3737
python -m venv venv
3838
. venv/bin/activate
39+
pip install --upgrade pip
3940
make reqs-install-dev
4041
"""
4142
}

Jenkinsfiles/Jenkinsfile.cbc-run-multi-pr-checks-w-selenium

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
pipeline {
22
agent {
33
kubernetes {
4-
defaultContainer "bb2-cbc-build-selenium"
4+
defaultContainer "bb2-cbc-build-selenium-django32"
55
yamlFile "Jenkinsfiles/cbc-pod-deployment-config-w-selenium.yaml"
66
}
77
}
@@ -55,8 +55,9 @@ pipeline {
5555
sh """
5656
python -m venv venv
5757
. venv/bin/activate
58-
make reqs-install-dev
5958
pip install selenium
59+
pip install cryptography==37.0.2
60+
make reqs-install-dev
6061
"""
6162
}
6263
}

Jenkinsfiles/cbc-pod-deployment-config-w-selenium.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ apiVersion: v1
22
kind: Pod
33
spec:
44
containers:
5-
- name: bb2-cbc-build-selenium
6-
image: "public.ecr.aws/f5g8o1y9/bb2-cbc-build-selenium:latest"
5+
- name: bb2-cbc-build-selenium-django32
6+
image: "public.ecr.aws/f5g8o1y9/bb2-cbc-build-selenium-django32:latest"
77
tty: true
88
command: ["tail", "-f"]
99
imagePullPolicy: Always

apps/accounts/tests/test_case_ins_username.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
from django.contrib.auth.models import User
2+
from django.http import HttpRequest
13
from django.test import TestCase
24
from django.test.client import Client
3-
from django.contrib.auth.models import User
45
from django.urls import reverse
6+
57
from ..models import UserProfile
68

79

@@ -22,13 +24,15 @@ def setUp(self):
2224
self.client = Client()
2325

2426
def test_page_loads(self):
25-
self.client.login(username="fred@example.com", password="foobar")
27+
request = HttpRequest()
28+
self.client.login(request=request, username="fred@example.com", password="foobar")
2629
url = reverse('account_settings')
2730
response = self.client.get(url, follow=True)
2831
self.assertEqual(response.status_code, 200)
2932

3033
def test_all_fields_required(self):
31-
self.client.login(username="fred@example.com", password="foobar")
34+
request = HttpRequest()
35+
self.client.login(request=request, username="fred@example.com", password="foobar")
3236
url = reverse('account_settings')
3337
form_data = {'username': '',
3438
'email': 'fred@example.com',
@@ -41,7 +45,8 @@ def test_all_fields_required(self):
4145
self.assertContains(response, 'This field is required.')
4246

4347
def test_username_forced_to_lower(self):
44-
self.client.login(username="fred@example.com", password="foobar")
48+
request = HttpRequest()
49+
self.client.login(request=request, username="fred@example.com", password="foobar")
4550
url = reverse('account_settings')
4651
form_data = {'username': 'FRED@Example.com',
4752
'email': 'fred@example.com',

apps/accounts/tests/test_create_account.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ def test_valid_account_create(self):
4242
'last_name': 'Rubble',
4343
'identification_choice': str(ident_choice.pk),
4444
}
45+
4546
response = self.client.post(self.url, form_data, follow=True)
4647

4748
self.assertEqual(response.status_code, 200)

apps/accounts/tests/test_enduser_cannot_reach_standard_admin_login.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from django.http import HttpRequest
12
from django.test import TestCase
23
from django.contrib.auth.models import User
34
from django.test.client import Client
@@ -27,7 +28,8 @@ def setUp(self):
2728
user = User.objects.get(username='fred')
2829
UserProfile.objects.create(user=user)
2930
self.client = Client()
30-
self.client.login(username='fred', password='bedrocks')
31+
request = HttpRequest()
32+
self.client.login(request=request, username='fred', password='bedrocks')
3133
self.url = reverse('admin:login')
3234

3335
def test_standard_user_cannot_reach_admin_login(self):

apps/accounts/tests/test_login.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ def test_valid_login_case_insensitive_username(self):
6767
def test_invalid_login(self):
6868
"""
6969
Invalid user cannot login
70+
Django upgrade 3.2:
71+
Now AXES gives warning as shown below:
72+
AXES: New login failure by
73+
{username: "fred", ip_address: "127.0.0.1", user_agent: "<unknown>", path_info: "/v1/accounts/login"}.
74+
Created new record in the database
7075
"""
7176
form_data = {'username': 'fred', 'password': 'dino'}
7277
response = self.client.post(self.url, form_data, follow=True)

apps/accounts/tests/test_password_reset_while_authenticated.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import time
22
from django.contrib.auth.models import User
3+
from django.http import HttpRequest
34
from django.test import TestCase
45
from django.test.client import Client
56
from django.urls import reverse
@@ -50,7 +51,8 @@ def setUp(self):
5051

5152
@override_switch('login', active=True)
5253
def test_page_loads(self):
53-
self.client.login(username="fred", password="foobarfoobarfoobar")
54+
request = HttpRequest()
55+
self.client.login(request=request, username="fred", password="foobarfoobarfoobar")
5456
url = reverse('password_change')
5557
response = self.client.get(url, follow=True)
5658
self.assertEqual(response.status_code, 200)
@@ -63,7 +65,8 @@ def test_page_requires_authentication(self):
6365

6466
@override_switch('login', active=True)
6567
def test_password_ischanged(self):
66-
self.client.login(username="fred", password="foobarfoobarfoobar")
68+
request = HttpRequest()
69+
self.client.login(request=request, username="fred", password="foobarfoobarfoobar")
6770
url = reverse('password_change')
6871
form_data = {'old_password': 'foobarfoobarfoobar',
6972
'new_password1': 'IchangedTHEpassword#123',
@@ -78,7 +81,8 @@ def test_password_ischanged(self):
7881

7982
@override_switch('login', active=True)
8083
def test_password_change_complexity_and_min_age_validation(self):
81-
self.client.login(username="fred", password="foobarfoobarfoobar")
84+
request = HttpRequest()
85+
self.client.login(request=request, username="fred", password="foobarfoobarfoobar")
8286
url = reverse('password_change')
8387
# sleep 3 sec to let min password age of 3 sec elapse
8488
time.sleep(3)
@@ -115,7 +119,8 @@ def test_password_change_complexity_and_min_age_validation(self):
115119

116120
@override_switch('login', active=True)
117121
def test_password_change_reuse_validation(self):
118-
self.client.login(username="fred", password="foobarfoobarfoobar")
122+
request = HttpRequest()
123+
self.client.login(request=request, username="fred", password="foobarfoobarfoobar")
119124
url = reverse('password_change')
120125

121126
# first password change

0 commit comments

Comments
 (0)