|
| 1 | +pipeline { |
| 2 | + agent { |
| 3 | + kubernetes { |
| 4 | + defaultContainer "bb2-cbc-build-selenium-python311-chronium" |
| 5 | + yamlFile "Jenkinsfiles/cbc-pod-deployment-config-w-selenium-p311-chronium.yaml" |
| 6 | + } |
| 7 | + } |
| 8 | + |
| 9 | + environment { |
| 10 | + USE_MSLSX = true |
| 11 | + DJANGO_LOG_JSON_FORMAT_PRETTY = true |
| 12 | + DJANGO_SETTINGS_MODULE = "hhs_oauth_server.settings.logging_it" |
| 13 | + OAUTHLIB_INSECURE_TRANSPORT = true |
| 14 | + DJANGO_SECURE_SESSION = false |
| 15 | + DJANGO_FHIR_CERTSTORE = "./certstore" |
| 16 | + DJANGO_MEDICARE_SLSX_REDIRECT_URI="http://localhost:8000/mymedicare/sls-callback" |
| 17 | + DJANGO_MEDICARE_SLSX_LOGIN_URI="https://test.medicare.gov/sso/authorize?client_id=bb2api" |
| 18 | + DJANGO_SLSX_HEALTH_CHECK_ENDPOINT="https://test.accounts.cms.gov/health" |
| 19 | + DJANGO_SLSX_TOKEN_ENDPOINT="https://test.medicare.gov/sso/session" |
| 20 | + DJANGO_SLSX_SIGNOUT_ENDPOINT="https://test.medicare.gov/sso/signout" |
| 21 | + DJANGO_SLSX_USERINFO_ENDPOINT="https://test.accounts.cms.gov/v1/users" |
| 22 | + DJANGO_SLSX_CLIENT_ID = credentials("bb2-selenium-tests-slsx-client-id") |
| 23 | + DJANGO_SLSX_CLIENT_SECRET = credentials("bb2-selenium-tests-slsx-client-secret") |
| 24 | + DJANGO_USER_ID_ITERATIONS = credentials("bb2-integration-tests-bfd-iterations") |
| 25 | + DJANGO_USER_ID_SALT = credentials("bb2-integration-tests-bfd-salt") |
| 26 | + FHIR_CERT = credentials("bb2-integration-tests-bfd-cert") |
| 27 | + FHIR_KEY = credentials("bb2-integration-tests-bfd-key") |
| 28 | + FHIR_URL = "${params.FHIR_URL}" |
| 29 | + HOSTNAME_URL = "http://localhost:8000" |
| 30 | + } |
| 31 | + |
| 32 | + parameters { |
| 33 | + string( |
| 34 | + name: 'FHIR_URL', |
| 35 | + defaultValue: "https://prod-sbx.bfd.cms.gov", |
| 36 | + description: 'The default FHIR URL for the back end BFD service.' |
| 37 | + ) |
| 38 | + booleanParam( |
| 39 | + name: 'RUN_SELENIUM_TESTS', |
| 40 | + defaultValue: false, |
| 41 | + description: 'Set to true, selenium tests will be run as part of integration tests' |
| 42 | + ) |
| 43 | + } |
| 44 | + |
| 45 | + stages { |
| 46 | + stage("SETUP FHIR cert and key") { |
| 47 | + steps { |
| 48 | + writeFile(file: "${env.DJANGO_FHIR_CERTSTORE}/certstore/ca.cert.pem", text: readFile(env.FHIR_CERT)) |
| 49 | + writeFile(file: "${env.DJANGO_FHIR_CERTSTORE}/certstore/ca.key.nocrypt.pem", text: readFile(env.FHIR_KEY)) |
| 50 | + } |
| 51 | + } |
| 52 | + |
| 53 | + stage("INSTALL Python Packages") { |
| 54 | + steps { |
| 55 | + sh """ |
| 56 | + python -m venv venv |
| 57 | + . venv/bin/activate |
| 58 | + python -m pip install --upgrade pip setuptools wheel cryptography |
| 59 | + make reqs-install-dev |
| 60 | + """ |
| 61 | + } |
| 62 | + } |
| 63 | + |
| 64 | + stage("CHECK Flake8 Python Lint/Style") { |
| 65 | + steps{ |
| 66 | + sh """ |
| 67 | + . venv/bin/activate |
| 68 | + flake8 |
| 69 | + """ |
| 70 | + } |
| 71 | + } |
| 72 | + |
| 73 | + stage("RUN Django Unit Tests") { |
| 74 | + steps{ |
| 75 | + sh """ |
| 76 | + . venv/bin/activate |
| 77 | + python runtests.py |
| 78 | + """ |
| 79 | + } |
| 80 | + } |
| 81 | + |
| 82 | + stage("START BB2 server in background") { |
| 83 | + when { |
| 84 | + expression { params.RUN_SELENIUM_TESTS == true } |
| 85 | + } |
| 86 | + steps{ |
| 87 | + sh """ |
| 88 | + . venv/bin/activate |
| 89 | + mkdir ./docker-compose/tmp/ |
| 90 | + python manage.py migrate && python manage.py create_admin_groups && python manage.py loaddata scopes.json && python manage.py create_blue_button_scopes && python manage.py create_test_user_and_application && python manage.py create_user_identification_label_selection && python manage.py create_test_feature_switches && (if [ ! -d 'bluebutton-css' ] ; then git clone https://github.com/CMSgov/bluebutton-css.git ; else echo 'CSS already installed.' ; fi) && echo 'starting bb2...' && (export DJANGO_SETTINGS_MODULE=hhs_oauth_server.settings.logging_it && python manage.py runserver 0.0.0.0:8000 > ./docker-compose/tmp/bb2_email_to_stdout.log 2>&1 &) |
| 91 | + """ |
| 92 | + } |
| 93 | + } |
| 94 | + |
| 95 | + stage("RUN logging integration tests") { |
| 96 | + when { |
| 97 | + expression { params.RUN_SELENIUM_TESTS == true } |
| 98 | + } |
| 99 | + steps{ |
| 100 | + sh """ |
| 101 | + . venv/bin/activate |
| 102 | + USE_NEW_PERM_SCREEN=true pytest ./apps/integration_tests/logging_tests.py::TestLoggings::test_auth_fhir_flows_logging |
| 103 | + """ |
| 104 | + } |
| 105 | + } |
| 106 | + |
| 107 | + stage("RUN selenium user and apps management tests") { |
| 108 | + when { |
| 109 | + expression { params.RUN_SELENIUM_TESTS == true } |
| 110 | + } |
| 111 | + steps{ |
| 112 | + sh 'echo "RUN selenium tests - user account and app management tests"' |
| 113 | + sh """ |
| 114 | + . venv/bin/activate |
| 115 | + pytest ./apps/integration_tests/selenium_accounts_tests.py::TestUserAndAppMgmt::testAccountAndAppMgmt |
| 116 | + """ |
| 117 | + } |
| 118 | + } |
| 119 | + |
| 120 | + stage("RUN integration tests") { |
| 121 | + steps{ |
| 122 | + sh """ |
| 123 | + . venv/bin/activate |
| 124 | + python runtests.py --integration apps.integration_tests.integration_test_fhir_resources.IntegrationTestFhirApiResources |
| 125 | + """ |
| 126 | + } |
| 127 | + } |
| 128 | + |
| 129 | + stage("RUN selenium tests") { |
| 130 | + when { |
| 131 | + expression { params.RUN_SELENIUM_TESTS == true } |
| 132 | + } |
| 133 | + steps{ |
| 134 | + sh 'echo "RUN selenium tests - testclient based authorization flow tests and data flow tests"' |
| 135 | + sh """ |
| 136 | + . venv/bin/activate |
| 137 | + USE_NEW_PERM_SCREEN=true pytest ./apps/integration_tests/selenium_tests.py |
| 138 | + """ |
| 139 | + } |
| 140 | + } |
| 141 | + |
| 142 | + } |
| 143 | +} |
0 commit comments