Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates to various packages and tests #549

Merged
merged 54 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
7d225b0
Updated keycloak-js to 19.0.3 and using login.esgf.io for localhost (…
sturoscy-personal Jul 25, 2023
c498715
resolve packages
sashakames Jul 25, 2023
85c898d
Upgraded to React 18.2, upgraded to antd 4.24, and upgraded node vers…
downiec Jul 28, 2023
687e037
In process of fixing several tests. Too many are broken and will need…
downiec Aug 5, 2023
64eb001
Refactored the whole test suite to use userEvent rather than fireEven…
downiec Aug 5, 2023
ac70acc
update projects and local settings for devel
sashakames Aug 10, 2023
81d7337
correct urls
sashakames Aug 14, 2023
139d39b
Got tests to pass: skipped failing tests, fixed a few tests and creat…
downiec Aug 16, 2023
d2f5e24
Skipped one more failing test
downiec Aug 16, 2023
a39b1b4
ome minor fixes to improve coverage
downiec Aug 22, 2023
3032e97
wget api post initial test.
downiec Aug 22, 2023
f803d80
Merge branch 'integration-keycloak' into fix_wget_script
sashakames Aug 22, 2023
5bbf0b0
update view
sashakames Aug 22, 2023
c15f7b4
Fixed issue where the 'downloading' icon continues to show even after…
downiec Aug 22, 2023
0f110af
fix post on backend do_request
sashakames Aug 22, 2023
ee68b57
Merge branch 'fix_wget_script' of https://github.com/aims-group/metag…
sashakames Aug 22, 2023
d224665
Added timestamp for the wget script filename.
downiec Aug 22, 2023
2c448b0
Merge branch 'fix_wget_script' into globus_dev_demo_updates and ignor…
downiec Aug 23, 2023
d1dc1c2
Updated comment regarding the fetchWgetScript
downiec Aug 23, 2023
92c675b
fix issue using legacy wget API, need to unpack arrays them pass as data
sashakames Aug 23, 2023
cef39e6
Merge branch 'fix_wget_script' of https://github.com/aims-group/metag…
sashakames Aug 23, 2023
80f040f
resolve
sashakames Aug 23, 2023
01b86d5
Merged in the beta_integration branch
downiec Aug 24, 2023
d72bacb
Updated the version number and changelog.
downiec Aug 24, 2023
6cfe4c4
Integrated changes to keycloak from the integration_keycloak brannch
downiec Aug 24, 2023
f4abff8
Fixed some issue with the custom-render and the message displayed on …
downiec Aug 24, 2023
3df0aee
Minor patch to the updateProjects.sh script
downiec Aug 25, 2023
1152b59
Updated change log notes.
downiec Aug 25, 2023
c9696ef
fixed minor typos
downiec Aug 29, 2023
ebb8911
Skipped some broken tests that were failing from the keycloak changes…
downiec Sep 13, 2023
4186332
fix backend post parameters for wget
sashakames Sep 13, 2023
17c3f25
resolve and switch django
sashakames Sep 14, 2023
b3e4e21
change dataset_id param to consistently be a list
sashakames Sep 14, 2023
f732e4d
Updated django version, skipped more tests that were failing, fixed i…
downiec Sep 15, 2023
bea3172
Updated the config with correct keycloak url to fix signin issue. Rec…
downiec Sep 22, 2023
df15dc1
Lots of cleanup and test progress. Removed more unused functions and …
downiec Sep 30, 2023
0a43d10
Increased coverage by removing unused ModalContext.tsx component, upd…
downiec Oct 11, 2023
f648a21
Updated django version.
downiec Oct 12, 2023
22f908d
Created more mock functions and modified tests to improve coverage. C…
downiec Nov 5, 2023
09be58e
Created several more extensive tests for the Globus download componen…
downiec Nov 17, 2023
7dce05e
Globus dev demo updates keycloak (#568)
sturoscy-personal Nov 21, 2023
e4a4927
Refactored customRender in test so that it shows tat Keycloak is used…
downiec Nov 28, 2023
21efea5
Updated the DatasetDownload tests to include testing the PKCE respons…
downiec Dec 5, 2023
3f33958
Added a few more tests to get general coverage over 95%
downiec Dec 12, 2023
872865f
Updating workflow files and Django version, to see if backend passes …
downiec Dec 12, 2023
39a08d9
Check if updating node version or package.json, would affect tests.
downiec Dec 14, 2023
3a649f2
Globus dev demo updates tests (#575)
sturoscy-personal Dec 15, 2023
da86162
Finally fixed issue with istanbul coverage display incorrectly displa…
downiec Dec 15, 2023
065d6f5
Updated package.json to se if lockfile error will go away. Updated th…
downiec Dec 19, 2023
81122ad
Fixed a few more tests by creating new helper function which correctl…
downiec Dec 20, 2023
6b14c7a
Consolidated the test setup, by moving test mocks to the setupTests.t…
downiec Dec 22, 2023
8237dc6
Had to skip a test that seems to only fail on github CI, but works lo…
downiec Dec 22, 2023
d765ed2
Added config file for codecov so that we can set the coverage thresho…
downiec Dec 22, 2023
b9de39e
Updated the patch threshold for codecov and removed unneded print sta…
downiec Dec 22, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions .github/workflows/backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,20 @@ defaults:
env:
DJANGO_SETTINGS_MODULE: metagrid.config.local
DOMAIN_NAME: http://localhost:8000
DJANGO_SECURE_SSL_REDIRECT: False
CORS_ORIGIN_WHITELIST: http://localhost:3000
KEYCLOAK_URL: http://keycloak:8080/auth
KEYCLOAK_REALM: metagrid
KEYCLOAK_CLIENT_ID: backend
KEYCLOAK_URL: https://esgf-login.ceda.ac.uk/
KEYCLOAK_REALM: esgf
KEYCLOAK_CLIENT_ID: metagrid-localhost
DATABASE_URL: pgsql://postgres:postgres@localhost:5432/postgres
REACT_APP_SEARCH_URL: https://esgf-node.llnl.gov/esg-search/search
REACT_APP_WGET_API_URL: https://esgf-node.llnl.gov/esg-search/wget
REACT_APP_ESGF_NODE_STATUS_URL: https://aims2.llnl.gov/metagrid-backend/proxy/status
REACT_APP_ESGF_SOLR_URL: https://esgf-fedtest.llnl.gov/solr
DJANGO_LOGIN_REDIRECT_URL: http://localhost:3000/search
DJANGO_LOGOUT_REDIRECT_URL: http://localhost:3000/search
GLOBUS_CLIENT_KEY: 12345
GLOBUS_CLIENT_SECRET: 12345

jobs:
build:
Expand Down
11 changes: 5 additions & 6 deletions .github/workflows/frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,20 @@ defaults:
working-directory: frontend

env:
REACT_APP_CORS_PROXY_URL: http://localhost:3001
REACT_APP_KEYCLOAK_REALM: metagrid
REACT_APP_KEYCLOAK_URL: http://keycloak:8080/auth
REACT_APP_KEYCLOAK_CLIENT_ID: frontend
REACT_APP_KEYCLOAK_REALM: esgf
REACT_APP_KEYCLOAK_URL: https://esgf-login.ceda.ac.uk/
REACT_APP_KEYCLOAK_CLIENT_ID: metagrid-localhost

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Use Node.js 18.x
- name: Use Node.js 21.x
uses: actions/setup-node@v2
with:
node-version: "18.x"
node-version: "21.x"

- name: Cache node modules
uses: actions/cache@v2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
uses: actions/checkout@v2

# Required to run the local ESLint hook
- name: Use Node.js 18.x
- name: Use Node.js 21.x
uses: actions/setup-node@v2
with:
node-version: "18.x"
node-version: "21.x"

- name: Cache node modules
uses: actions/cache@v2
Expand Down
3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ repos:
args: ["--config=backend/pyproject.toml"]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.790
rev: v0.950
hooks:
- id: mypy
additional_dependencies: ["types-requests"]

# Front-end
# ------------------------------------------------------------------------------
Expand Down
5 changes: 2 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"typescript",
"typescriptreact"
],
"eslint.workingDirectories": ["./frontend/"],
// Jest
// -----------------------------
"jest.pathToJest": "yarn test:watch",
Expand All @@ -76,7 +77,5 @@
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"python.analysis.extraPaths": [
"backend/venv/bin/python"
]
"python.analysis.extraPaths": ["backend/venv/bin/python"]
}
3 changes: 2 additions & 1 deletion backend/.coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ omit =
*postgres-data/*,
*tests/*,
*venv/*,
*config/*
*config/*,
*tests*

[report]
# Regexes for lines to exclude from consideration
Expand Down
19 changes: 16 additions & 3 deletions backend/.envs/.django
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@
DJANGO_SETTINGS_MODULE=config.settings.local
DOMAIN_NAME=http://localhost:8000

# Security
# ------------------------------------------------------------------------------
DJANGO_SECURE_SSL_REDIRECT=False

# django-cors-headers
# ------------------------------------------------------------------------------
CORS_ORIGIN_WHITELIST=http://localhost:3000

# django-all-auth
# ------------------------------------------------------------------------------
KEYCLOAK_URL=http://keycloak:8080/auth
KEYCLOAK_REALM=metagrid
KEYCLOAK_CLIENT_ID=backend
KEYCLOAK_URL=https://esgf-login.ceda.ac.uk/
KEYCLOAK_REALM=esgf
KEYCLOAK_CLIENT_ID=metagrid-localhost

# ESGF wget API
# https://github.com/ESGF/esgf-wget
Expand All @@ -27,3 +31,12 @@ REACT_APP_ESGF_NODE_STATUS_URL=https://aims2.llnl.gov/metagrid-backend/proxy/sta

# ESGF Solr URL
REACT_APP_ESGF_SOLR_URL=https://esgf-fedtest.llnl.gov/solr

# https://docs.djangoproject.com/en/4.2/ref/settings/#login-redirect-url
# https://docs.djangoproject.com/en/4.2/ref/settings/#logout-redirect-url
DJANGO_LOGIN_REDIRECT_URL=http://localhost:3000/search
DJANGO_LOGOUT_REDIRECT_URL=http://localhost:3000/search

# https://app.globus.org/settings/developers/registration/confidential_client
GLOBUS_CLIENT_KEY=12345
GLOBUS_CLIENT_SECRET=12345
42 changes: 41 additions & 1 deletion backend/config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@
"allauth.socialaccount.providers.keycloak",
"dj_rest_auth",
"drf_yasg",
"social_django",
# Your apps
"metagrid.api_proxy",
"metagrid.users",
"metagrid.projects",
"metagrid.cart",
Expand All @@ -80,10 +82,18 @@
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
"social_django.middleware.SocialAuthExceptionMiddleware",
)

SESSION_SAVE_EVERY_REQUEST = True

# Authentication backends setup OAuth2 handling and where user data should be
# stored
AUTHENTICATION_BACKENDS = [
"globus_portal_framework.auth.GlobusOpenIdConnect",
"django.contrib.auth.backends.ModelBackend",
]

# https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts
ALLOWED_HOSTS = ["localhost", "0.0.0.0", "127.0.0.1"]
ROOT_URLCONF = "config.urls"
Expand Down Expand Up @@ -250,6 +260,8 @@
"rest_framework.permissions.IsAuthenticated"
],
"DEFAULT_AUTHENTICATION_CLASSES": (
"rest_framework.authentication.BasicAuthentication",
"rest_framework.authentication.SessionAuthentication",
"dj_rest_auth.jwt_auth.JWTCookieAuthentication",
),
}
Expand Down Expand Up @@ -287,6 +299,32 @@
# Access tokens are used to validate a user
ACCOUNT_EMAIL_VERIFICATION = "none"

# social_django
# -------------------------------------------------------------------------------
# This is a general Django setting if views need to redirect to login
# https://docs.djangoproject.com/en/3.2/ref/settings/#login-url
LOGIN_URL = "/login/globus/"

LOGIN_REDIRECT_URL = env("DJANGO_LOGIN_REDIRECT_URL")
LOGOUT_REDIRECT_URL = env("DJANGO_LOGOUT_REDIRECT_URL")

# This dictates which scopes will be requested on each user login
SOCIAL_AUTH_GLOBUS_SCOPE = [
"openid",
"profile",
"email",
"urn:globus:auth:scope:search.api.globus.org:all",
"urn:globus:auth:scope:transfer.api.globus.org:all",
]

SOCIAL_AUTH_GLOBUS_KEY = env("GLOBUS_CLIENT_KEY")
SOCIAL_AUTH_GLOBUS_SECRET = env("GLOBUS_CLIENT_SECRET")
SOCIAL_AUTH_GLOBUS_AUTH_EXTRA_ARGUMENTS = {
"requested_scopes": SOCIAL_AUTH_GLOBUS_SCOPE,
"prompt": None,
}
SOCIAL_AUTH_JSONFIELD_ENABLED = True

# dj-rest-auth
# -------------------------------------------------------------------------------
# https://dj-rest-auth.readthedocs.io/en/latest/index.html
Expand All @@ -296,7 +334,9 @@
# django-cors-headers
# -------------------------------------------------------------------------------
# https://github.com/adamchainz/django-cors-headers#setup
CORS_ORIGIN_ALLOW_ALL = False
CORS_ALLOWED_ORIGINS = [
"http://localhost:3000",
]
CORS_ALLOW_CREDENTIALS = True
CORS_ORIGIN_WHITELIST = env.list("CORS_ORIGIN_WHITELIST")

Expand Down
6 changes: 6 additions & 0 deletions backend/config/settings/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,9 @@
"whitenoise.runserver_nostatic",
"django_extensions",
] + INSTALLED_APPS # noqa F405

CORS_ORIGIN_ALLOW_ALL = True

CSRF_TRUSTED_ORIGINS = ["http://localhost:3000"]

SOCIAL_AUTH_REDIRECT_IS_HTTPS = False
2 changes: 2 additions & 0 deletions backend/config/settings/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,5 @@
# ------------------------------------------------------------------------------
# Django Admin URL regex.
ADMIN_URL = env("DJANGO_ADMIN_URL")

CORS_ORIGIN_ALLOW_ALL = False
6 changes: 6 additions & 0 deletions backend/config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
from metagrid.api_globus.views import do_globus_transfer, get_access_token
from metagrid.api_proxy.views import (
do_citation,
do_globus_auth,
do_globus_logout,
do_search,
do_status,
do_wget,
Expand Down Expand Up @@ -50,6 +52,10 @@ class KeycloakLogin(SocialLoginView):
r"^$",
RedirectView.as_view(url=reverse_lazy("api-root"), permanent=False),
),
# social_auth
path("", include("social_django.urls", namespace="social")),
path("proxy/globus-logout/", do_globus_logout, name="globus-logout"),
path("proxy/globus-auth/", do_globus_auth, name="globus-auth"),
# all-auth
path("accounts/", include("allauth.urls"), name="socialaccount_signup"),
# dj-rest-auth
Expand Down
17 changes: 0 additions & 17 deletions backend/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,6 @@ services:
ports:
- "5433:5432"

keycloak:
# Source: https://github.com/keycloak/keycloak-containers/blob/master/docker-compose-examples/keycloak-postgres.yml
image: jboss/keycloak
container_name: keycloak
# https://github.com/jhipster/generator-jhipster/issues/7157#issuecomment-367813386
depends_on:
- postgres
volumes:
- ./docker/local/keycloak:/opt/jboss/keycloak/imports
env_file:
- ./.envs/.keycloak
ports:
- "8080:8080"
command: -Dkeycloak.import=/opt/jboss/keycloak/imports/realm-export.json
-Dkeycloak.migration.strategy=IGNORE_EXISTING

django:
build:
context: .
Expand All @@ -46,7 +30,6 @@ services:
container_name: django
depends_on:
- postgres
- keycloak
volumes:
- .:/app
env_file:
Expand Down
1 change: 1 addition & 0 deletions backend/docker/local/django/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
FROM python:3.9-slim-buster

ENV DATABASE_URL postgres://postgres:postgres@postgres:5432/postgres
ENV PYTHONUNBUFFERED 1
ENV PYTHONDONTWRITEBYTECODE 1

Expand Down
Loading
Loading