Skip to content

Commit

Permalink
bump pulpcore, pulp_ansible, pulp_container and django 4.x. (#1753)
Browse files Browse the repository at this point in the history
* Upgrade to django 4.x.

No-Issue

Signed-off-by: James Tanner <[email protected]>
  • Loading branch information
jctanner authored Jul 5, 2023
1 parent ed413f9 commit 803afa4
Show file tree
Hide file tree
Showing 18 changed files with 377 additions and 111 deletions.
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@ docker/test/integration/container: ## Run integration tests.

.PHONY: docker/loaddata
docker/loaddata: ## Load initial data from python script
#./compose run --rm api manage shell < app/dev/common/setup_test_data.py
$(call exec_or_run, api, bash, -c "django-admin shell < app/dev/common/setup_test_data.py")
$(call exec_or_run, api, "/bin/bash", "-c", "/entrypoint.sh manage shell < app/dev/common/setup_test_data.py")

.PHONY: docker/makemigrations
docker/makemigrations: ## Run django migrations
Expand Down Expand Up @@ -142,7 +141,7 @@ docker/db_restore: ## Restore database from a snapshot with optional NAME para

.PHONY: docker/translations
docker/translations: ## Generate the translation messages
./compose run --rm api bash -c "cd /app/galaxy_ng && django-admin makemessages --all"
$(call exec_or_run, api, "/bin/bash", "-c", "cd /app/galaxy_ng && /entrypoint.sh manage makemessages --all")

.PHONY: docker/all
docker/all: ## Build, migrate, loaddata, translate and add test collections.
Expand Down
14 changes: 14 additions & 0 deletions galaxy_ng/app/access_control/statements/pulp.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,20 @@
{"action": "*", "principal": "admin", "effect": "allow"},
]
},
"tasks": {
"statements": [
{
"action": ["list"],
"principal": "authenticated",
"effect": "allow",
},
{
"action": ["retrieve", "my_permissions"],
"principal": "authenticated",
"effect": "allow",
},
]
}
}


Expand Down
1 change: 1 addition & 0 deletions galaxy_ng/app/access_control/statements/roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"galaxy.add_containerregistryremote",
"galaxy.change_containerregistryremote",
"galaxy.delete_containerregistryremote",
"container.manage_roles_containernamespace"
},
"inherit_from": ["galaxy.execution_environment_publisher"],
},
Expand Down
4 changes: 4 additions & 0 deletions galaxy_ng/app/api/v3/viewsets/execution_environments.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ class Meta:
}

def has_permissions(self, queryset, name, value):
log.debug(
'GALAXY_NG repositoryfilter has_permissions queryset:'
+ f'{queryset} name:{name} value:{value}'
)
perms = self.request.query_params.getlist(name)
namespaces = get_objects_for_user(
self.request.user, perms, qs=container_models.ContainerNamespace.objects.all())
Expand Down
6 changes: 4 additions & 2 deletions galaxy_ng/app/dynaconf_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,11 @@ def configure_logging(settings: Dynaconf) -> Dict[str, Any]:
)
}
if data["GALAXY_ENABLE_API_ACCESS_LOG"]:
data["INSTALLED_APPS"] = ["automated_logging", "dynaconf_merge"]
data["INSTALLED_APPS"] = ["dynaconf_merge"]
data["MIDDLEWARE"] = [
"automated_logging.middleware.AutomatedLoggingMiddleware",
# We want to re-add this separately with a vendored copy
# since the upstream is no longer maintained.
# "automated_logging.middleware.AutomatedLoggingMiddleware",
"dynaconf_merge",
]
data["LOGGING"] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,9 @@ def _simple_csv(full_path, file_name, query, max_data_size=209715200):
tfile = _get_csv_splitter(file_path, max_data_size)

with Collector.db_connection().cursor() as cursor:
cursor.copy_expert(query, tfile)
with cursor.copy(query) as copy:
while data := copy.read():
tfile.write(str(data, 'utf8'))

return tfile.file_list()

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Generated by Django 4.2.1 on 2023-05-31 22:38

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):
dependencies = [
("core", "0106_alter_artifactdistribution_distribution_ptr_and_more"),
("galaxy", "0040_fix_collection_remote_pulp_type"),
]

operations = [
migrations.AlterField(
model_name="containerregistryremote",
name="remote_ptr",
field=models.OneToOneField(
auto_created=True,
on_delete=django.db.models.deletion.CASCADE,
parent_link=True,
primary_key=True,
serialize=False,
to="core.remote",
),
),
]
1 change: 0 additions & 1 deletion galaxy_ng/app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
'django_guid.middleware.guid_middleware',
# END: Pulp standard middleware
'django_prometheus.middleware.PrometheusAfterMiddleware',
'django_currentuser.middleware.ThreadLocalUserMiddleware',
]

INSTALLED_APPS = [
Expand Down
2 changes: 1 addition & 1 deletion galaxy_ng/app/urls.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.conf import settings
from django.conf.urls import url
from django.urls import re_path as url
from django.shortcuts import redirect
from django.urls import include, path

Expand Down
8 changes: 8 additions & 0 deletions galaxy_ng/tests/integration/api/test_iqe_rbac.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,10 +662,18 @@ def test_role_add_ee(self, galaxy_client):
"""
gc = galaxy_client("admin")
user, group = add_new_user_to_new_group(gc)

permissions_user = ["container.add_containernamespace"]
role_user = f"galaxy.rbac_test_role_{uuid4()}"
gc.create_role(role_user, "any_description", permissions_user)
gc.add_role_to_group(role_user, group["id"])

# this block added for pulp 3.27 upgrade ...
permissions_user = ["container.manage_roles_containernamespace"]
role_user = f"galaxy.rbac_test_role_{uuid4()}"
gc.create_role(role_user, "any_description2", permissions_user)
gc.add_role_to_group(role_user, group["id"])

remote_registry = f"remote_registry_{uuid4()}"
create_registry(gc, remote_registry, "url")
gc_user = galaxy_client(user)
Expand Down
2 changes: 1 addition & 1 deletion galaxy_ng/tests/integration/api/test_v3_plugin_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def test_api_v3_plugin_execution_environments_repositories_content_history(
validate_json(instance=resp, schema=schema_objectlist)

# assert on the expected minimum length of the dataset
assert resp['data'][0]['number'] >= 3
assert resp['data'][0]['number'] >= 1


# /api/automation-hub/v3/plugin/execution-environments/repositories/{base_path}/_content/images/
Expand Down
3 changes: 2 additions & 1 deletion galaxy_ng/tests/unit/api/test_api_ui_auth_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ def test_login_csrf_cookie_set_header_missing(self):

self._test_login_permission_denied(
data={"username": "test1", "password": "test1-secret"},
expected_detail="CSRF Failed: CSRF token missing or incorrect.",
# expected_detail="CSRF Failed: CSRF token missing or incorrect.",
expected_detail="CSRF Failed: CSRF token missing.",
client=client
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from django.test import TestCase
import os


s3_details = {
"aws_access_key_id": "blah",
"aws_secret_access_key": "blah",
Expand Down
2 changes: 1 addition & 1 deletion galaxy_ng/ui/urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.conf.urls import url
from django.urls import re_path as url
from django.views.generic import RedirectView


Expand Down
Loading

0 comments on commit 803afa4

Please sign in to comment.