Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/github-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ jobs:
- run: echo "💡 The ${{ github.repository }} repository has been cloned to ${{ github.workspace }}."
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
- run: echo "🧪 Run tests and Verification"
- run: ./ci.sh test
- run: ./ci/test.sh
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
__pycache__/
*.py[cod]
*$py.class
output/

# C extensions
*.so
Expand Down
28 changes: 22 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
FROM python:3.8.1-alpine
FROM jetpackio/devbox:latest

RUN apk add bash
RUN pip install pipenv
USER root:root
Comment thread
anevis marked this conversation as resolved.

ADD . /app
RUN rm -rf /homeless-shelter && \
mkdir -p /etc/nix && \
echo "sandbox = false" > /etc/nix/nix.conf && \
echo "build-users-group =" >> /etc/nix/nix.conf

ENV HOME=/tmp

WORKDIR /app
RUN pipenv install --dev --system --deploy --ignore-pipfile
RUN chown devbox:devbox /app

USER devbox

# Copy dependency files first for better caching
COPY --chown=devbox:devbox devbox.json devbox.lock ./
COPY --chown=devbox:devbox pyproject.toml uv.lock ./
COPY --chown=devbox:devbox scripts/ ./scripts/

# Install dependencies in separate layer for caching
RUN devbox run install

CMD ["./ci/_test.sh"]
# Copy remaining files
COPY --chown=devbox:devbox ci/ ./ci/
COPY --chown=devbox:devbox src/ ./src/
17 changes: 0 additions & 17 deletions Pipfile

This file was deleted.

424 changes: 0 additions & 424 deletions Pipfile.lock

This file was deleted.

35 changes: 28 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,50 @@ and EDAI. This also includes sample code that uses Two Factor Authentication (2F
_**Note:** 2FA for the user must use the `Software Token` method._

## Pre-requisites
Please see `Pipfile` for the Python dependencies.
- [Devbox](https://www.jetify.com/devbox)

Please see `pyproject.toml` for the Python dependencies.

## Setup
```bash
devbox run install
```

## Usage
To view the current usage/help please run the below command:
To view the current usage/help please run:

`$ python3 ./run.py -h`
```bash
devbox run help
```

Or directly:
```bash
python3 src/call.py -h
```

#### Examples

##### RAPI using 2FA
```
./run.py -b https://dev.xplan.iress.com.au -u testuser -p ASDDsf3sdsf2 -o HTHHH72MQ7CBVX3SU25YRKQO6OAI36TD -i FPj9cymketaHXunJE3E3 -tfa -api
```bash
devbox run call -b https://dev.xplan.iress.com.au -u testuser -p ASDDsf3sdsf2 -o HTHHH72MQ7CBVX3SU25YRKQO6OAI36TD -i FPj9cymketaHXunJE3E3 -tfa -api
```

##### EDAI using 2FA
```
./run.py -b https://dev.xplan.iress.com.au -u testuser -p ASDDsf3sdsf2 -o HTHHH72MQ7CBVX3SU25YRKQO6OAI36TD -i FPj9cymketaHXunJE3E3 -tfa -edai
```bash
devbox run call -b https://dev.xplan.iress.com.au -u testuser -p ASDDsf3sdsf2 -o HTHHH72MQ7CBVX3SU25YRKQO6OAI36TD -i FPj9cymketaHXunJE3E3 -tfa -edai
```

_**Note:**_
- If you don't specify a password using the `-p` option the script will prompt for the password
- If you don't specify an OTP Secret using the `-o` option the script will prompt for the secret

## Development
Available commands:
- `devbox run test` - Run tests
- `devbox run lint` - Run linting
- `devbox run format` - Format code
- `devbox run upgrade` - Upgrade dependencies

**Sample result of the above script:**
```
[
Expand Down
12 changes: 0 additions & 12 deletions ci.sh

This file was deleted.

10 changes: 7 additions & 3 deletions ci/_test.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
#!/usr/bin/env bash
set -euo pipefail

echo "Running Unit Tests and Coverage"
echo "Installing dependencies..."
devbox run install

coverage run
coverage report
echo "Linting code..."
devbox run lint

echo "Running Unit Tests and Coverage..."
devbox run test
2 changes: 1 addition & 1 deletion ci/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ set -euo pipefail

docker build -t iress/xplan-api-examples .

docker run iress/xplan-api-examples
docker run iress/xplan-api-examples ./ci/_test.sh
21 changes: 21 additions & 0 deletions devbox.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "iress-xplan-api-examples",
"packages": [
"python@3.14",
"uv@latest"
],
"shell": {
"init_hook": [
". ${VENV_DIR}/bin/activate"
],
"scripts": {
"call": "scripts/call.sh \"$@\"",
"format": "scripts/format.sh \"$@\"",
"help": "scripts/help.sh \"$@\"",
"install": "scripts/install.sh \"$@\"",
"lint": "scripts/lint.sh \"$@\"",
"test": "scripts/test.sh \"$@\"",
"upgrade": "scripts/upgrade.sh \"$@\""
}
}
}
114 changes: 114 additions & 0 deletions devbox.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
{
"lockfile_version": "1",
"packages": {
"github:NixOS/nixpkgs/nixpkgs-unstable": {
"last_modified": "2026-01-19T00:39:23Z",
"resolved": "github:NixOS/nixpkgs/bde09022887110deb780067364a0818e89258968?lastModified=1768783163&narHash=sha256-tLj4KcRDLakrlpvboTJDKsrp6z2XLwyQ4Zmo%2Bw8KsY4%3D"
},
"python@3.14": {
"last_modified": "2026-01-23T17:20:52Z",
"plugin_version": "0.0.4",
"resolved": "github:NixOS/nixpkgs/a1bab9e494f5f4939442a57a58d0449a109593fe#python314",
"source": "devbox-search",
"version": "3.14.2",
"systems": {
"aarch64-darwin": {
"outputs": [
{
"name": "out",
"path": "/nix/store/8bwmgvfcyys3kfia055ih7gask3fid7s-python3-3.14.2",
"default": true
}
],
"store_path": "/nix/store/8bwmgvfcyys3kfia055ih7gask3fid7s-python3-3.14.2"
},
"aarch64-linux": {
"outputs": [
{
"name": "out",
"path": "/nix/store/9zj2a40gbfh9scynfmfs1s9wx2q01yv3-python3-3.14.2",
"default": true
},
{
"name": "debug",
"path": "/nix/store/j8ryg1l3z8ibf9rn848y1vll0f0wcab7-python3-3.14.2-debug"
}
],
"store_path": "/nix/store/9zj2a40gbfh9scynfmfs1s9wx2q01yv3-python3-3.14.2"
},
"x86_64-darwin": {
"outputs": [
{
"name": "out",
"path": "/nix/store/0mnhsagxg8cp6cr9g0fz2dihw469ih8s-python3-3.14.2",
"default": true
}
],
"store_path": "/nix/store/0mnhsagxg8cp6cr9g0fz2dihw469ih8s-python3-3.14.2"
},
"x86_64-linux": {
"outputs": [
{
"name": "out",
"path": "/nix/store/hd3h6gjpy7pf5himwf8sfqb3108pz5ld-python3-3.14.2",
"default": true
},
{
"name": "debug",
"path": "/nix/store/2wvc4f32yycchbip56mlxixjm2sdzw2y-python3-3.14.2-debug"
}
],
"store_path": "/nix/store/hd3h6gjpy7pf5himwf8sfqb3108pz5ld-python3-3.14.2"
}
}
},
"uv@latest": {
"last_modified": "2026-01-30T02:32:49Z",
"resolved": "github:NixOS/nixpkgs/6308c3b21396534d8aaeac46179c14c439a89b8a#uv",
"source": "devbox-search",
"version": "0.9.27",
"systems": {
"aarch64-darwin": {
"outputs": [
{
"name": "out",
"path": "/nix/store/bj9jidx7h317hmnz220qpka6850sjvi1-uv-0.9.27",
"default": true
}
],
"store_path": "/nix/store/bj9jidx7h317hmnz220qpka6850sjvi1-uv-0.9.27"
},
"aarch64-linux": {
"outputs": [
{
"name": "out",
"path": "/nix/store/2703hnsgll85c1rpzzqycnmp0jvy579z-uv-0.9.27",
"default": true
}
],
"store_path": "/nix/store/2703hnsgll85c1rpzzqycnmp0jvy579z-uv-0.9.27"
},
"x86_64-darwin": {
"outputs": [
{
"name": "out",
"path": "/nix/store/il24573a65xa0bfy2d6kli6nvnx80qhv-uv-0.9.27",
"default": true
}
],
"store_path": "/nix/store/il24573a65xa0bfy2d6kli6nvnx80qhv-uv-0.9.27"
},
"x86_64-linux": {
"outputs": [
{
"name": "out",
"path": "/nix/store/k9b6fbx5pzj04fws4na77i4pb5l64li8-uv-0.9.27",
"default": true
}
],
"store_path": "/nix/store/k9b6fbx5pzj04fws4na77i4pb5l64li8-uv-0.9.27"
}
}
}
}
}
3 changes: 0 additions & 3 deletions iress/xplan/__init__.py

This file was deleted.

91 changes: 91 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
[project]
name = "iress-xplan-api-examples"
requires-python = ">=3.14"
version = "1.0"

dependencies = [
"pyotp",
"requests",
"urllib3"
]

[dependency-groups]
dev = [
"coverage",
"mypy",
"pytest",
"pytest-cov",
"responses",
"ruff",
"types-requests"
]

[tool.coverage.run]
branch = true
source = ["src"]
omit = [
# omit anything in a .local directory anywhere
"*/.local/*",
# Omit any test files
"*/*_test.py",
]

# [tool.coverage.xml]
# output = "./coverage.xml"

[tool.mypy]
platform="linux"

show_column_numbers=true
show_error_context=false
error_summary=true

# treat Optional per PEP 484
strict_optional=true
strict_equality=true

# https://mypy.readthedocs.io/en/stable/config_file.html#configuring-warnings
warn_redundant_casts=true
warn_unused_ignores=true
warn_unreachable=true
warn_no_return=true
warn_return_any=true

# Be real strict on using types
check_untyped_defs=true
disallow_incomplete_defs=true
disallow_untyped_calls=true
disallow_untyped_decorators=false
disallow_untyped_defs=true

# Support for types is not yet available
ignore_missing_imports = true

[tool.pytest.ini_options]
markers = [
"integration: marks tests as integration (these are not run by default)."
]

[tool.ruff]
line-length = 90
preview = true

[tool.ruff.lint]
select = [
"F", "E", "W", "C90", "I", "N", "D2", "UP", "YTT", "ANN", "ASYNC", "S",
"B", "A", "C4", "DTZ", "T10", "FA", "ISC", "ICN",
"LOG", "G", "INP", "PIE", "PT", "Q", "RSE", "RET", "SLF", "SLOT", "SIM",
"TID", "TCH", "ARG", "PTH", "TD", "FIX", "ERA", "PL", "TRY", "FLY",
"PERF", "FURB", "RUF"
]

ignore = ["E203", "S101", "S311", "D203", "D211", "D213", "ISC001", "ANN401", "TRY003", "ERA001", "PLW0603"]

[tool.ruff.lint.mccabe]
max-complexity = 10

[tool.ruff.lint.pylint]
max-args = 6

[tool.ruff.lint.per-file-ignores]
"*_test.py" = ["S105", "FBT", "PLR2004", "PLR6301", "PLC2801"]
5 changes: 5 additions & 0 deletions scripts/call.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash
# This script is used to run the commands.
set -euo pipefail

PYTHONPATH=$(pwd)/src python src/call.py "$@"
Loading