From 0da675a8a4df5a78a4b88eb3f45c738a71363109 Mon Sep 17 00:00:00 2001 From: Brady-Malott Date: Mon, 13 Feb 2023 20:05:05 -0500 Subject: [PATCH 001/106] Created Jenkinsfile for building app --- Jenkinsfile | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..09515e1 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,20 @@ +pipeline { + agent { dockerfile true } + + stages { + + stage('Checkout') { + steps { + checkout scm + } + } + + stage('Build') { + steps { + sh 'docker build -t microblog:latest .' + } + } + + } + +} From 7ee7662d0532c1d4bde3cdf25e34a41a1512afe0 Mon Sep 17 00:00:00 2001 From: Brady-Malott Date: Mon, 13 Feb 2023 20:29:34 -0500 Subject: [PATCH 002/106] jenkinsfile test --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 09515e1..816aec7 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,5 +1,5 @@ pipeline { - agent { dockerfile true } + agent any stages { From 5d8090807cd2ec880a8cafef6a87dcbf66b774c2 Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Mon, 13 Feb 2023 20:40:41 -0500 Subject: [PATCH 003/106] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 816aec7..53d5710 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -11,7 +11,7 @@ pipeline { stage('Build') { steps { - sh 'docker build -t microblog:latest .' + sh 'sudo docker build -t microblog:latest .' } } From b6245541250a00cef2c28b03525dd637c9ce3009 Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Mon, 13 Feb 2023 21:25:55 -0500 Subject: [PATCH 004/106] Update Jenkinsfile --- Jenkinsfile | 7 ------- 1 file changed, 7 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 53d5710..6625a27 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,13 +2,6 @@ pipeline { agent any stages { - - stage('Checkout') { - steps { - checkout scm - } - } - stage('Build') { steps { sh 'sudo docker build -t microblog:latest .' From 8e5f47cb5eb653cff94702611b76323b9dd9d1f0 Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Mon, 13 Feb 2023 21:29:29 -0500 Subject: [PATCH 005/106] Update Jenkinsfile --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 6625a27..a742e73 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,10 +1,10 @@ pipeline { - agent any + agent { dockerfile true } stages { stage('Build') { steps { - sh 'sudo docker build -t microblog:latest .' + sh 'echo building...' } } From d5c9f7cc2f59a001d7b6ccebb02a4b8edd804863 Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Mon, 13 Feb 2023 21:45:26 -0500 Subject: [PATCH 006/106] Update Jenkinsfile --- Jenkinsfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index a742e73..40da509 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,10 +1,11 @@ pipeline { - agent { dockerfile true } + agent any stages { stage('Build') { steps { sh 'echo building...' + sh 'docker run -p 5000:5000 microblog:latest' } } From 71d12a1f76b9773844b72a417296d7888f7d2aa5 Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Mon, 13 Feb 2023 21:49:34 -0500 Subject: [PATCH 007/106] Update Jenkinsfile --- Jenkinsfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 40da509..ea37cb6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,8 +4,10 @@ pipeline { stages { stage('Build') { steps { - sh 'echo building...' - sh 'docker run -p 5000:5000 microblog:latest' + node { + checkout scm + def customImage = docker.build("microblog:latest") + } } } From 608da55115e8cc9b5c5c1501177ac61427f29322 Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Mon, 13 Feb 2023 21:52:15 -0500 Subject: [PATCH 008/106] Update Jenkinsfile --- Jenkinsfile | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index ea37cb6..d987a89 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,16 +1,5 @@ -pipeline { - agent any - - stages { - stage('Build') { - steps { - node { - checkout scm - def customImage = docker.build("microblog:latest") - } - } - } - - } +node { + checkout scm + def customImage = docker.build("microblog:latest") } From 1cf62091f39ad98b32bfed575d75c8d98aa8d164 Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Wed, 15 Feb 2023 16:05:59 -0500 Subject: [PATCH 009/106] Updated greenlet version --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index d27db7e..ba67d17 100644 --- a/requirements.txt +++ b/requirements.txt @@ -18,7 +18,7 @@ Flask-Migrate==3.0.1 Flask-Moment==1.0.1 Flask-SQLAlchemy==2.5.1 Flask-WTF==0.15.1 -greenlet==1.1.0 +greenlet==2.0.2 httpie==2.4.0 idna==2.10 itsdangerous==2.0.1 From 2e7b6ec891bbc10b1cd08a0ebcf470eb4b5d5665 Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Fri, 17 Feb 2023 00:22:43 -0500 Subject: [PATCH 010/106] Update Jenkinsfile --- Jenkinsfile | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index d987a89..a917524 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,5 +1,9 @@ -node { - checkout scm - - def customImage = docker.build("microblog:latest") +pipeline { + agent any + + stages { + stage('Build') { + sh 'docker build -t microblog:latest .' + } + } } From 914225e3142e80fa277b5f834fe7c98ff53bed81 Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Fri, 17 Feb 2023 00:24:13 -0500 Subject: [PATCH 011/106] Update Jenkinsfile --- Jenkinsfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index a917524..10e8a4d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -3,7 +3,9 @@ pipeline { stages { stage('Build') { - sh 'docker build -t microblog:latest .' + steps { + sh 'docker build -t microblog:latest .' + } } } } From dd7557f1ba8dc958ca1cd27e0b4b294cb2cc1535 Mon Sep 17 00:00:00 2001 From: Jarrett Jackson Date: Fri, 17 Feb 2023 01:35:41 -0500 Subject: [PATCH 012/106] Updated Jenkinsfile Added pipeline for discord-notifier plugin --- Jenkinsfile | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 10e8a4d..ac750e5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -7,5 +7,12 @@ pipeline { sh 'docker build -t microblog:latest .' } } + stage("Hello To Discord") { + steps { + echo ' Test to Discord' + discordSend description: '', footer: '', image: '', link: 'http://3.91.14.163:8080', result: '', scmWebUrl: '', thumbnail: '', title: + 'HelloToDiscordTest', webhookURL: 'https://discord.com/api/webhooks/1075879011667955872/Nk0gmKZkrISEs-hru-HjtzzgezWweABCdPsOKGIzkmj5xMcqKC3m1-dx7GZSu0yURAOo' + } + } } } From 35f6ed607af16fac09fe3982938c46e6fb5f56c0 Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Fri, 17 Feb 2023 17:34:05 -0500 Subject: [PATCH 013/106] Update Jenkinsfile --- Jenkinsfile | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index ac750e5..6341189 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -7,7 +7,15 @@ pipeline { sh 'docker build -t microblog:latest .' } } - stage("Hello To Discord") { + stage('Deploy') { + steps { + // Stop running microblog container + sh 'docker stop $(docker ps -q --filter ancestor=microblog:latest)' + // Deploy new container + sh 'docker run -d -p 5000:5000 microblog:latest + } + } + stage('Hello To Discord') { steps { echo ' Test to Discord' discordSend description: '', footer: '', image: '', link: 'http://3.91.14.163:8080', result: '', scmWebUrl: '', thumbnail: '', title: From fbbaefacbb3f2c6289662f0e5eae76068383e6f1 Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Fri, 17 Feb 2023 17:34:56 -0500 Subject: [PATCH 014/106] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 6341189..5f514da 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -12,7 +12,7 @@ pipeline { // Stop running microblog container sh 'docker stop $(docker ps -q --filter ancestor=microblog:latest)' // Deploy new container - sh 'docker run -d -p 5000:5000 microblog:latest + sh 'docker run -d -p 5000:5000 microblog:latest' } } stage('Hello To Discord') { From 53b17efde5eee08465603f01a58491a78d950c47 Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Fri, 17 Feb 2023 17:37:46 -0500 Subject: [PATCH 015/106] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 5f514da..d64e4e0 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -10,7 +10,7 @@ pipeline { stage('Deploy') { steps { // Stop running microblog container - sh 'docker stop $(docker ps -q --filter ancestor=microblog:latest)' + sh 'docker ps -q --filter ancestor=microblog:latest | docker stop' // Deploy new container sh 'docker run -d -p 5000:5000 microblog:latest' } From e77137b0d0d93a31280307e4a3ee641411c10240 Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Fri, 17 Feb 2023 17:40:09 -0500 Subject: [PATCH 016/106] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index d64e4e0..bf5f403 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -10,7 +10,7 @@ pipeline { stage('Deploy') { steps { // Stop running microblog container - sh 'docker ps -q --filter ancestor=microblog:latest | docker stop' + sh 'echo $(docker ps -q --filter ancestor=microblog:latest) | docker stop' // Deploy new container sh 'docker run -d -p 5000:5000 microblog:latest' } From 69c31ec36d88bf8a80c121d9c81f76404696c18f Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Fri, 17 Feb 2023 17:48:16 -0500 Subject: [PATCH 017/106] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index bf5f403..35df4d6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -10,7 +10,7 @@ pipeline { stage('Deploy') { steps { // Stop running microblog container - sh 'echo $(docker ps -q --filter ancestor=microblog:latest) | docker stop' + sh 'if [[ $(docker ps -q --filter ancestor=microblog:latest | wc -l) == 0 ]]; then docker stop $(docker ps -q --filter ancestor=microblog:latest) fi' // Deploy new container sh 'docker run -d -p 5000:5000 microblog:latest' } From bb4f23e39710e4ba72267e300a5107d7ea5b5867 Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Fri, 17 Feb 2023 17:52:42 -0500 Subject: [PATCH 018/106] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 35df4d6..cd2e78f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -10,7 +10,7 @@ pipeline { stage('Deploy') { steps { // Stop running microblog container - sh 'if [[ $(docker ps -q --filter ancestor=microblog:latest | wc -l) == 0 ]]; then docker stop $(docker ps -q --filter ancestor=microblog:latest) fi' + sh 'if [[ $(docker ps -q --filter ancestor=microblog:latest | wc -l) != 0 ]]; then docker stop $(docker ps -q --filter ancestor=microblog:latest) fi' // Deploy new container sh 'docker run -d -p 5000:5000 microblog:latest' } From 630fb4ca2a360e0db0dfef7be6d6561f23a36b5b Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Fri, 17 Feb 2023 18:11:55 -0500 Subject: [PATCH 019/106] Update Jenkinsfile --- Jenkinsfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index cd2e78f..b1b211a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -10,7 +10,8 @@ pipeline { stage('Deploy') { steps { // Stop running microblog container - sh 'if [[ $(docker ps -q --filter ancestor=microblog:latest | wc -l) != 0 ]]; then docker stop $(docker ps -q --filter ancestor=microblog:latest) fi' + //sh 'if [[ $(docker ps -q --filter ancestor=microblog:latest | wc -l) != 0 ]]; then docker stop $(docker ps -q --filter ancestor=microblog:latest) fi' + sh 'docker stop $(docker ps -q --filter ancestor=microblog:latest) || true && docker rm $(docker ps -q --filter ancestor=microblog:latest) || true' // Deploy new container sh 'docker run -d -p 5000:5000 microblog:latest' } From 18a4d83c2164ee9dc12644b5efa5ffde4c2f14cd Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Fri, 17 Feb 2023 18:28:05 -0500 Subject: [PATCH 020/106] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index b1b211a..03278ee 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -13,7 +13,7 @@ pipeline { //sh 'if [[ $(docker ps -q --filter ancestor=microblog:latest | wc -l) != 0 ]]; then docker stop $(docker ps -q --filter ancestor=microblog:latest) fi' sh 'docker stop $(docker ps -q --filter ancestor=microblog:latest) || true && docker rm $(docker ps -q --filter ancestor=microblog:latest) || true' // Deploy new container - sh 'docker run -d -p 5000:5000 microblog:latest' + sh 'docker run --name microblog -d -p 8000:5000 --rm microblog:latest' } } stage('Hello To Discord') { From 63c1a6c852137bfe8c985f1fe28b2c2298e9d6b5 Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Fri, 17 Feb 2023 18:40:10 -0500 Subject: [PATCH 021/106] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 03278ee..052383b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -13,7 +13,7 @@ pipeline { //sh 'if [[ $(docker ps -q --filter ancestor=microblog:latest | wc -l) != 0 ]]; then docker stop $(docker ps -q --filter ancestor=microblog:latest) fi' sh 'docker stop $(docker ps -q --filter ancestor=microblog:latest) || true && docker rm $(docker ps -q --filter ancestor=microblog:latest) || true' // Deploy new container - sh 'docker run --name microblog -d -p 8000:5000 --rm microblog:latest' + sh 'docker run --name microblog -d -p 5000:5000 --rm microblog:latest' } } stage('Hello To Discord') { From 0d168ebf7eef16df8177dcd03c87cd29dcad352f Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Fri, 17 Feb 2023 18:56:15 -0500 Subject: [PATCH 022/106] Added selenium to requirements --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index ba67d17..ffee2da 100644 --- a/requirements.txt +++ b/requirements.txt @@ -37,6 +37,7 @@ redis==3.5.3 requests==2.25.1 requests-toolbelt==0.9.1 rq==1.9.0 +selenium=4.8.2 six==1.16.0 SQLAlchemy==1.4.20 urllib3==1.26.6 From 565a7dbf2a6e5ff9ec8d8aefc67ed98b613040ca Mon Sep 17 00:00:00 2001 From: Aleksa <59575151+Aleksa-Vig@users.noreply.github.com> Date: Fri, 17 Feb 2023 19:34:14 -0500 Subject: [PATCH 023/106] Update Jenkinsfile --- Jenkinsfile | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 052383b..2d78935 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -16,12 +16,29 @@ pipeline { sh 'docker run --name microblog -d -p 5000:5000 --rm microblog:latest' } } + stage('Selenium Tests') { + steps { + sh 'python3 selenium.py' + } + } stage('Hello To Discord') { steps { - echo ' Test to Discord' + echo 'PipelineComplete' discordSend description: '', footer: '', image: '', link: 'http://3.91.14.163:8080', result: '', scmWebUrl: '', thumbnail: '', title: 'HelloToDiscordTest', webhookURL: 'https://discord.com/api/webhooks/1075879011667955872/Nk0gmKZkrISEs-hru-HjtzzgezWweABCdPsOKGIzkmj5xMcqKC3m1-dx7GZSu0yURAOo' } } } + post { + success { + echo 'Pipeline has completed' + discordSend description: '', footer: '', image: '', link: 'http://3.91.14.163:8080', result: '', scmWebUrl: '', thumbnail: '', title: + 'Pipeline has completed ✅', webhookURL: 'https://discord.com/api/webhooks/1075879011667955872/Nk0gmKZkrISEs-hru-HjtzzgezWweABCdPsOKGIzkmj5xMcqKC3m1-dx7GZSu0yURAOo' + } + failure { + echo 'Something has failed!' + discordSend description: 'Pipeline has failed!', footer: '', image: '', link: 'http://3.91.14.163:8080', result: '', scmWebUrl: '', thumbnail: '', title: + 'Pipeline failure ❌', webhookURL: 'https://discord.com/api/webhooks/1075879011667955872/Nk0gmKZkrISEs-hru-HjtzzgezWweABCdPsOKGIzkmj5xMcqKC3m1-dx7GZSu0yURAOo' + } + } } From 7b25256fbd574f726212b139bb489ce10a9ec96d Mon Sep 17 00:00:00 2001 From: Aleksa <59575151+Aleksa-Vig@users.noreply.github.com> Date: Fri, 17 Feb 2023 19:47:14 -0500 Subject: [PATCH 024/106] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2d78935..a2cc67f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -29,7 +29,7 @@ pipeline { } } } - post { + post { success { echo 'Pipeline has completed' discordSend description: '', footer: '', image: '', link: 'http://3.91.14.163:8080', result: '', scmWebUrl: '', thumbnail: '', title: From 1c9987d2ebf3cd12711738d7221743fb7c98a177 Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Fri, 17 Feb 2023 20:03:37 -0500 Subject: [PATCH 025/106] Update requirements.txt --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index ffee2da..a3a386f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -37,7 +37,7 @@ redis==3.5.3 requests==2.25.1 requests-toolbelt==0.9.1 rq==1.9.0 -selenium=4.8.2 +selenium==4.8.2 six==1.16.0 SQLAlchemy==1.4.20 urllib3==1.26.6 From b86eca2af82815943ab67dcec0b698a28cf94c64 Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Fri, 17 Feb 2023 20:04:32 -0500 Subject: [PATCH 026/106] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index a2cc67f..f64a360 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -18,7 +18,7 @@ pipeline { } stage('Selenium Tests') { steps { - sh 'python3 selenium.py' + //sh 'python3 selenium.py' } } stage('Hello To Discord') { From 3b74eb127b11f84adbeb053efd33547ebb37d96d Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Fri, 17 Feb 2023 20:05:09 -0500 Subject: [PATCH 027/106] Update Jenkinsfile --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index f64a360..9359581 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -18,6 +18,7 @@ pipeline { } stage('Selenium Tests') { steps { + echo 'Running Selenium Tests...' //sh 'python3 selenium.py' } } From ea787b7658620f66813fa74908ed2415142b6dc4 Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Fri, 17 Feb 2023 20:07:27 -0500 Subject: [PATCH 028/106] Update requirements.txt --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index a3a386f..fbfd869 100644 --- a/requirements.txt +++ b/requirements.txt @@ -37,7 +37,7 @@ redis==3.5.3 requests==2.25.1 requests-toolbelt==0.9.1 rq==1.9.0 -selenium==4.8.2 +selenium six==1.16.0 SQLAlchemy==1.4.20 urllib3==1.26.6 From 2e3af32b20d4c9395cc9bda1780501b01567c6d3 Mon Sep 17 00:00:00 2001 From: Manraj Date: Fri, 17 Feb 2023 20:11:23 -0500 Subject: [PATCH 029/106] Update Jenkinsfile --- Jenkinsfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 9359581..3fff242 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -22,7 +22,6 @@ pipeline { //sh 'python3 selenium.py' } } - stage('Hello To Discord') { steps { echo 'PipelineComplete' discordSend description: '', footer: '', image: '', link: 'http://3.91.14.163:8080', result: '', scmWebUrl: '', thumbnail: '', title: From 47ee375c102feb7b8f6d48c58b16e3f4832b04ad Mon Sep 17 00:00:00 2001 From: Manraj Date: Fri, 17 Feb 2023 20:11:49 -0500 Subject: [PATCH 030/106] Update Jenkinsfile --- Jenkinsfile | 7 ------- 1 file changed, 7 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 3fff242..7144688 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -10,7 +10,6 @@ pipeline { stage('Deploy') { steps { // Stop running microblog container - //sh 'if [[ $(docker ps -q --filter ancestor=microblog:latest | wc -l) != 0 ]]; then docker stop $(docker ps -q --filter ancestor=microblog:latest) fi' sh 'docker stop $(docker ps -q --filter ancestor=microblog:latest) || true && docker rm $(docker ps -q --filter ancestor=microblog:latest) || true' // Deploy new container sh 'docker run --name microblog -d -p 5000:5000 --rm microblog:latest' @@ -22,12 +21,6 @@ pipeline { //sh 'python3 selenium.py' } } - steps { - echo 'PipelineComplete' - discordSend description: '', footer: '', image: '', link: 'http://3.91.14.163:8080', result: '', scmWebUrl: '', thumbnail: '', title: - 'HelloToDiscordTest', webhookURL: 'https://discord.com/api/webhooks/1075879011667955872/Nk0gmKZkrISEs-hru-HjtzzgezWweABCdPsOKGIzkmj5xMcqKC3m1-dx7GZSu0yURAOo' - } - } } post { success { From 8b757ad1bd8824b968205e038a95547d0f456fdb Mon Sep 17 00:00:00 2001 From: Aleksa V Date: Fri, 17 Feb 2023 20:42:52 -0500 Subject: [PATCH 031/106] added selenium file --- selenium.py | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 selenium.py diff --git a/selenium.py b/selenium.py new file mode 100644 index 0000000..a363491 --- /dev/null +++ b/selenium.py @@ -0,0 +1,4 @@ +from selenium import webdriver + +driver = webdriver.chrome() +driver.get("http://www.python.org") From 052f034f504b995e4a8281727619dfd4ba691dfd Mon Sep 17 00:00:00 2001 From: Brady-Malott Date: Fri, 17 Feb 2023 21:30:08 -0500 Subject: [PATCH 032/106] Added comment to Jenkinsfile --- Jenkinsfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 7144688..be70415 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -22,6 +22,8 @@ pipeline { } } } + + // Post always runs even if the pipeline fails post { success { echo 'Pipeline has completed' From 1fd5c41a03cf4c22e98d3f787ebd7930e9fc1b13 Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Fri, 17 Feb 2023 22:02:14 -0500 Subject: [PATCH 033/106] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 82e3e48..b6dbaa4 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ # Welcome to Microblog! This is an example application featured in my [Flask Mega-Tutorial](https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world). See the tutorial for instructions on how to work with it. + +test From aa10f4e3d71901cf456ea38c2f4a0d97dd259aa7 Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Fri, 17 Feb 2023 22:14:21 -0500 Subject: [PATCH 034/106] Update README.md --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index b6dbaa4..82e3e48 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,3 @@ # Welcome to Microblog! This is an example application featured in my [Flask Mega-Tutorial](https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world). See the tutorial for instructions on how to work with it. - -test From 9b24856241365a737d27e1393cd69800186b4459 Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Fri, 17 Feb 2023 22:18:36 -0500 Subject: [PATCH 035/106] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 82e3e48..b6dbaa4 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ # Welcome to Microblog! This is an example application featured in my [Flask Mega-Tutorial](https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world). See the tutorial for instructions on how to work with it. + +test From 5cc81ae75d68a8ddc2c1ee4d7a2d2c33e8f7a2f0 Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Fri, 17 Feb 2023 22:19:20 -0500 Subject: [PATCH 036/106] Update README.md --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index b6dbaa4..82e3e48 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,3 @@ # Welcome to Microblog! This is an example application featured in my [Flask Mega-Tutorial](https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world). See the tutorial for instructions on how to work with it. - -test From 0fb265a2b3f2a5765982484650a530be6cb100b7 Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Fri, 17 Feb 2023 22:19:47 -0500 Subject: [PATCH 037/106] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 82e3e48..b6dbaa4 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ # Welcome to Microblog! This is an example application featured in my [Flask Mega-Tutorial](https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world). See the tutorial for instructions on how to work with it. + +test From 38141b0e2aa838a04867790dc8f91ada02a0a44b Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Fri, 17 Feb 2023 22:25:23 -0500 Subject: [PATCH 038/106] Update Jenkinsfile --- Jenkinsfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index be70415..b0e0832 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -11,6 +11,8 @@ pipeline { steps { // Stop running microblog container sh 'docker stop $(docker ps -q --filter ancestor=microblog:latest) || true && docker rm $(docker ps -q --filter ancestor=microblog:latest) || true' + // Prune old containers that are not running + sh 'docker container prune' // Deploy new container sh 'docker run --name microblog -d -p 5000:5000 --rm microblog:latest' } From 5ae9e2f79362efafe7a60e8dae6c10aca5117024 Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Fri, 17 Feb 2023 22:26:25 -0500 Subject: [PATCH 039/106] Update README.md --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index b6dbaa4..82e3e48 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,3 @@ # Welcome to Microblog! This is an example application featured in my [Flask Mega-Tutorial](https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world). See the tutorial for instructions on how to work with it. - -test From 8ef0a3784e1dd3c7bfe31c46df073d3d84764247 Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Fri, 17 Feb 2023 22:42:47 -0500 Subject: [PATCH 040/106] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 82e3e48..b6dbaa4 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ # Welcome to Microblog! This is an example application featured in my [Flask Mega-Tutorial](https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world). See the tutorial for instructions on how to work with it. + +test From 24496d0dc06d6b61d3336e53991fec6ead424da9 Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Fri, 17 Feb 2023 23:09:22 -0500 Subject: [PATCH 041/106] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index b0e0832..b68716c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -12,7 +12,7 @@ pipeline { // Stop running microblog container sh 'docker stop $(docker ps -q --filter ancestor=microblog:latest) || true && docker rm $(docker ps -q --filter ancestor=microblog:latest) || true' // Prune old containers that are not running - sh 'docker container prune' + sh 'echo y | docker container prune' // Deploy new container sh 'docker run --name microblog -d -p 5000:5000 --rm microblog:latest' } From 3f046da8dfbea05341211fc05f5172c3e6e27b58 Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Fri, 17 Feb 2023 23:17:07 -0500 Subject: [PATCH 042/106] Update README.md --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index b6dbaa4..82e3e48 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,3 @@ # Welcome to Microblog! This is an example application featured in my [Flask Mega-Tutorial](https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world). See the tutorial for instructions on how to work with it. - -test From a418c6c510546c382efa7fb6d8331414f1566969 Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Sun, 26 Feb 2023 16:07:35 -0500 Subject: [PATCH 043/106] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 82e3e48..b6dbaa4 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ # Welcome to Microblog! This is an example application featured in my [Flask Mega-Tutorial](https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world). See the tutorial for instructions on how to work with it. + +test From 4d5e7e568ba3cb94bb85396e2758a8ab6040ff94 Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Sun, 26 Feb 2023 16:14:17 -0500 Subject: [PATCH 044/106] Update README.md --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index b6dbaa4..82e3e48 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,3 @@ # Welcome to Microblog! This is an example application featured in my [Flask Mega-Tutorial](https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world). See the tutorial for instructions on how to work with it. - -test From dd52f6dc27d28a22e76aa91f6406bc34586cccbb Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Sun, 26 Feb 2023 16:23:41 -0500 Subject: [PATCH 045/106] Update microblog.py --- microblog.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/microblog.py b/microblog.py index 67d0890..47fb23d 100644 --- a/microblog.py +++ b/microblog.py @@ -1,6 +1,8 @@ from app import create_app, db, cli from app.models import User, Post, Message, Notification, Task +print('test') + app = create_app() cli.register(app) From eb950de5b55a1bf9d3433d76e5ea769446fc57af Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Sun, 26 Feb 2023 16:25:12 -0500 Subject: [PATCH 046/106] Update microblog.py --- microblog.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/microblog.py b/microblog.py index 47fb23d..67d0890 100644 --- a/microblog.py +++ b/microblog.py @@ -1,8 +1,6 @@ from app import create_app, db, cli from app.models import User, Post, Message, Notification, Task -print('test') - app = create_app() cli.register(app) From e205c228e9de35ab93fe8d0fe2e82dc6fc8195a7 Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Sun, 26 Feb 2023 16:28:26 -0500 Subject: [PATCH 047/106] Update microblog.py --- microblog.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/microblog.py b/microblog.py index 67d0890..47fb23d 100644 --- a/microblog.py +++ b/microblog.py @@ -1,6 +1,8 @@ from app import create_app, db, cli from app.models import User, Post, Message, Notification, Task +print('test') + app = create_app() cli.register(app) From bf95fbbc8a410a0dab3c3c51ed5fdafe1ac1c5d3 Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Sun, 26 Feb 2023 17:08:13 -0500 Subject: [PATCH 048/106] Update Jenkinsfile --- Jenkinsfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index b68716c..d570056 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -12,9 +12,11 @@ pipeline { // Stop running microblog container sh 'docker stop $(docker ps -q --filter ancestor=microblog:latest) || true && docker rm $(docker ps -q --filter ancestor=microblog:latest) || true' // Prune old containers that are not running - sh 'echo y | docker container prune' + sh 'docker container prune -f' // Deploy new container sh 'docker run --name microblog -d -p 5000:5000 --rm microblog:latest' + // Remove all images that don't have a container running them + sh 'docker image prune -a' } } stage('Selenium Tests') { From 7e748d8d5b75acc23b2c497b0e8f95143c5182bd Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Sun, 26 Feb 2023 17:18:35 -0500 Subject: [PATCH 049/106] Update microblog.py --- microblog.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/microblog.py b/microblog.py index 47fb23d..67d0890 100644 --- a/microblog.py +++ b/microblog.py @@ -1,8 +1,6 @@ from app import create_app, db, cli from app.models import User, Post, Message, Notification, Task -print('test') - app = create_app() cli.register(app) From fafa0c646e9ab80ea87e3aa13a763d45a0db474b Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Sun, 26 Feb 2023 17:32:08 -0500 Subject: [PATCH 050/106] Update Jenkinsfile --- Jenkinsfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index d570056..75429b3 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -11,8 +11,6 @@ pipeline { steps { // Stop running microblog container sh 'docker stop $(docker ps -q --filter ancestor=microblog:latest) || true && docker rm $(docker ps -q --filter ancestor=microblog:latest) || true' - // Prune old containers that are not running - sh 'docker container prune -f' // Deploy new container sh 'docker run --name microblog -d -p 5000:5000 --rm microblog:latest' // Remove all images that don't have a container running them From 6ad72eddc0434839b5bc8c3f082a426bb43f9df0 Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Sun, 26 Feb 2023 17:50:07 -0500 Subject: [PATCH 051/106] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 75429b3..252b227 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -14,7 +14,7 @@ pipeline { // Deploy new container sh 'docker run --name microblog -d -p 5000:5000 --rm microblog:latest' // Remove all images that don't have a container running them - sh 'docker image prune -a' + sh 'docker image prune --filter "label=org.opencontainers.image.vendor=Jenkins project"' } } stage('Selenium Tests') { From 60951e9a1db79881937d8b2de6a66b6f1a7cf7da Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Sun, 26 Feb 2023 17:50:32 -0500 Subject: [PATCH 052/106] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 252b227..eed8f9a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -14,7 +14,7 @@ pipeline { // Deploy new container sh 'docker run --name microblog -d -p 5000:5000 --rm microblog:latest' // Remove all images that don't have a container running them - sh 'docker image prune --filter "label=org.opencontainers.image.vendor=Jenkins project"' + sh 'docker image prune --filter "label!=org.opencontainers.image.vendor=Jenkins project"' } } stage('Selenium Tests') { From c170691e6619d12224df0d452d4707b513cc7279 Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Sun, 26 Feb 2023 17:52:10 -0500 Subject: [PATCH 053/106] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index eed8f9a..600ef80 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -13,7 +13,7 @@ pipeline { sh 'docker stop $(docker ps -q --filter ancestor=microblog:latest) || true && docker rm $(docker ps -q --filter ancestor=microblog:latest) || true' // Deploy new container sh 'docker run --name microblog -d -p 5000:5000 --rm microblog:latest' - // Remove all images that don't have a container running them + // Remove all images except for jenkins sh 'docker image prune --filter "label!=org.opencontainers.image.vendor=Jenkins project"' } } From bf1b0db721df8f9a389f55cebd26dfd7ecc85c9e Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Sun, 26 Feb 2023 18:06:50 -0500 Subject: [PATCH 054/106] Update Jenkinsfile --- Jenkinsfile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 600ef80..ac2940d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -7,6 +7,12 @@ pipeline { sh 'docker build -t microblog:latest .' } } + stage('Selenium Tests') { + steps { + echo 'Running Selenium Tests...' + //sh 'python3 selenium.py' + } + } stage('Deploy') { steps { // Stop running microblog container @@ -17,12 +23,6 @@ pipeline { sh 'docker image prune --filter "label!=org.opencontainers.image.vendor=Jenkins project"' } } - stage('Selenium Tests') { - steps { - echo 'Running Selenium Tests...' - //sh 'python3 selenium.py' - } - } } // Post always runs even if the pipeline fails From 18a16c0c028f35388d9df3e907d797134e855fe0 Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Sun, 26 Feb 2023 18:10:32 -0500 Subject: [PATCH 055/106] Update Jenkinsfile --- Jenkinsfile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index ac2940d..600ef80 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -7,12 +7,6 @@ pipeline { sh 'docker build -t microblog:latest .' } } - stage('Selenium Tests') { - steps { - echo 'Running Selenium Tests...' - //sh 'python3 selenium.py' - } - } stage('Deploy') { steps { // Stop running microblog container @@ -23,6 +17,12 @@ pipeline { sh 'docker image prune --filter "label!=org.opencontainers.image.vendor=Jenkins project"' } } + stage('Selenium Tests') { + steps { + echo 'Running Selenium Tests...' + //sh 'python3 selenium.py' + } + } } // Post always runs even if the pipeline fails From 5552659a5de4bb4511e28c14092974482239f55a Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Sun, 26 Feb 2023 18:11:39 -0500 Subject: [PATCH 056/106] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 82e3e48..86ebb4a 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ # Welcome to Microblog! This is an example application featured in my [Flask Mega-Tutorial](https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world). See the tutorial for instructions on how to work with it. + +Test From 7791ad310e4c1c6bea843c1d826eb014e661f9bb Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Sun, 26 Feb 2023 18:16:57 -0500 Subject: [PATCH 057/106] Update README.md --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 86ebb4a..82e3e48 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,3 @@ # Welcome to Microblog! This is an example application featured in my [Flask Mega-Tutorial](https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world). See the tutorial for instructions on how to work with it. - -Test From f7d7e192b0b5da9cda6810a7646d6b2a137bc0a5 Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Sun, 26 Feb 2023 18:20:43 -0500 Subject: [PATCH 058/106] Update microblog.py --- microblog.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/microblog.py b/microblog.py index 67d0890..47fb23d 100644 --- a/microblog.py +++ b/microblog.py @@ -1,6 +1,8 @@ from app import create_app, db, cli from app.models import User, Post, Message, Notification, Task +print('test') + app = create_app() cli.register(app) From 1fa635477367249fe9f15f86270ccb4032a5fc7f Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Sun, 26 Feb 2023 18:58:23 -0500 Subject: [PATCH 059/106] Update Dockerfile --- Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index 6604175..bdf6443 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,5 +19,7 @@ ENV FLASK_APP microblog.py RUN chown -R microblog:microblog ./ USER microblog +LABEL microblog + EXPOSE 5000 ENTRYPOINT ["./boot.sh"] From 3d788eb83b2e1437696bf49cf9a1cd3399d060c7 Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Sun, 26 Feb 2023 19:03:39 -0500 Subject: [PATCH 060/106] Update Jenkinsfile --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 600ef80..0a1dcc1 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -9,8 +9,8 @@ pipeline { } stage('Deploy') { steps { - // Stop running microblog container - sh 'docker stop $(docker ps -q --filter ancestor=microblog:latest) || true && docker rm $(docker ps -q --filter ancestor=microblog:latest) || true' + // Stop running microblog container (microblog label applied to microblog container by this repo's Dockerfile) + sh 'docker stop $(docker ps -q --filter label=microblog) || true && docker rm $(docker ps -q --filter label=microblog) || true' // Deploy new container sh 'docker run --name microblog -d -p 5000:5000 --rm microblog:latest' // Remove all images except for jenkins From 0d6980493bb47a69144768309a67f1b7bdf3064b Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Sun, 26 Feb 2023 19:07:38 -0500 Subject: [PATCH 061/106] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 0a1dcc1..919f34f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -10,7 +10,7 @@ pipeline { stage('Deploy') { steps { // Stop running microblog container (microblog label applied to microblog container by this repo's Dockerfile) - sh 'docker stop $(docker ps -q --filter label=microblog) || true && docker rm $(docker ps -q --filter label=microblog) || true' + sh 'docker stop $(docker ps -q --filter name=microblog) || true && docker rm $(docker ps -q --filter name=microblog) || true' // Deploy new container sh 'docker run --name microblog -d -p 5000:5000 --rm microblog:latest' // Remove all images except for jenkins From 81d476087722a808263120573c228d65cf2d711c Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Sun, 26 Feb 2023 19:08:08 -0500 Subject: [PATCH 062/106] Update Dockerfile --- Dockerfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index bdf6443..6604175 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,7 +19,5 @@ ENV FLASK_APP microblog.py RUN chown -R microblog:microblog ./ USER microblog -LABEL microblog - EXPOSE 5000 ENTRYPOINT ["./boot.sh"] From ec8a1e7895e1d4cdb10ca25d61fe63737332deb4 Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Sun, 26 Feb 2023 19:10:20 -0500 Subject: [PATCH 063/106] Update microblog.py --- microblog.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/microblog.py b/microblog.py index 47fb23d..67d0890 100644 --- a/microblog.py +++ b/microblog.py @@ -1,8 +1,6 @@ from app import create_app, db, cli from app.models import User, Post, Message, Notification, Task -print('test') - app = create_app() cli.register(app) From a94977a174f46e7695a51e245ad1104dba9e0733 Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Sun, 26 Feb 2023 19:18:01 -0500 Subject: [PATCH 064/106] Update microblog.py --- microblog.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/microblog.py b/microblog.py index 67d0890..47fb23d 100644 --- a/microblog.py +++ b/microblog.py @@ -1,6 +1,8 @@ from app import create_app, db, cli from app.models import User, Post, Message, Notification, Task +print('test') + app = create_app() cli.register(app) From 887b2de385db2c03c0b23876ca618e9027322ea6 Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Sun, 26 Feb 2023 19:54:51 -0500 Subject: [PATCH 065/106] Update microblog.py --- microblog.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/microblog.py b/microblog.py index 47fb23d..d4ba730 100644 --- a/microblog.py +++ b/microblog.py @@ -1,7 +1,7 @@ from app import create_app, db, cli from app.models import User, Post, Message, Notification, Task -print('test') +print('test2') app = create_app() cli.register(app) From 1edae19db2b4f76c24c8865d6b2bf37156609af6 Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Sun, 26 Feb 2023 21:19:34 -0500 Subject: [PATCH 066/106] Update Jenkinsfile --- Jenkinsfile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 919f34f..d471815 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,6 +2,12 @@ pipeline { agent any stages { + stage('Undeploy') { + steps { + // Stop running microblog container (microblog label applied to microblog container by this repo's Dockerfile) + sh 'docker stop $(docker ps -q --filter name=microblog) || true && docker rm $(docker ps -q --filter name=microblog) || true' + } + } stage('Build') { steps { sh 'docker build -t microblog:latest .' @@ -9,8 +15,6 @@ pipeline { } stage('Deploy') { steps { - // Stop running microblog container (microblog label applied to microblog container by this repo's Dockerfile) - sh 'docker stop $(docker ps -q --filter name=microblog) || true && docker rm $(docker ps -q --filter name=microblog) || true' // Deploy new container sh 'docker run --name microblog -d -p 5000:5000 --rm microblog:latest' // Remove all images except for jenkins From ab761c89f29bd4e1e70fc33bd7330bce44a66e2f Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Sun, 26 Feb 2023 21:23:48 -0500 Subject: [PATCH 067/106] Update Jenkinsfile --- Jenkinsfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index d471815..bc2d70b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -5,7 +5,9 @@ pipeline { stage('Undeploy') { steps { // Stop running microblog container (microblog label applied to microblog container by this repo's Dockerfile) - sh 'docker stop $(docker ps -q --filter name=microblog) || true && docker rm $(docker ps -q --filter name=microblog) || true' + sh 'docker stop $(docker ps -q --filter name=microblog) || true && docker rm $(docker ps -q --filter name=microblog) || true' + // Remove all images except for jenkins + sh 'docker image prune --filter "label!=org.opencontainers.image.vendor=Jenkins project"' } } stage('Build') { @@ -17,8 +19,6 @@ pipeline { steps { // Deploy new container sh 'docker run --name microblog -d -p 5000:5000 --rm microblog:latest' - // Remove all images except for jenkins - sh 'docker image prune --filter "label!=org.opencontainers.image.vendor=Jenkins project"' } } stage('Selenium Tests') { From 64d4a433beca90b8014eacf7a0ac5e60d798e4da Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Sun, 26 Feb 2023 21:29:32 -0500 Subject: [PATCH 068/106] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index bc2d70b..85b709a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -7,7 +7,7 @@ pipeline { // Stop running microblog container (microblog label applied to microblog container by this repo's Dockerfile) sh 'docker stop $(docker ps -q --filter name=microblog) || true && docker rm $(docker ps -q --filter name=microblog) || true' // Remove all images except for jenkins - sh 'docker image prune --filter "label!=org.opencontainers.image.vendor=Jenkins project"' + sh 'docker image prune -a --filter "label!=org.opencontainers.image.vendor=Jenkins project"' } } stage('Build') { From a2cf7254c79c97baf24c7ebb81a358fcaaa512fa Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Sun, 26 Feb 2023 21:32:15 -0500 Subject: [PATCH 069/106] Update microblog.py --- microblog.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/microblog.py b/microblog.py index d4ba730..47fb23d 100644 --- a/microblog.py +++ b/microblog.py @@ -1,7 +1,7 @@ from app import create_app, db, cli from app.models import User, Post, Message, Notification, Task -print('test2') +print('test') app = create_app() cli.register(app) From 37759e094b34e7f1f26f6be64204242f7cbc8642 Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Sun, 26 Feb 2023 21:36:23 -0500 Subject: [PATCH 070/106] Update microblog.py --- microblog.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/microblog.py b/microblog.py index 47fb23d..67d0890 100644 --- a/microblog.py +++ b/microblog.py @@ -1,8 +1,6 @@ from app import create_app, db, cli from app.models import User, Post, Message, Notification, Task -print('test') - app = create_app() cli.register(app) From d975bcfbf5e5beb76b3265b2024bb5aa74f80003 Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Sun, 26 Feb 2023 21:38:19 -0500 Subject: [PATCH 071/106] Update Jenkinsfile --- Jenkinsfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 85b709a..41851f4 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -6,19 +6,19 @@ pipeline { steps { // Stop running microblog container (microblog label applied to microblog container by this repo's Dockerfile) sh 'docker stop $(docker ps -q --filter name=microblog) || true && docker rm $(docker ps -q --filter name=microblog) || true' - // Remove all images except for jenkins - sh 'docker image prune -a --filter "label!=org.opencontainers.image.vendor=Jenkins project"' } } stage('Build') { steps { - sh 'docker build -t microblog:latest .' + sh 'docker build -t microblog:latest .' } } stage('Deploy') { steps { // Deploy new container sh 'docker run --name microblog -d -p 5000:5000 --rm microblog:latest' + // Remove all images except for jenkins + sh 'docker image prune -a --filter "label!=org.opencontainers.image.vendor=Jenkins project"' } } stage('Selenium Tests') { From e7b6440a947b2b0b6e29cf3d38a948158321b058 Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Sun, 26 Feb 2023 21:42:40 -0500 Subject: [PATCH 072/106] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 41851f4..1197257 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -18,7 +18,7 @@ pipeline { // Deploy new container sh 'docker run --name microblog -d -p 5000:5000 --rm microblog:latest' // Remove all images except for jenkins - sh 'docker image prune -a --filter "label!=org.opencontainers.image.vendor=Jenkins project"' + sh 'docker image prune -af --filter "label!=org.opencontainers.image.vendor=Jenkins project"' } } stage('Selenium Tests') { From 46927c06b0cf9856ba129f98dd9fff0a4c7ae11a Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Sun, 26 Feb 2023 21:45:56 -0500 Subject: [PATCH 073/106] Update login.html --- app/templates/auth/login.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/templates/auth/login.html b/app/templates/auth/login.html index fe46cce..fad8d55 100644 --- a/app/templates/auth/login.html +++ b/app/templates/auth/login.html @@ -2,7 +2,7 @@ {% import 'bootstrap/wtf.html' as wtf %} {% block app_content %} -

{{ _('Sign In') }}

+

{{ _('Sign In Test') }}

{{ wtf.quick_form(form) }} From 621f341a8dcf1eff29a70b400c0cd1f2e83b30cf Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Sun, 26 Feb 2023 21:48:59 -0500 Subject: [PATCH 074/106] Update login.html --- app/templates/auth/login.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/templates/auth/login.html b/app/templates/auth/login.html index fad8d55..fe46cce 100644 --- a/app/templates/auth/login.html +++ b/app/templates/auth/login.html @@ -2,7 +2,7 @@ {% import 'bootstrap/wtf.html' as wtf %} {% block app_content %} -

{{ _('Sign In Test') }}

+

{{ _('Sign In') }}

{{ wtf.quick_form(form) }} From 012cbe019589d20043f13b5a87e7540bfc1ba0b5 Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Sun, 26 Feb 2023 21:57:22 -0500 Subject: [PATCH 075/106] Update microblog.py --- microblog.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/microblog.py b/microblog.py index 67d0890..47fb23d 100644 --- a/microblog.py +++ b/microblog.py @@ -1,6 +1,8 @@ from app import create_app, db, cli from app.models import User, Post, Message, Notification, Task +print('test') + app = create_app() cli.register(app) From 2ff5ca08ab9fc0dc9b25bb7ee8e77d75d2fae73d Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Sun, 26 Feb 2023 22:02:53 -0500 Subject: [PATCH 076/106] Update microblog.py --- microblog.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/microblog.py b/microblog.py index 47fb23d..67d0890 100644 --- a/microblog.py +++ b/microblog.py @@ -1,8 +1,6 @@ from app import create_app, db, cli from app.models import User, Post, Message, Notification, Task -print('test') - app = create_app() cli.register(app) From 6f47fdd65bd869e235f9eb1baf754e3df9866e13 Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Fri, 3 Mar 2023 18:37:13 -0500 Subject: [PATCH 077/106] Update Jenkinsfile Fixed link in discord notification --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 1197257..19bf6f0 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -33,12 +33,12 @@ pipeline { post { success { echo 'Pipeline has completed' - discordSend description: '', footer: '', image: '', link: 'http://3.91.14.163:8080', result: '', scmWebUrl: '', thumbnail: '', title: + discordSend description: '', footer: '', image: '', link: 'http://3.238.108.178:8080/', result: '', scmWebUrl: '', thumbnail: '', title: 'Pipeline has completed ✅', webhookURL: 'https://discord.com/api/webhooks/1075879011667955872/Nk0gmKZkrISEs-hru-HjtzzgezWweABCdPsOKGIzkmj5xMcqKC3m1-dx7GZSu0yURAOo' } failure { echo 'Something has failed!' - discordSend description: 'Pipeline has failed!', footer: '', image: '', link: 'http://3.91.14.163:8080', result: '', scmWebUrl: '', thumbnail: '', title: + discordSend description: 'Pipeline has failed!', footer: '', image: '', link: 'http://3.238.108.178:8080/', result: '', scmWebUrl: '', thumbnail: '', title: 'Pipeline failure ❌', webhookURL: 'https://discord.com/api/webhooks/1075879011667955872/Nk0gmKZkrISEs-hru-HjtzzgezWweABCdPsOKGIzkmj5xMcqKC3m1-dx7GZSu0yURAOo' } } From 7bbd883955111b82b0b7299a26fade9b317d8768 Mon Sep 17 00:00:00 2001 From: manrajg13 Date: Mon, 6 Mar 2023 14:11:02 -0500 Subject: [PATCH 078/106] Add 2FA --- .env | 3 + app/auth/forms.py | 21 ++++++- app/auth/routes.py | 63 +++++++++++++++++-- app/auth/twilio_verify.py | 26 ++++++++ app/models.py | 4 ++ app/templates/auth/disable_2fa.html | 13 ++++ app/templates/auth/enable_2fa.html | 34 ++++++++++ app/templates/auth/verify_2fa.html | 12 ++++ app/templates/user.html | 5 ++ config.py | 3 + .../23e9d8ca48c2_two_factor_authentication.py | 28 +++++++++ 11 files changed, 207 insertions(+), 5 deletions(-) create mode 100644 .env create mode 100644 app/auth/twilio_verify.py create mode 100644 app/templates/auth/disable_2fa.html create mode 100644 app/templates/auth/enable_2fa.html create mode 100644 app/templates/auth/verify_2fa.html create mode 100644 migrations/versions/23e9d8ca48c2_two_factor_authentication.py diff --git a/.env b/.env new file mode 100644 index 0000000..094a49a --- /dev/null +++ b/.env @@ -0,0 +1,3 @@ +TWILIO_ACCOUNT_SID='AC0bd1e642a7054c751da1cce44df0b627' +TWILIO_AUTH_TOKEN='50f07accf2e7e5888a28f2657957ddab' +TWILIO_VERIFY_SERVICE_ID='VAb34d1b5d153b89ef0706728107612a4e' \ No newline at end of file diff --git a/app/auth/forms.py b/app/auth/forms.py index c1dd3eb..f0fbba5 100644 --- a/app/auth/forms.py +++ b/app/auth/forms.py @@ -4,7 +4,6 @@ from wtforms.validators import ValidationError, DataRequired, Email, EqualTo from flask_babel import _, lazy_gettext as _l from app.models import User - class LoginForm(FlaskForm): username = StringField(_l('Username'), validators=[DataRequired()]) password = PasswordField(_l('Password'), validators=[DataRequired()]) @@ -12,6 +11,26 @@ class LoginForm(FlaskForm): submit = SubmitField(_l('Sign In')) +class Confirm2faForm(FlaskForm): + token = StringField('Token') + submit = SubmitField('Verify') + + +class Enable2faForm(FlaskForm): + verification_phone = StringField('Phone', validators=[DataRequired()]) + submit = SubmitField('Enable 2FA') + + def validate_verification_phone(self, verification_phone): + try: + return + except: + print("An exception occurred") + + +class Disable2faForm(FlaskForm): + submit = SubmitField('Disable 2FA') + + class RegistrationForm(FlaskForm): username = StringField(_l('Username'), validators=[DataRequired()]) email = StringField(_l('Email'), validators=[DataRequired(), Email()]) diff --git a/app/auth/routes.py b/app/auth/routes.py index b3f1d72..d3b5053 100644 --- a/app/auth/routes.py +++ b/app/auth/routes.py @@ -1,10 +1,11 @@ -from flask import render_template, redirect, url_for, flash, request +from app.auth.twilio_verify import check_verification_token, request_verification_token +from flask import render_template, redirect, url_for, flash, request, session from werkzeug.urls import url_parse -from flask_login import login_user, logout_user, current_user +from flask_login import login_user, login_required, logout_user, current_user from flask_babel import _ from app import db from app.auth import bp -from app.auth.forms import LoginForm, RegistrationForm, \ +from app.auth.forms import Confirm2faForm, Disable2faForm, Enable2faForm, LoginForm, RegistrationForm, \ ResetPasswordRequestForm, ResetPasswordForm from app.models import User from app.auth.email import send_password_reset_email @@ -20,14 +21,68 @@ def login(): if user is None or not user.check_password(form.password.data): flash(_('Invalid username or password')) return redirect(url_for('auth.login')) - login_user(user, remember=form.remember_me.data) next_page = request.args.get('next') + if user.two_factor_enabled(): + request_verification_token(user.verification_phone) + session['username'] = user.username + session['phone'] = user.verification_phone + return redirect(url_for( + 'auth.verify_2fa', next=next_page, + remember='1' if form.remember_me.data else '0')) + login_user(user, remember=form.remember_me.data) if not next_page or url_parse(next_page).netloc != '': next_page = url_for('main.index') return redirect(next_page) return render_template('auth/login.html', title=_('Sign In'), form=form) +@bp.route('/verify2fa', methods=['GET', 'POST']) +def verify_2fa(): + form = Confirm2faForm() + if form.validate_on_submit(): + phone = session['phone'] + if check_verification_token(phone, form.token.data): + del session['phone'] + if current_user.is_authenticated: + current_user.verification_phone = phone + db.session.commit() + flash('Two-factor authentication is now enabled') + return redirect(url_for('main.index')) + else: + username = session['username'] + del session['username'] + user = User.query.filter_by(username=username).first() + next_page = request.args.get('next') + remember = request.args.get('remember', '0') == '1' + login_user(user, remember=remember) + return redirect(next_page) + form.token.errors.append('Invalid token') + return render_template('auth/verify_2fa.html', form=form) + + +@bp.route('/enable_2fa', methods=['GET', 'POST']) +@login_required +def enable_2fa(): + form = Enable2faForm() + if form.validate_on_submit(): + session['phone'] = form.verification_phone.data + request_verification_token(session['phone']) + return redirect(url_for('auth.verify_2fa')) + return render_template('auth/enable_2fa.html', form=form) + + +@bp.route('/disable_2fa', methods=['GET', 'POST']) +@login_required +def disable_2fa(): + form = Disable2faForm() + if form.validate_on_submit(): + current_user.verification_phone = None + db.session.commit() + flash('Two-factor authentication is now disabled.') + return redirect(url_for('main.index')) + return render_template('auth/disable_2fa.html', form=form) + + @bp.route('/logout') def logout(): logout_user() diff --git a/app/auth/twilio_verify.py b/app/auth/twilio_verify.py new file mode 100644 index 0000000..97b219b --- /dev/null +++ b/app/auth/twilio_verify.py @@ -0,0 +1,26 @@ +from flask import current_app +from twilio.rest import Client, TwilioException + + +def _get_twilio_verify_client(): + return Client( + current_app.config['TWILIO_ACCOUNT_SID'], + current_app.config['TWILIO_AUTH_TOKEN']).verify.services( + current_app.config['TWILIO_VERIFY_SERVICE_ID']) + + +def request_verification_token(phone): + verify = _get_twilio_verify_client() + try: + verify.verifications.create(to=phone, channel='sms') + except TwilioException: + verify.verifications.create(to=phone, channel='call') + + +def check_verification_token(phone, token): + verify = _get_twilio_verify_client() + try: + result = verify.verification_checks.create(to=phone, code=token) + except TwilioException: + return False + return result.status == 'approved' \ No newline at end of file diff --git a/app/models.py b/app/models.py index 5bdab20..8ae4a82 100644 --- a/app/models.py +++ b/app/models.py @@ -94,6 +94,7 @@ class User(UserMixin, PaginatedAPIMixin, db.Model): username = db.Column(db.String(64), index=True, unique=True) email = db.Column(db.String(120), index=True, unique=True) password_hash = db.Column(db.String(128)) + verification_phone = db.Column(db.String(16)) posts = db.relationship('Post', backref='author', lazy='dynamic') about_me = db.Column(db.String(140)) last_seen = db.Column(db.DateTime, default=datetime.utcnow) @@ -123,6 +124,9 @@ class User(UserMixin, PaginatedAPIMixin, db.Model): def check_password(self, password): return check_password_hash(self.password_hash, password) + + def two_factor_enabled(self): + return self.verification_phone is not None def avatar(self, size): digest = md5(self.email.lower().encode('utf-8')).hexdigest() diff --git a/app/templates/auth/disable_2fa.html b/app/templates/auth/disable_2fa.html new file mode 100644 index 0000000..c65e110 --- /dev/null +++ b/app/templates/auth/disable_2fa.html @@ -0,0 +1,13 @@ +{# app/templates/auth/disable_2fa.html #} +{% extends 'base.html' %} +{% import 'bootstrap/wtf.html' as wtf %} + +{% block app_content %} +

Disable Two-Factor Authentication

+

Please click the button below to disable two-factor authentication on your account.

+
+
+ {{ wtf.quick_form(form) }} +
+
+{% endblock %} \ No newline at end of file diff --git a/app/templates/auth/enable_2fa.html b/app/templates/auth/enable_2fa.html new file mode 100644 index 0000000..a8deb3e --- /dev/null +++ b/app/templates/auth/enable_2fa.html @@ -0,0 +1,34 @@ +{% extends 'base.html' %} +{% import 'bootstrap/wtf.html' as wtf %} + +{% block app_content %} +

Enable Two-Factor Authentication

+

Please enter your mobile number to activate two-factor authentication on your account.

+
+
+ {{ wtf.quick_form(form) }} +
+
+{% endblock %} + +{% block styles %} + {{ super() }} + +{% endblock %} + +{% block scripts %} + {{ super() }} + + +{% endblock %} diff --git a/app/templates/auth/verify_2fa.html b/app/templates/auth/verify_2fa.html new file mode 100644 index 0000000..93028ee --- /dev/null +++ b/app/templates/auth/verify_2fa.html @@ -0,0 +1,12 @@ +{% extends 'base.html' %} +{% import 'bootstrap/wtf.html' as wtf %} + +{% block app_content %} +

Two-Factor Authentication

+

Please enter the token that was sent to your phone.

+
+
+ {{ wtf.quick_form(form) }} +
+
+{% endblock %} \ No newline at end of file diff --git a/app/templates/user.html b/app/templates/user.html index 1d85872..ed71258 100644 --- a/app/templates/user.html +++ b/app/templates/user.html @@ -34,6 +34,11 @@ {% if user != current_user %}

{{ _('Send private message') }}

{% endif %} + {% if not user.two_factor_enabled() %} +

{{ _('Enable two-factor authentication') }}

+ {% else %} +

{{ _('Disable two-factor authentication') }}

+ {% endif %} diff --git a/config.py b/config.py index 481fa1a..8e4f51c 100644 --- a/config.py +++ b/config.py @@ -11,6 +11,9 @@ class Config(object): 'postgres://', 'postgresql://') or \ 'sqlite:///' + os.path.join(basedir, 'app.db') SQLALCHEMY_TRACK_MODIFICATIONS = False + TWILIO_ACCOUNT_SID = os.environ.get('TWILIO_ACCOUNT_SID') + TWILIO_AUTH_TOKEN = os.environ.get('TWILIO_ACCOUNT_TOKEN') + TWILIO_VERIFY_SERVICE_ID = os.environ.get('TWILIO_VERIFY_SERVICE_ID') LOG_TO_STDOUT = os.environ.get('LOG_TO_STDOUT') MAIL_SERVER = os.environ.get('MAIL_SERVER') MAIL_PORT = int(os.environ.get('MAIL_PORT') or 25) diff --git a/migrations/versions/23e9d8ca48c2_two_factor_authentication.py b/migrations/versions/23e9d8ca48c2_two_factor_authentication.py new file mode 100644 index 0000000..285010d --- /dev/null +++ b/migrations/versions/23e9d8ca48c2_two_factor_authentication.py @@ -0,0 +1,28 @@ +"""two-factor authentication + +Revision ID: 23e9d8ca48c2 +Revises: 834b1a697901 +Create Date: 2023-03-04 14:26:06.269415 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '23e9d8ca48c2' +down_revision = '834b1a697901' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.add_column('user', sa.Column('verification_phone', sa.String(length=16), nullable=True)) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_column('user', 'verification_phone') + # ### end Alembic commands ### From 98dae894dee08d5de814686277d5863ae82aedfd Mon Sep 17 00:00:00 2001 From: Manraj Date: Mon, 6 Mar 2023 14:36:13 -0500 Subject: [PATCH 079/106] Delete .env --- .env | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 .env diff --git a/.env b/.env deleted file mode 100644 index 094a49a..0000000 --- a/.env +++ /dev/null @@ -1,3 +0,0 @@ -TWILIO_ACCOUNT_SID='AC0bd1e642a7054c751da1cce44df0b627' -TWILIO_AUTH_TOKEN='50f07accf2e7e5888a28f2657957ddab' -TWILIO_VERIFY_SERVICE_ID='VAb34d1b5d153b89ef0706728107612a4e' \ No newline at end of file From a1d2522dd17cbca97a49ec7d70ff6ead354a11e6 Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Tue, 7 Mar 2023 18:39:58 -0500 Subject: [PATCH 080/106] Update Jenkinsfile --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 19bf6f0..eb2bdb1 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -33,12 +33,12 @@ pipeline { post { success { echo 'Pipeline has completed' - discordSend description: '', footer: '', image: '', link: 'http://3.238.108.178:8080/', result: '', scmWebUrl: '', thumbnail: '', title: + discordSend description: '', footer: '', image: '', link: 'http://3.220.122.102:8080/', result: '', scmWebUrl: '', thumbnail: '', title: 'Pipeline has completed ✅', webhookURL: 'https://discord.com/api/webhooks/1075879011667955872/Nk0gmKZkrISEs-hru-HjtzzgezWweABCdPsOKGIzkmj5xMcqKC3m1-dx7GZSu0yURAOo' } failure { echo 'Something has failed!' - discordSend description: 'Pipeline has failed!', footer: '', image: '', link: 'http://3.238.108.178:8080/', result: '', scmWebUrl: '', thumbnail: '', title: + discordSend description: 'Pipeline has failed!', footer: '', image: '', link: 'http://3.220.122.102:8080/', result: '', scmWebUrl: '', thumbnail: '', title: 'Pipeline failure ❌', webhookURL: 'https://discord.com/api/webhooks/1075879011667955872/Nk0gmKZkrISEs-hru-HjtzzgezWweABCdPsOKGIzkmj5xMcqKC3m1-dx7GZSu0yURAOo' } } From 863ae3496a294c4b47c9276c991138a3dc58c669 Mon Sep 17 00:00:00 2001 From: Aleksa V Date: Tue, 7 Mar 2023 18:58:00 -0500 Subject: [PATCH 081/106] removed a testing file --- selenium.py | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 selenium.py diff --git a/selenium.py b/selenium.py deleted file mode 100644 index a363491..0000000 --- a/selenium.py +++ /dev/null @@ -1,4 +0,0 @@ -from selenium import webdriver - -driver = webdriver.chrome() -driver.get("http://www.python.org") From 1d0a0c1c17403e2873572850fbad52f2c79bec6e Mon Sep 17 00:00:00 2001 From: Aleksa V Date: Tue, 7 Mar 2023 21:49:09 -0500 Subject: [PATCH 082/106] Scaffolded and added readmes for testing work --- __init__.py | 0 requirements.txt | 2 ++ tests/features/add-task.feature | 17 ++++++++++++ tests/features/how-to-run-behave.md | 5 ++++ tests/features/steps/add-task-steps.py | 38 ++++++++++++++++++++++++++ tests/features/steps/check-ui-steps.py | 30 ++++++++++++++++++++ tests/unit/__init__.py | 0 tests/unit/how-to-run-tests.md | 11 ++++++++ tests.py => tests/unit/test_example.py | 3 ++ 9 files changed, 106 insertions(+) create mode 100644 __init__.py create mode 100644 tests/features/add-task.feature create mode 100644 tests/features/how-to-run-behave.md create mode 100644 tests/features/steps/add-task-steps.py create mode 100644 tests/features/steps/check-ui-steps.py create mode 100644 tests/unit/__init__.py create mode 100644 tests/unit/how-to-run-tests.md rename tests.py => tests/unit/test_example.py (99%) mode change 100755 => 100644 diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/requirements.txt b/requirements.txt index fbfd869..c9f1ec1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -38,6 +38,8 @@ requests==2.25.1 requests-toolbelt==0.9.1 rq==1.9.0 selenium +behave +webdriver_manager six==1.16.0 SQLAlchemy==1.4.20 urllib3==1.26.6 diff --git a/tests/features/add-task.feature b/tests/features/add-task.feature new file mode 100644 index 0000000..07b2634 --- /dev/null +++ b/tests/features/add-task.feature @@ -0,0 +1,17 @@ +Feature: Add tasks to todo list + As a user + I want to be able to add tasks to my todo list + So thats I can keep track of my work + + Scenario: User visits the todo list page + Given the user is on the todo list page + Then the page should have a text field to enter the title of the task + And the page should have a text field to enter the estimate of hours needed to complete the task + And the page should have a button to add the task + + Scenario: Add a new task to the todo list + Given I am on the todo list page + When I enter "Buy groceries" in the title field + And I enter "2" in the estimate field + And I click the "Add" button + Then the task "Buy groceries" with estimate "2" should be added to the todo list \ No newline at end of file diff --git a/tests/features/how-to-run-behave.md b/tests/features/how-to-run-behave.md new file mode 100644 index 0000000..e49a513 --- /dev/null +++ b/tests/features/how-to-run-behave.md @@ -0,0 +1,5 @@ +How to run behave tutorial + +1. Running all behave features + +run " behave tests/features/add-task.feature " \ No newline at end of file diff --git a/tests/features/steps/add-task-steps.py b/tests/features/steps/add-task-steps.py new file mode 100644 index 0000000..652025e --- /dev/null +++ b/tests/features/steps/add-task-steps.py @@ -0,0 +1,38 @@ +from behave import * +from webdriver_manager.chrome import ChromeDriverManager +from selenium import webdriver +from selenium.webdriver.chrome.service import Service as ChromeService +from selenium.webdriver.common.by import By + +@given(u'I am on the todo list page') +def open_browser(context): + context.driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install())) + context.driver.implicitly_wait(5) + context.driver.get("http://127.0.0.1:5000/") + + +@when('I enter "{title}" in the title field') +def step_impl(context, title): + title_field = context.driver.find_element(By.NAME, "title") + title_field.send_keys(title) + + +@when('I enter "{estimate}" in the estimate field') +def step_impl(context, estimate): + estimate_field = context.driver.find_element(By.NAME, "estimate") + estimate_field.send_keys(estimate) + + +@when(u'I click the "Add" button') +def step_impl(context): + add_button = context.driver.find_element(By.XPATH, "//button[contains(text(),'Add')]") + add_button.click() + context.driver.implicitly_wait(5) + + +@then('the task "{title}" with estimate "{estimate}" should be added to the todo list') +def step_impl(context, title, estimate): + dump_text = context.driver.page_source + print(dump_text) + assert ("Buy groceries | 2" in dump_text) is True + diff --git a/tests/features/steps/check-ui-steps.py b/tests/features/steps/check-ui-steps.py new file mode 100644 index 0000000..698df79 --- /dev/null +++ b/tests/features/steps/check-ui-steps.py @@ -0,0 +1,30 @@ +from behave import * +from webdriver_manager.chrome import ChromeDriverManager +from selenium import webdriver +from selenium.webdriver.chrome.service import Service as ChromeService +from selenium.webdriver.common.by import By + + +@given(u'the user is on the todo list page') +def open_browser(context): + context.driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install())) + context.driver.implicitly_wait(5) + context.driver.get("http://127.0.0.1:5000/") + + +@then(u'the page should have a text field to enter the title of the task') +def check_task_title_textbox(context): + status = context.driver.find_element(By.NAME, "title").is_displayed() + assert status is True + + +@then(u'the page should have a text field to enter the estimate of hours needed to complete the task') +def check_task_estimate_textbox(context): + status = context.driver.find_element(By.NAME, "estimate").is_displayed() + assert status is True + + +@then(u'the page should have a button to add the task') +def check_task_add_button(context): + status = context.driver.find_element(By.XPATH, "//button[contains(text(),'Add')]").is_displayed() + assert status is True diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/unit/how-to-run-tests.md b/tests/unit/how-to-run-tests.md new file mode 100644 index 0000000..c6e8720 --- /dev/null +++ b/tests/unit/how-to-run-tests.md @@ -0,0 +1,11 @@ +How to run unit tests + +unit tests must follow the "test*.py" regex to be picked up + +1. Individual tests + +run " python .\tests\unit\test_example.py " + +2. Run all unit tests + +run " python -m unittest discover -s ./tests/unit " \ No newline at end of file diff --git a/tests.py b/tests/unit/test_example.py old mode 100755 new mode 100644 similarity index 99% rename from tests.py rename to tests/unit/test_example.py index 52111b1..fb9827f --- a/tests.py +++ b/tests/unit/test_example.py @@ -1,4 +1,7 @@ #!/usr/bin/env python +import sys +sys.path.append('./') + from datetime import datetime, timedelta import unittest from app import create_app, db From 5352537c6df1a1d27059fdb1b7bb2ed60d9b2a16 Mon Sep 17 00:00:00 2001 From: manrajg13 Date: Wed, 8 Mar 2023 15:36:20 -0500 Subject: [PATCH 083/106] Update Dockerfile --- .gitignore | 1 + Dockerfile | 5 +++++ requirements.txt | 18 +++++++++++++----- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 1e4f836..764b603 100644 --- a/.gitignore +++ b/.gitignore @@ -38,3 +38,4 @@ nosetests.xml venv app.db microblog.log* +.env diff --git a/Dockerfile b/Dockerfile index 6604175..ebd77ad 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,6 +5,7 @@ RUN useradd microblog WORKDIR /home/microblog COPY requirements.txt requirements.txt +COPY .env .env RUN python -m venv venv RUN venv/bin/pip install -r requirements.txt RUN venv/bin/pip install gunicorn pymysql cryptography @@ -16,6 +17,10 @@ RUN chmod a+x boot.sh ENV FLASK_APP microblog.py +CMD flask db upgrade +CMD flask db migrate -m "two-factor authentication" +CMD flask db upgrade + RUN chown -R microblog:microblog ./ USER microblog diff --git a/requirements.txt b/requirements.txt index fbfd869..eb4d95f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,13 +1,17 @@ alembic==1.6.5 +async-generator==1.10 +attrs==22.2.0 Babel==2.9.1 blinker==1.4 certifi==2021.5.30 chardet==4.0.0 +charset-normalizer==3.0.1 click==8.0.1 dnspython==2.1.0 dominate==2.6.0 elasticsearch==7.13.3 email-validator==1.1.3 +exceptiongroup==1.1.0 Flask==2.0.1 Flask-Babel==2.0.0 Flask-Bootstrap==3.3.7.1 @@ -19,6 +23,7 @@ Flask-Moment==1.0.1 Flask-SQLAlchemy==2.5.1 Flask-WTF==0.15.1 greenlet==2.0.2 +h11==0.14.0 httpie==2.4.0 idna==2.10 itsdangerous==2.0.1 @@ -26,6 +31,7 @@ Jinja2==3.0.1 langdetect==1.0.9 Mako==1.1.4 MarkupSafe==2.0.1 +outcome==1.2.0 Pygments==2.9.0 PyJWT==2.1.0 PySocks==1.7.1 @@ -37,14 +43,16 @@ redis==3.5.3 requests==2.25.1 requests-toolbelt==0.9.1 rq==1.9.0 -selenium +selenium==4.4.1 six==1.16.0 +sniffio==1.3.0 +sortedcontainers==2.4.0 SQLAlchemy==1.4.20 +trio==0.22.0 +trio-websocket==0.9.2 +twilio==7.16.4 urllib3==1.26.6 visitor==0.1.3 Werkzeug==2.0.1 +wsproto==1.2.0 WTForms==2.3.3 - -# requirements for Heroku -#psycopg2==2.9.1 -#gunicorn==20.1.0 From 89dda8d505b79312d2d50dc2bffc300354a9fc35 Mon Sep 17 00:00:00 2001 From: Brady-Malott <55215446+Brady-Malott@users.noreply.github.com> Date: Wed, 8 Mar 2023 17:24:08 -0500 Subject: [PATCH 084/106] Ignored .idea folder --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 1e4f836..3d8d8c7 100644 --- a/.gitignore +++ b/.gitignore @@ -38,3 +38,5 @@ nosetests.xml venv app.db microblog.log* + +.idea/ From 71249f04abd91c74c4785de305b06c8a484062b9 Mon Sep 17 00:00:00 2001 From: Aleksa V Date: Wed, 8 Mar 2023 19:51:22 -0500 Subject: [PATCH 085/106] PR issues --- README.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/README.md b/README.md index 82e3e48..c0567b3 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,32 @@ # Welcome to Microblog! This is an example application featured in my [Flask Mega-Tutorial](https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world). See the tutorial for instructions on how to work with it. + +# How to run behave tutorial + +*NOTE* behave steps in the .feature file MUST unicode match those in the 'steps' file + +e.g. in the *.feature file there is a Gherkin line like +'the task 'Buy groceries' with estimate '2' should be added to the todo list' + +then in the accompanying *step.py file it must follow the exact unicode in the behave decorator +Like this -> '@then("the task '{title}' with estimate '{estimate}' should be added to the todo list")' + + +Also step files must follow the regex *step.py + +1. Running all behave features + +run " behave tests/features/add-task.feature " + +# How to run unit tests + +unit tests must follow the "test*.py" regex to be picked up + +1. Individual tests + +run " python ./ests/unit/test_example.py " + +2. Run all unit tests + +run " python -m unittest discover -s ./tests/unit " \ No newline at end of file From 858f7cccdfa99eb4590921c98519863a285a369a Mon Sep 17 00:00:00 2001 From: Aleksa V Date: Wed, 8 Mar 2023 19:52:19 -0500 Subject: [PATCH 086/106] Missed a file --- tests/features/add-task.feature | 8 +++---- tests/features/how-to-run-behave.md | 5 ----- tests/features/steps/add-task-steps.py | 30 ++++++++++++++++++++------ tests/features/steps/check-ui-steps.py | 21 ++++++++++++------ tests/unit/how-to-run-tests.md | 11 ---------- 5 files changed, 42 insertions(+), 33 deletions(-) delete mode 100644 tests/features/how-to-run-behave.md delete mode 100644 tests/unit/how-to-run-tests.md diff --git a/tests/features/add-task.feature b/tests/features/add-task.feature index 07b2634..3e1c284 100644 --- a/tests/features/add-task.feature +++ b/tests/features/add-task.feature @@ -11,7 +11,7 @@ Feature: Add tasks to todo list Scenario: Add a new task to the todo list Given I am on the todo list page - When I enter "Buy groceries" in the title field - And I enter "2" in the estimate field - And I click the "Add" button - Then the task "Buy groceries" with estimate "2" should be added to the todo list \ No newline at end of file + When I enter 'Buy groceries' in the title field + And I enter '2' in the estimate field + And I click the 'Add' button + Then the task 'Buy groceries' with estimate '2' should be added to the todo list \ No newline at end of file diff --git a/tests/features/how-to-run-behave.md b/tests/features/how-to-run-behave.md deleted file mode 100644 index e49a513..0000000 --- a/tests/features/how-to-run-behave.md +++ /dev/null @@ -1,5 +0,0 @@ -How to run behave tutorial - -1. Running all behave features - -run " behave tests/features/add-task.feature " \ No newline at end of file diff --git a/tests/features/steps/add-task-steps.py b/tests/features/steps/add-task-steps.py index 652025e..4fa5cf2 100644 --- a/tests/features/steps/add-task-steps.py +++ b/tests/features/steps/add-task-steps.py @@ -1,38 +1,54 @@ -from behave import * +from behave import given, when, then from webdriver_manager.chrome import ChromeDriverManager from selenium import webdriver from selenium.webdriver.chrome.service import Service as ChromeService from selenium.webdriver.common.by import By +from selenium.webdriver.chrome.options import Options -@given(u'I am on the todo list page') +#THESE ARE EXAMPLES FILES. +#Todo delete these once we set a standard with our own tests + +@given("I am on the todo list page") def open_browser(context): - context.driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install())) + + # Implementation of headless from https://stackoverflow.com/questions/46920243/how-to-configure-chromedriver-to-initiate-chrome-browser-in-headless-mode-throug + # Stackoverflow post desribes what is goin on with options to enable headless chrome + + options = Options() + options.add_argument("--headless") # Runs Chrome in headless mode. + options.add_argument('--no-sandbox') # Bypass OS security model + options.add_argument('start-maximized') #to maximize viewport this should still be headless + options.add_argument('disable-infobars') + options.add_argument("--disable-extensions") + context.driver = webdriver.Chrome(options=options, service=ChromeService(ChromeDriverManager().install())) context.driver.implicitly_wait(5) context.driver.get("http://127.0.0.1:5000/") -@when('I enter "{title}" in the title field') +@when("I enter '{title}' in the title field") def step_impl(context, title): title_field = context.driver.find_element(By.NAME, "title") title_field.send_keys(title) -@when('I enter "{estimate}" in the estimate field') +@when("I enter '{estimate}' in the estimate field") def step_impl(context, estimate): estimate_field = context.driver.find_element(By.NAME, "estimate") estimate_field.send_keys(estimate) -@when(u'I click the "Add" button') +@when("I click the 'Add' button") def step_impl(context): add_button = context.driver.find_element(By.XPATH, "//button[contains(text(),'Add')]") add_button.click() context.driver.implicitly_wait(5) -@then('the task "{title}" with estimate "{estimate}" should be added to the todo list') +@then("the task '{title}' with estimate '{estimate}' should be added to the todo list") def step_impl(context, title, estimate): dump_text = context.driver.page_source print(dump_text) assert ("Buy groceries | 2" in dump_text) is True + + diff --git a/tests/features/steps/check-ui-steps.py b/tests/features/steps/check-ui-steps.py index 698df79..1f07681 100644 --- a/tests/features/steps/check-ui-steps.py +++ b/tests/features/steps/check-ui-steps.py @@ -1,30 +1,39 @@ -from behave import * +from behave import given, when, then from webdriver_manager.chrome import ChromeDriverManager from selenium import webdriver from selenium.webdriver.chrome.service import Service as ChromeService from selenium.webdriver.common.by import By +from selenium.webdriver.chrome.options import Options +#THESE ARE EXAMPLES FILES. +#Todo delete these once we set a standard with our own tests -@given(u'the user is on the todo list page') +@given("the user is on the todo list page") def open_browser(context): - context.driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install())) + options = Options() + options.add_argument("--headless") # Runs Chrome in headless mode. + options.add_argument('--no-sandbox') # Bypass OS security model + options.add_argument('start-maximized') #to maximize viewport this should still be headless + options.add_argument('disable-infobars') + options.add_argument("--disable-extensions") + context.driver = webdriver.Chrome(options=options, service=ChromeService(ChromeDriverManager().install())) context.driver.implicitly_wait(5) context.driver.get("http://127.0.0.1:5000/") -@then(u'the page should have a text field to enter the title of the task') +@then("the page should have a text field to enter the title of the task") def check_task_title_textbox(context): status = context.driver.find_element(By.NAME, "title").is_displayed() assert status is True -@then(u'the page should have a text field to enter the estimate of hours needed to complete the task') +@then("the page should have a text field to enter the estimate of hours needed to complete the task") def check_task_estimate_textbox(context): status = context.driver.find_element(By.NAME, "estimate").is_displayed() assert status is True -@then(u'the page should have a button to add the task') +@then("the page should have a button to add the task") def check_task_add_button(context): status = context.driver.find_element(By.XPATH, "//button[contains(text(),'Add')]").is_displayed() assert status is True diff --git a/tests/unit/how-to-run-tests.md b/tests/unit/how-to-run-tests.md deleted file mode 100644 index c6e8720..0000000 --- a/tests/unit/how-to-run-tests.md +++ /dev/null @@ -1,11 +0,0 @@ -How to run unit tests - -unit tests must follow the "test*.py" regex to be picked up - -1. Individual tests - -run " python .\tests\unit\test_example.py " - -2. Run all unit tests - -run " python -m unittest discover -s ./tests/unit " \ No newline at end of file From c72f13d35b794f55f28cddefcd66a6f0c34c57f0 Mon Sep 17 00:00:00 2001 From: manrajg13 Date: Fri, 10 Mar 2023 18:33:38 -0500 Subject: [PATCH 087/106] Fix: Dockerfile and routes error handling Moved copying .env in dockerfile to avoid cache invalidation. Removed try and except in confirm2fa because it did nothing. Checking if next is None or '' before returning and removed data deletions in route functions. --- Dockerfile | 2 +- app/auth/forms.py | 6 ------ app/auth/routes.py | 10 +++++----- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index ebd77ad..5f4bf9c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,11 +5,11 @@ RUN useradd microblog WORKDIR /home/microblog COPY requirements.txt requirements.txt -COPY .env .env RUN python -m venv venv RUN venv/bin/pip install -r requirements.txt RUN venv/bin/pip install gunicorn pymysql cryptography +COPY .env .env COPY app app COPY migrations migrations COPY microblog.py config.py boot.sh ./ diff --git a/app/auth/forms.py b/app/auth/forms.py index f0fbba5..7ac8730 100644 --- a/app/auth/forms.py +++ b/app/auth/forms.py @@ -20,12 +20,6 @@ class Enable2faForm(FlaskForm): verification_phone = StringField('Phone', validators=[DataRequired()]) submit = SubmitField('Enable 2FA') - def validate_verification_phone(self, verification_phone): - try: - return - except: - print("An exception occurred") - class Disable2faForm(FlaskForm): submit = SubmitField('Disable 2FA') diff --git a/app/auth/routes.py b/app/auth/routes.py index d3b5053..7762880 100644 --- a/app/auth/routes.py +++ b/app/auth/routes.py @@ -22,6 +22,8 @@ def login(): flash(_('Invalid username or password')) return redirect(url_for('auth.login')) next_page = request.args.get('next') + if not next_page or url_parse(next_page).netloc != '': + next_page = url_for('main.index') if user.two_factor_enabled(): request_verification_token(user.verification_phone) session['username'] = user.username @@ -30,19 +32,16 @@ def login(): 'auth.verify_2fa', next=next_page, remember='1' if form.remember_me.data else '0')) login_user(user, remember=form.remember_me.data) - if not next_page or url_parse(next_page).netloc != '': - next_page = url_for('main.index') return redirect(next_page) return render_template('auth/login.html', title=_('Sign In'), form=form) -@bp.route('/verify2fa', methods=['GET', 'POST']) +@bp.route('/verify_2fa', methods=['GET', 'POST']) def verify_2fa(): form = Confirm2faForm() if form.validate_on_submit(): phone = session['phone'] if check_verification_token(phone, form.token.data): - del session['phone'] if current_user.is_authenticated: current_user.verification_phone = phone db.session.commit() @@ -50,10 +49,11 @@ def verify_2fa(): return redirect(url_for('main.index')) else: username = session['username'] - del session['username'] user = User.query.filter_by(username=username).first() next_page = request.args.get('next') remember = request.args.get('remember', '0') == '1' + if not next_page or url_parse(next_page).netloc != '': + next_page = url_for('main.index') login_user(user, remember=remember) return redirect(next_page) form.token.errors.append('Invalid token') From 7cc3bca0ce8cbe71cc334ae592dc58198ff3023f Mon Sep 17 00:00:00 2001 From: Manraj Date: Sat, 11 Mar 2023 01:46:40 -0500 Subject: [PATCH 088/106] Update Jenkinsfile --- Jenkinsfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index eb2bdb1..7052d54 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -6,6 +6,9 @@ pipeline { steps { // Stop running microblog container (microblog label applied to microblog container by this repo's Dockerfile) sh 'docker stop $(docker ps -q --filter name=microblog) || true && docker rm $(docker ps -q --filter name=microblog) || true' + withCredentials([file(credentialsId: twilio-creds, variable: 'env')]) { + writeFile file: '.env', text: readFile(env) + } } } stage('Build') { From d9f605d7dbac105d1c4d62d254f568ac04b31100 Mon Sep 17 00:00:00 2001 From: Manraj Date: Sat, 11 Mar 2023 01:50:45 -0500 Subject: [PATCH 089/106] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 7052d54..0884caa 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -7,7 +7,7 @@ pipeline { // Stop running microblog container (microblog label applied to microblog container by this repo's Dockerfile) sh 'docker stop $(docker ps -q --filter name=microblog) || true && docker rm $(docker ps -q --filter name=microblog) || true' withCredentials([file(credentialsId: twilio-creds, variable: 'env')]) { - writeFile file: '.env', text: readFile(env) + sh "cp \$env /.env" } } } From 671fc2a1b0812660cc2efb5bedca8054b154830b Mon Sep 17 00:00:00 2001 From: Manraj Date: Sat, 11 Mar 2023 01:53:11 -0500 Subject: [PATCH 090/106] Update Jenkinsfile --- Jenkinsfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 0884caa..ce0e501 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -6,9 +6,9 @@ pipeline { steps { // Stop running microblog container (microblog label applied to microblog container by this repo's Dockerfile) sh 'docker stop $(docker ps -q --filter name=microblog) || true && docker rm $(docker ps -q --filter name=microblog) || true' - withCredentials([file(credentialsId: twilio-creds, variable: 'env')]) { - sh "cp \$env /.env" - } + } + withCredentials([file(credentialsId: twilio-creds, variable: 'env')]) { + sh "cp \$env /.env" } } stage('Build') { From d36893e54a2f81745d749e8169808c17e20b5d28 Mon Sep 17 00:00:00 2001 From: Manraj Date: Sat, 11 Mar 2023 02:00:18 -0500 Subject: [PATCH 091/106] Update Jenkinsfile --- Jenkinsfile | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index ce0e501..cef8097 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -7,12 +7,14 @@ pipeline { // Stop running microblog container (microblog label applied to microblog container by this repo's Dockerfile) sh 'docker stop $(docker ps -q --filter name=microblog) || true && docker rm $(docker ps -q --filter name=microblog) || true' } - withCredentials([file(credentialsId: twilio-creds, variable: 'env')]) { - sh "cp \$env /.env" - } } stage('Build') { + environment { + TWILIO_CREDS = credentials('twilio-creds') + } steps { + echo 'Copying .env file...' + sh 'cp SECRET_FILE_ID ./' sh 'docker build -t microblog:latest .' } } From a19e5a22fe27e3cb4ab12130874b71417ad68f26 Mon Sep 17 00:00:00 2001 From: Manraj Date: Sat, 11 Mar 2023 02:02:56 -0500 Subject: [PATCH 092/106] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index cef8097..e9d8b29 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -14,7 +14,7 @@ pipeline { } steps { echo 'Copying .env file...' - sh 'cp SECRET_FILE_ID ./' + sh 'cp ${SECRET_FILE_ID} ./' sh 'docker build -t microblog:latest .' } } From 2d19c93c8b5bf2c83d44f91219492b72c3fdfe37 Mon Sep 17 00:00:00 2001 From: Manraj Date: Sat, 11 Mar 2023 02:04:09 -0500 Subject: [PATCH 093/106] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index e9d8b29..3374dc5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -14,7 +14,7 @@ pipeline { } steps { echo 'Copying .env file...' - sh 'cp ${SECRET_FILE_ID} ./' + sh 'cp ${SECRET_FILE_ID} .env' sh 'docker build -t microblog:latest .' } } From 207d788904581b22792d367d991a4bdddb988098 Mon Sep 17 00:00:00 2001 From: Manraj Date: Sat, 11 Mar 2023 02:05:06 -0500 Subject: [PATCH 094/106] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 3374dc5..f88dd1d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -14,7 +14,7 @@ pipeline { } steps { echo 'Copying .env file...' - sh 'cp ${SECRET_FILE_ID} .env' + sh 'cp ${TWILIO_CREDS} .env' sh 'docker build -t microblog:latest .' } } From 41be7f86ed1d99fc6fd2e5c34b8712274657533d Mon Sep 17 00:00:00 2001 From: Manraj Date: Sat, 11 Mar 2023 02:32:25 -0500 Subject: [PATCH 095/106] Update Jenkinsfile --- Jenkinsfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index f88dd1d..c4cd482 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -13,8 +13,7 @@ pipeline { TWILIO_CREDS = credentials('twilio-creds') } steps { - echo 'Copying .env file...' - sh 'cp ${TWILIO_CREDS} .env' + sh 'cp $TWILIO_CREDS .env' sh 'docker build -t microblog:latest .' } } From 7ef301c166d8b1f177d60c610654d3ed7347ba05 Mon Sep 17 00:00:00 2001 From: Manraj Date: Sat, 11 Mar 2023 02:36:48 -0500 Subject: [PATCH 096/106] Update Jenkinsfile --- Jenkinsfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index c4cd482..d00065d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -13,7 +13,8 @@ pipeline { TWILIO_CREDS = credentials('twilio-creds') } steps { - sh 'cp $TWILIO_CREDS .env' + sh 'chown -R root:jenkins target/' + sh 'sudo cp $TWILIO_CREDS .env' sh 'docker build -t microblog:latest .' } } From 770d3898e9ecb57c3f6ec3aa2d50b771b81054d3 Mon Sep 17 00:00:00 2001 From: Manraj Date: Sat, 11 Mar 2023 02:37:48 -0500 Subject: [PATCH 097/106] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index d00065d..2dc138b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -13,7 +13,7 @@ pipeline { TWILIO_CREDS = credentials('twilio-creds') } steps { - sh 'chown -R root:jenkins target/' + sh 'chown -R root:jenkins' sh 'sudo cp $TWILIO_CREDS .env' sh 'docker build -t microblog:latest .' } From df0bba6121c01cbfc1312d24773737f47420a033 Mon Sep 17 00:00:00 2001 From: Manraj Date: Sat, 11 Mar 2023 02:38:39 -0500 Subject: [PATCH 098/106] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2dc138b..552de78 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -13,7 +13,7 @@ pipeline { TWILIO_CREDS = credentials('twilio-creds') } steps { - sh 'chown -R root:jenkins' + sh 'chown -R root:jenkins *' sh 'sudo cp $TWILIO_CREDS .env' sh 'docker build -t microblog:latest .' } From 03c8ad1f8e3fba16be505b9086d0949f0a770cb6 Mon Sep 17 00:00:00 2001 From: Manraj Date: Sat, 11 Mar 2023 02:40:20 -0500 Subject: [PATCH 099/106] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 552de78..c2b7da6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -13,7 +13,7 @@ pipeline { TWILIO_CREDS = credentials('twilio-creds') } steps { - sh 'chown -R root:jenkins *' + sh 'sudo usermod -a -G root jenkins' sh 'sudo cp $TWILIO_CREDS .env' sh 'docker build -t microblog:latest .' } From 4139da1fdd7b670f35728d47f1c3309f759dbc04 Mon Sep 17 00:00:00 2001 From: Manraj Date: Sat, 11 Mar 2023 02:41:52 -0500 Subject: [PATCH 100/106] Update Jenkinsfile --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index c2b7da6..732209a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -13,8 +13,8 @@ pipeline { TWILIO_CREDS = credentials('twilio-creds') } steps { - sh 'sudo usermod -a -G root jenkins' - sh 'sudo cp $TWILIO_CREDS .env' + sh 'whoami' + sh 'cp $TWILIO_CREDS .env' sh 'docker build -t microblog:latest .' } } From 9b893e05107e1944d6bb9314e6122ae88e3b9e7d Mon Sep 17 00:00:00 2001 From: Manraj Date: Sat, 11 Mar 2023 02:42:50 -0500 Subject: [PATCH 101/106] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 732209a..aaa80f9 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -13,7 +13,7 @@ pipeline { TWILIO_CREDS = credentials('twilio-creds') } steps { - sh 'whoami' + sh 'sudo chmod a+rwx *' sh 'cp $TWILIO_CREDS .env' sh 'docker build -t microblog:latest .' } From 88d1b915689754491b610b0a44754adf247f317a Mon Sep 17 00:00:00 2001 From: Manraj Date: Sat, 11 Mar 2023 02:45:00 -0500 Subject: [PATCH 102/106] Update Jenkinsfile --- Jenkinsfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index aaa80f9..c2ee8d0 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -13,8 +13,7 @@ pipeline { TWILIO_CREDS = credentials('twilio-creds') } steps { - sh 'sudo chmod a+rwx *' - sh 'cp $TWILIO_CREDS .env' + sh 'scp $TWILIO_CREDS .env' sh 'docker build -t microblog:latest .' } } From 69db46537363e9b35b364a5c1c47df11e64afd42 Mon Sep 17 00:00:00 2001 From: Manraj Date: Sat, 11 Mar 2023 02:46:25 -0500 Subject: [PATCH 103/106] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index c2ee8d0..c4cd482 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -13,7 +13,7 @@ pipeline { TWILIO_CREDS = credentials('twilio-creds') } steps { - sh 'scp $TWILIO_CREDS .env' + sh 'cp $TWILIO_CREDS .env' sh 'docker build -t microblog:latest .' } } From c3a61854a56c4df061afd5b22ee523a32daaf3c3 Mon Sep 17 00:00:00 2001 From: Manraj Date: Sat, 11 Mar 2023 14:12:45 -0500 Subject: [PATCH 104/106] Update Jenkinsfile --- Jenkinsfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index c4cd482..da6d51b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -10,10 +10,12 @@ pipeline { } stage('Build') { environment { - TWILIO_CREDS = credentials('twilio-creds') + TWILIO_ACCOUNT_SID = credentials('TWILIO_ACCOUNT_SID') + TWILIO_AUTH_TOKEN = credentials('TWILIO_ACCOUNT_SID') + TWILIO_VERIFY_SERVICE_ID = credentials('TWILIO_ACCOUNT_SID') } steps { - sh 'cp $TWILIO_CREDS .env' + echo '$TWILIO_ACCOUNT_SID' sh 'docker build -t microblog:latest .' } } From 8e8d583fccfff71fa9788b9576d8a012aa23b1ea Mon Sep 17 00:00:00 2001 From: Manraj Date: Sat, 11 Mar 2023 14:16:11 -0500 Subject: [PATCH 105/106] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index da6d51b..6913362 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -15,7 +15,7 @@ pipeline { TWILIO_VERIFY_SERVICE_ID = credentials('TWILIO_ACCOUNT_SID') } steps { - echo '$TWILIO_ACCOUNT_SID' + sh 'cat .env' sh 'docker build -t microblog:latest .' } } From 49771f96b77a830bf75b9e2bbbaf3f0737889962 Mon Sep 17 00:00:00 2001 From: Manraj Date: Sat, 11 Mar 2023 14:19:33 -0500 Subject: [PATCH 106/106] Update Jenkinsfile --- Jenkinsfile | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 6913362..eb2bdb1 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -9,13 +9,7 @@ pipeline { } } stage('Build') { - environment { - TWILIO_ACCOUNT_SID = credentials('TWILIO_ACCOUNT_SID') - TWILIO_AUTH_TOKEN = credentials('TWILIO_ACCOUNT_SID') - TWILIO_VERIFY_SERVICE_ID = credentials('TWILIO_ACCOUNT_SID') - } steps { - sh 'cat .env' sh 'docker build -t microblog:latest .' } }