Skip to content

Commit

Permalink
chore(deps): update dependency ops to v2.18.0 (#250)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Arturo Seijas <[email protected]>
Co-authored-by: Weii Wang <[email protected]>
  • Loading branch information
3 people authored Feb 10, 2025
1 parent 7b93a33 commit ef01145
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 44 deletions.
1 change: 1 addition & 0 deletions .github/workflows/integration_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ jobs:
./tests/integration/pre_run_script.sh"
setup-devstack-swift: true
trivy-image-config: ./trivy.yaml
channel: 1.31/stable
3 changes: 3 additions & 0 deletions .licenserc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ header:
content: |
Copyright [year] [owner]
See LICENSE file for licensing details.
pattern: |
Copyright \d{4} Canonical Ltd.
See LICENSE file for licensing details.
paths:
- '**'
paths-ignore:
Expand Down
4 changes: 4 additions & 0 deletions .trivyignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ CVE-2023-45287
CVE-2023-45288
CVE-2024-24790
CVE-2024-34156
# golang
CVE-2024-45337
CVE-2024-45338

2 changes: 1 addition & 1 deletion charmcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ parts:
- requests
- ops-lib-mysql
charm-binary-python-packages:
- mysql-connector-python
- mysql-connector-python==9.1.0
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
mysql-connector-python
ops==2.17.1
ops==2.18.0
requests==2.32.3
pydantic>=1,<2
4 changes: 3 additions & 1 deletion tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,9 @@ async def prepare_swift(wordpress: WordpressApp, swift_config: Dict[str, str]):
@pytest_asyncio.fixture(scope="module")
async def prepare_nginx_ingress(wordpress: WordpressApp, prepare_mysql):
"""Deploy and relate nginx-ingress-integrator charm for integration tests."""
await wordpress.model.deploy("nginx-ingress-integrator", series="focal", trust=True)
await wordpress.model.deploy(
"nginx-ingress-integrator", channel="latest/edge", series="focal", revision=133, trust=True
)
await wordpress.model.wait_for_idle(apps=["nginx-ingress-integrator"], timeout=30 * 60)
await wordpress.model.relate(f"{wordpress.name}:nginx-route", "nginx-ingress-integrator")
await wordpress.model.wait_for_idle(status="active")
Expand Down
47 changes: 6 additions & 41 deletions tests/integration/test_ingress.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@

"""Integration tests for WordPress charm ingress integration."""

import socket
import unittest.mock

import kubernetes
import pytest
import requests
Expand All @@ -21,37 +18,6 @@ async def test_ingress(wordpress: WordpressApp):
and WordPress charm.
assert: A Kubernetes ingress should be created and the ingress should accept HTTPS connections.
"""

def gen_patch_getaddrinfo(host: str, resolve_to: str):
"""Generate patched getaddrinfo function.
This function is used to generate a patched getaddrinfo function that will resolve to the
resolve_to address without having to actually register a host.
Args:
host: intended hostname of a given application.
resolve_to: destination address for host to resolve to.
Returns:
A patching function for getaddrinfo.
"""
original_getaddrinfo = socket.getaddrinfo

def patched_getaddrinfo(*args):
"""Patch getaddrinfo to point to desired ip address.
Args:
args: original arguments to getaddrinfo when creating network connection.
Returns:
Patched getaddrinfo function.
"""
if args[0] == host:
return original_getaddrinfo(resolve_to, *args[1:])
return original_getaddrinfo(*args)

return patched_getaddrinfo

response = requests.get("http://127.0.0.1", headers={"Host": wordpress.name}, timeout=5)
assert (
response.status_code == 200 and "wordpress" in response.text.lower()
Expand All @@ -60,13 +26,12 @@ def patched_getaddrinfo(*args):
new_hostname = "wordpress.test"
await wordpress.set_config({"blog_hostname": new_hostname})
await wordpress.model.wait_for_idle(status="active")
with unittest.mock.patch.multiple(
socket, getaddrinfo=gen_patch_getaddrinfo(new_hostname, "127.0.0.1")
):
response = requests.get(f"https://{new_hostname}", timeout=5, verify=False) # nosec
assert (
response.status_code == 200 and "wordpress" in response.text.lower()
), "Ingress should update the server name indication based routing after blog_hostname updated"
response = requests.get(
"https://127.0.0.1", headers={"Host": new_hostname}, timeout=5, verify=False
) # nosec
assert (
response.status_code == 200 and "wordpress" in response.text.lower()
), "Ingress should update the server name indication based routing after blog_hostname updated"


@pytest.mark.usefixtures("prepare_mysql", "prepare_nginx_ingress", "prepare_swift")
Expand Down

0 comments on commit ef01145

Please sign in to comment.