mreg-cli 1.2.1__tar.gz → 1.2.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/.github/workflows/test.yml +4 -8
  2. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/CHANGELOG.md +17 -0
  3. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/CONTRIBUTING +4 -0
  4. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/PKG-INFO +1 -1
  5. mreg_cli-1.2.3/ci/Dockerfile +13 -0
  6. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/ci/diff.py +3 -3
  7. mreg_cli-1.2.3/ci/run_testsuite_and_record_V2.sh +88 -0
  8. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/ci/testsuite-result.json +2262 -133
  9. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/mreg_cli/_version.py +2 -2
  10. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/mreg_cli/api/abstracts.py +1 -0
  11. mreg_cli-1.2.3/mreg_cli/api/fields.py +172 -0
  12. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/mreg_cli/api/history.py +1 -1
  13. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/mreg_cli/api/models.py +150 -178
  14. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/mreg_cli/cli.py +13 -4
  15. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/mreg_cli/commands/dhcp.py +11 -17
  16. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/mreg_cli/commands/group.py +3 -3
  17. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/mreg_cli/commands/help.py +0 -1
  18. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/mreg_cli/commands/host_submodules/a_aaaa.py +100 -49
  19. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/mreg_cli/commands/host_submodules/bacnet.py +3 -3
  20. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/mreg_cli/commands/host_submodules/cname.py +27 -20
  21. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/mreg_cli/commands/host_submodules/core.py +29 -26
  22. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/mreg_cli/commands/host_submodules/rr.py +32 -27
  23. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/mreg_cli/commands/logging.py +1 -1
  24. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/mreg_cli/commands/network.py +2 -3
  25. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/mreg_cli/commands/policy.py +4 -4
  26. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/mreg_cli/config.py +1 -1
  27. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/mreg_cli/exceptions.py +48 -3
  28. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/mreg_cli/outputmanager.py +3 -6
  29. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/mreg_cli/prompt.py +6 -4
  30. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/mreg_cli/tokenfile.py +3 -3
  31. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/mreg_cli/types.py +29 -0
  32. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/mreg_cli/utilities/api.py +10 -2
  33. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/mreg_cli.egg-info/PKG-INFO +1 -1
  34. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/mreg_cli.egg-info/SOURCES.txt +5 -0
  35. mreg_cli-1.2.3/tests/api/test_fields.py +269 -0
  36. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/tests/conftest.py +10 -0
  37. mreg_cli-1.2.3/tests/test_exceptions.py +175 -0
  38. mreg_cli-1.2.3/tests/test_outputmanager.py +98 -0
  39. mreg_cli-1.2.3/tests/test_types.py +15 -0
  40. mreg_cli-1.2.1/mreg_cli/api/fields.py +0 -137
  41. mreg_cli-1.2.1/tests/api/test_fields.py +0 -144
  42. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/.github/workflows/publish.yml +0 -0
  43. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/.gitignore +0 -0
  44. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/.markdownlint.json +0 -0
  45. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/AUTHORS +0 -0
  46. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/LICENSE +0 -0
  47. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/README.md +0 -0
  48. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/ci/docker-compose.yml +0 -0
  49. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/ci/run_testsuite_and_record.sh +0 -0
  50. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/ci/testsuite +0 -0
  51. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/data/mreg-cli.conf +0 -0
  52. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/mreg_cli/__about__.py +0 -0
  53. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/mreg_cli/__init__.py +0 -0
  54. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/mreg_cli/__main__.py +0 -0
  55. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/mreg_cli/api/__init__.py +0 -0
  56. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/mreg_cli/api/endpoints.py +0 -0
  57. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/mreg_cli/commands/__init__.py +0 -0
  58. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/mreg_cli/commands/base.py +0 -0
  59. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/mreg_cli/commands/host.py +0 -0
  60. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/mreg_cli/commands/host_submodules/__init__.py +0 -0
  61. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/mreg_cli/commands/label.py +0 -0
  62. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/mreg_cli/commands/permission.py +0 -0
  63. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/mreg_cli/commands/recording.py +0 -0
  64. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/mreg_cli/commands/registry.py +0 -0
  65. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/mreg_cli/commands/root.py +0 -0
  66. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/mreg_cli/commands/zone.py +0 -0
  67. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/mreg_cli/errorbuilder.py +0 -0
  68. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/mreg_cli/help_formatter.py +0 -0
  69. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/mreg_cli/main.py +0 -0
  70. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/mreg_cli/py.typed +0 -0
  71. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/mreg_cli/tags.txt +0 -0
  72. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/mreg_cli/utilities/__init__.py +0 -0
  73. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/mreg_cli/utilities/shared.py +0 -0
  74. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/mreg_cli/utilities/validators.py +0 -0
  75. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/mreg_cli.egg-info/dependency_links.txt +0 -0
  76. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/mreg_cli.egg-info/entry_points.txt +0 -0
  77. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/mreg_cli.egg-info/requires.txt +0 -0
  78. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/mreg_cli.egg-info/top_level.txt +0 -0
  79. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/pyproject.toml +0 -0
  80. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/run.py +0 -0
  81. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/setup.cfg +0 -0
  82. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/tests/__init__.py +0 -0
  83. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/tests/api/__init__.py +0 -0
  84. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/tests/api/test_models.py +0 -0
  85. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/tests/test_errorbuilder.py +0 -0
  86. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/tests/test_prompt.py +0 -0
  87. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/tests/test_tokenfile.py +0 -0
  88. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/tests/utilities/__init__.py +0 -0
  89. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/tests/utilities/test_api.py +0 -0
  90. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/tox.ini +0 -0
  91. {mreg_cli-1.2.1 → mreg_cli-1.2.3}/uv.lock +0 -0
@@ -14,20 +14,15 @@ jobs:
14
14
  python-version:
15
15
  - '3.11'
16
16
  - '3.12'
17
+ - '3.13'
17
18
  env:
18
19
  # Disable colors and formatting in Rich console output
19
20
  TERM: dumb
20
21
  steps:
21
22
  - name: Checkout
22
23
  uses: actions/checkout@v4
23
- - name: Install uv
24
- uses: astral-sh/setup-uv@v2
25
- - name: Set up Python ${{ matrix.python-version }}
26
- run: uv python install ${{ matrix.python-version }}
27
- - name: Install mreg-cli
28
- run: uv sync
29
24
  - name: Test and compare api calls
30
- run: uv run ci/run_testsuite_and_record.sh
25
+ run: ci/run_testsuite_and_record_V2.sh ${{ matrix.python-version }}
31
26
 
32
27
  tox:
33
28
  name: tox
@@ -68,6 +63,7 @@ jobs:
68
63
  python-version:
69
64
  - "3.11"
70
65
  - "3.12"
66
+ - '3.13'
71
67
  steps:
72
68
  - uses: actions/checkout@v4
73
69
  - name: Install uv
@@ -77,4 +73,4 @@ jobs:
77
73
  - name: Install dependencies
78
74
  run: uv sync
79
75
  - name: Run unittest
80
- run: uv run pytest
76
+ run: uv run pytest
@@ -7,6 +7,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  <!-- ## Unreleased -->
9
9
 
10
+ ## [1.2.3](https://github.com/unioslo/mreg-cli/releases/tag/1.2.3) - 2024-12-16
11
+
12
+ ### Added
13
+
14
+ - `a_add` & `aaaa_add` `-force` option to force use an IP from a network that cannot be found in MREG.
15
+
16
+ ### Fixed
17
+
18
+ - Commands that try to find networks by IP raising a 404 error instead of a proper error message when no network can be found with the given IP.
19
+
20
+ ## [1.2.2](https://github.com/unioslo/mreg-cli/releases/tag/1.2.2) - 2024-12-09
21
+
22
+ ### Fixed
23
+
24
+ - `dhcp assoc` and `host add` commands displaying unique constraint error instead of a proper error message when a MAC is already associated with an IP.
25
+ - Validation errors causing the application to crash instead of displaying a proper error message.
26
+
10
27
  ## [1.2.1](https://github.com/unioslo/mreg-cli/releases/tag/1.2.1) - 2024-12-02
11
28
 
12
29
  ### Fixed
@@ -9,6 +9,10 @@ If you would like to contribute to this project, please follow these steps:
9
9
  5. Push to the branch (`git push origin feature/branch-name`)
10
10
  6. Create a Pull Request
11
11
 
12
+ ## Testing
13
+
14
+ To run tests locally, just run the script `ci/run_testsuite_and_record_V2.sh` from anywhere. The only prerequisite is a working installation of docker or podman.
15
+
12
16
  ## Publishing
13
17
 
14
18
  Publishing new versions is automatically handled by GitHub actions for versions tagged with `x.y.z[.prerelease]` (`1.2.3`, `1.2.3.rc1`, etc.). If you are a maintainer, you can create a new release by following these steps:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mreg-cli
3
- Version: 1.2.1
3
+ Version: 1.2.3
4
4
  Summary: MREG interactive command line client
5
5
  Author: Others (see AUTHORS)
6
6
  Author-email: Øyvind Kolbu <oyvind.kolbu@usit.uio.no>, Safet A <amedov@usit.uio.no>, Magnus Hirth <mhmorgan42@gmail.com>, Nico <nicolaydmohebi@gmail.com>, Marius Bakke <marius.bakke@usit.uio.no>, Fredrik Larsen <fredrik.larsen@usit.uio.no>, Paal Braathen <paal.braathen@usit.uio.no>, Nils Hiorth <nils@nls.me>, Dmytro Karpenko <dmytrok@usit.uio.no>
@@ -0,0 +1,13 @@
1
+ # This container image is only used temporarily for testing during a CI process.
2
+ FROM ubuntu:latest
3
+ ARG python_version=3.12
4
+
5
+ RUN apt-get -qq update
6
+ RUN apt-get -y install curl git >/dev/null
7
+ RUN curl -LsSf https://astral.sh/uv/0.5.6/install.sh | sh
8
+ RUN /root/.local/bin/uv self update -q
9
+ RUN /root/.local/bin/uv python install ${python_version}
10
+ COPY . /build
11
+ RUN cd /build; /root/.local/bin/uv sync -q
12
+
13
+ CMD cd /build/ci; /root/.local/bin/uv run bash -c 'echo "test" | mreg-cli -u test -d example.org --url http://127.0.0.1:8000 --source testsuite --record new_testsuite_log.json --record-without-timestamps -v ERROR >/dev/null'
@@ -126,7 +126,7 @@ def preprocess_json(s: str) -> str:
126
126
 
127
127
  # Replace all non-deterministic values with placeholders
128
128
  s = timestamp_pattern.sub("<TIME>", s)
129
- s = datetime_str_pattern.sub("<TIME>", s)
129
+ s = datetime_str_pattern.sub("<DATETIME>", s)
130
130
  s = serial_pattern.sub("Serial: <NUMBER>", s)
131
131
  s = mac_pattern.sub("<macaddress>", s)
132
132
  s = ipv4_pattern.sub("<IPv4>", s)
@@ -290,8 +290,8 @@ class CommandDiffer:
290
290
  new_testsuite_results.append(expected.original)
291
291
  self.diff_unresolved += 1
292
292
  else:
293
- # No diff, keep new line
294
- new_testsuite_results.append(result.original)
293
+ # No diff, keep old line
294
+ new_testsuite_results.append(expected.original)
295
295
 
296
296
  # Only write back changes if we are in review mode and there are changes
297
297
  if self.review and self.diff_resolved > 0:
@@ -0,0 +1,88 @@
1
+ #!/bin/bash
2
+
3
+ # exit immediately on error
4
+ set -e
5
+
6
+ # check if we have docker or podman
7
+ if command -v docker >/dev/null 2>&1 && ! docker 2>&1 | grep -q podman; then
8
+ echo "Using Docker"
9
+ GH_PARAMS="--ansi=never"
10
+ elif command -v podman >/dev/null 2>&1; then
11
+ echo "Using Podman"
12
+ GH_PARAMS="--no-ansi"
13
+ PODMAN=1
14
+ alias docker=podman
15
+ else
16
+ echo "Found neither docker nor podman."
17
+ exit 1
18
+ fi
19
+
20
+ # clean up on exit, even if something fails
21
+ function cleanup {
22
+ set +e
23
+ if [[ -n "$GITHUB_ACTIONS" ]]; then
24
+ docker compose $GH_PARAMS down
25
+ else
26
+ docker compose down
27
+ fi
28
+ docker ps -a | grep "mreg-" | awk '{print $1}' | xargs -r docker stop
29
+ docker ps -a | grep "mreg-" | awk '{print $1}' | xargs -r docker rm
30
+ docker images | grep "mreg-" | awk '{print $1}' | xargs -r docker rmi
31
+ rm -f new_testsuite_log.json
32
+ echo "cleanup done."
33
+ }
34
+ trap cleanup EXIT
35
+
36
+ # chdir to where this script is
37
+ cd `dirname $0`
38
+
39
+ # get Python version from argument
40
+ PYTHON_VERSION=3.12
41
+ if [ ! -z "$1" ]; then
42
+ PYTHON_VERSION=$1
43
+ fi
44
+ echo "Python version $PYTHON_VERSION"
45
+
46
+ # build a container image for mreg-cli
47
+ docker build -f Dockerfile -t mreg-cli --build-arg python_version=$PYTHON_VERSION ..
48
+
49
+ # start mreg+postgres in containers
50
+ if [[ -n "$GITHUB_ACTIONS" ]]; then
51
+ if [[ "$PODMAN" == "1" ]]; then
52
+ docker compose $GH_PARAMS pull >/dev/null 2>&1
53
+ else
54
+ docker compose $GH_PARAMS pull --quiet
55
+ fi
56
+ docker compose $GH_PARAMS up -d
57
+ else
58
+ docker compose up -d
59
+ fi
60
+
61
+ # give mreg some time to create the database schema and start up
62
+ sleep 5s
63
+
64
+ # create a superuser
65
+ if docker exec -t mreg uv version >/dev/null; then
66
+ docker exec -t mreg uv run /app/manage.py create_mreg_superuser --username test --password test
67
+ else
68
+ docker exec -t mreg /app/manage.py create_mreg_superuser --username test --password test
69
+ fi
70
+
71
+ # test connectivity
72
+ #docker run --rm --tty --network host --entrypoint curl mreg-cli --head http://127.0.0.1:8000/admin/login/
73
+
74
+ # start the mreg-cli container, which will automatically run the test suite
75
+ echo "Running the tests..."
76
+ docker run --name mreg-cli --network host --tty mreg-cli
77
+ docker commit mreg-cli finished-mreg-tests # because inside is the file new_testsuite_log.json which we want to look at
78
+
79
+ # show a detailed diff (and review if running locally)
80
+ if [[ -n "$GITHUB_ACTIONS" ]]; then
81
+ docker run --rm --tty --entrypoint bash finished-mreg-tests -c 'cd /build/ci; /root/.local/bin/uv run diff.py testsuite-result.json new_testsuite_log.json'
82
+ exit $?
83
+ else
84
+ docker run -it --name finished-mreg-tests --entrypoint bash finished-mreg-tests -c 'cd /build/ci; /root/.local/bin/uv run diff.py testsuite-result.json new_testsuite_log.json --review'
85
+ EXITCODE=$?
86
+ docker cp finished-mreg-tests:/build/ci/testsuite-result.json .
87
+ exit $EXITCODE
88
+ fi