From d3126cf5f6c961561b1449ad43ea27d3a1f5a3b7 Mon Sep 17 00:00:00 2001 From: "Ch.-David Blot" Date: Fri, 13 Nov 2026 10:12:44 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20tests:=20add=20VCR=20testing=20and?= =?UTF-8?q?=20CI/CD=20improvements?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/actions/common-ci/action.yml | 26 ++ .github/actions/run-test/action.yml | 11 + .github/scripts/vcr.py | 254 ++++++++++++++++++ .github/workflows/build.yml | 10 +- .github/workflows/codeql.yml | 8 +- .github/workflows/compliance.yml | 2 +- .github/workflows/gitleaks.yml | 2 +- .github/workflows/lint.yml | 30 +++ .github/workflows/publish.yml | 4 +- .github/workflows/pull-request.yml | 50 ++-- .github/workflows/push.yml | 38 +++ .github/workflows/sync-vcr-fixtures.yml | 56 ++++ .gitignore | 2 +- Makefile | 21 +- REUSE.toml | 2 +- examples/config_env/pom.xml | 2 +- .../java/io/github/outscale/example/App.java | 3 + examples/config_file/Makefile | 5 - examples/config_file/README.md | 14 - examples/config_file/pom.xml | 80 ------ examples/config_file/pom.xml.template | 80 ------ .../java/io/github/outscale/example/App.java | 99 ------- .../io/github/outscale/example/AppTest.java | 18 -- examples/password_auth/Makefile | 5 - examples/password_auth/README.md | 13 - examples/password_auth/pom.xml | 79 ------ examples/password_auth/pom.xml.template | 79 ------ .../java/io/github/outscale/example/App.java | 35 --- .../io/github/outscale/example/AppTest.java | 18 -- examples/vm/pom.xml | 2 +- .../java/io/github/outscale/example/App.java | 2 +- .../java/io/github/outscale/example/App.java | 2 +- ...b78ccff525ca2bb818eee68707c6e815cb133.json | 9 + ...aecb9a2d5e4265f75e857f75923685b889600.json | 16 ++ local_tests.sh | 42 --- pom.xml | 30 +++ sdk/pom.xml | 29 -- .../osc_sdk_java/client/ConfigurationEnv.java | 20 +- .../client/ConfigurationInitializer.java | 54 ++-- .../outscale/osc_sdk_java/client/Profile.java | 56 ++-- sdk/templates/JSON.mustache | 5 + .../libraries/okhttp-gson/JSON.mustache | 5 + 42 files changed, 606 insertions(+), 712 deletions(-) create mode 100644 .github/actions/common-ci/action.yml create mode 100644 .github/actions/run-test/action.yml create mode 100644 .github/scripts/vcr.py create mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/push.yml create mode 100644 .github/workflows/sync-vcr-fixtures.yml delete mode 100644 examples/config_file/Makefile delete mode 100644 examples/config_file/README.md delete mode 100644 examples/config_file/pom.xml delete mode 100644 examples/config_file/pom.xml.template delete mode 100644 examples/config_file/src/main/java/io/github/outscale/example/App.java delete mode 100644 examples/config_file/src/test/java/io/github/outscale/example/AppTest.java delete mode 100644 examples/password_auth/Makefile delete mode 100644 examples/password_auth/README.md delete mode 100644 examples/password_auth/pom.xml delete mode 100644 examples/password_auth/pom.xml.template delete mode 100644 examples/password_auth/src/main/java/io/github/outscale/example/App.java delete mode 100644 examples/password_auth/src/test/java/io/github/outscale/example/AppTest.java create mode 100644 fixtures/913e3dad1aefed1977f4893b48cb78ccff525ca2bb818eee68707c6e815cb133.json create mode 100644 fixtures/a7ba16ba63ec44eb79255b67f03aecb9a2d5e4265f75e857f75923685b889600.json delete mode 100755 local_tests.sh diff --git a/.github/actions/common-ci/action.yml b/.github/actions/common-ci/action.yml new file mode 100644 index 00000000..5ffe66d9 --- /dev/null +++ b/.github/actions/common-ci/action.yml @@ -0,0 +1,26 @@ +name: Setup Toolchain +description: Setup Toolchain + +runs: + using: composite + steps: + - uses: actions/setup-java@77dd5b2ce225ea11469928ac317850245a74ae78 # v6.2.0 + with: + distribution: 'temurin' + java-version: '11' + cache: 'maven' + - name: Ensure maven is installed + shell: bash + run: | + if ! command -v mvn >/dev/null 2>&1; then + sudo apt-get update + sudo apt-get install -y maven + fi + + if ! command -v mvn >/dev/null 2>&1; then + echo "Error: mvn is not available on PATH" >&2 + exit 1 + fi + + mvn --version + diff --git a/.github/actions/run-test/action.yml b/.github/actions/run-test/action.yml new file mode 100644 index 00000000..c56f453d --- /dev/null +++ b/.github/actions/run-test/action.yml @@ -0,0 +1,11 @@ +name: Run Tests +description: Run Integration / E2E Tests + +runs: + using: composite + steps: + - name: โฌ‡๏ธ Setup Toolchain + uses: ./.github/actions/common-ci + - name: ๐Ÿงช Run Tests + shell: bash + run: make examples-test diff --git a/.github/scripts/vcr.py b/.github/scripts/vcr.py new file mode 100644 index 00000000..7a281ce9 --- /dev/null +++ b/.github/scripts/vcr.py @@ -0,0 +1,254 @@ +from http.server import BaseHTTPRequestHandler, HTTPServer +import http.client +from pathlib import Path +import os +import base64 +import tempfile +import argparse + +MAX_BODY = int(1024 * 1024) # 1 Mo +RECORDED_RESPONSE_HEADERS = {"content-type"} + +import datetime +import hashlib +import hmac +import json + + +def sign(key, msg): + return hmac.new(key, msg.encode("utf-8"), hashlib.sha256).digest() + + +def getSignatureKey(key, dateStamp, regionName, serviceName): + kDate = sign(("AWS4" + key).encode("utf-8"), dateStamp) + kRegion = sign(kDate, regionName) + kService = sign(kRegion, serviceName) + kSigning = sign(kService, "aws4_request") + return kSigning + + +class RemoteSigner: + def __init__(self, access_key: str, secret_key: str, region: str, service: str): + self.access_key = access_key + self.secret_key = secret_key + self.region = region + self.service = service + + def sign(self, method, host, endpoint, body) -> dict[str, str]: + # https://github.com/aws-samples/sigv4-signing-examples/blob/b9011eb840d97e05b8a46d3bb4246b85e03aab8f/no-sdk/python/main.py + t = datetime.datetime.now(datetime.timezone.utc) + oscdate = t.strftime("%Y%m%dT%H%M%SZ") + datestamp = t.strftime("%Y%m%d") + canonical_uri = endpoint + canonical_querystring = "" + canonical_headers = "host:" + host + "\n" + "x-amz-date:" + oscdate + "\n" + signed_headers = "host;x-amz-date" + payload_hash = hashlib.sha256(body).hexdigest() + canonical_request = ( + method + + "\n" + + canonical_uri + + "\n" + + canonical_querystring + + "\n" + + canonical_headers + + "\n" + + signed_headers + + "\n" + + payload_hash + ) + algorithm = "AWS4-HMAC-SHA256" + credential_scope = ( + datestamp + "/" + self.region + "/" + self.service + "/" + "aws4_request" + ) + string_to_sign = ( + algorithm + + "\n" + + oscdate + + "\n" + + credential_scope + + "\n" + + hashlib.sha256(canonical_request.encode("utf-8")).hexdigest() + ) + signing_key = getSignatureKey( + self.secret_key, datestamp, self.region, self.service + ) + signature = hmac.new( + signing_key, (string_to_sign).encode("utf-8"), hashlib.sha256 + ).hexdigest() + authorization_header = ( + algorithm + + " " + + "Credential=" + + self.access_key + + "/" + + credential_scope + + ", " + + "SignedHeaders=" + + signed_headers + + ", " + + "Signature=" + + signature + ) + + return { + "host": host, + "x-amz-date": oscdate, + "authorization": authorization_header, + } + + +def fixture_key(method, target, body): + identity = { + "method": method, + "target": target, + "body_sha256": hashlib.sha256(body).hexdigest(), + } + serialized = json.dumps(identity, sort_keys=True, separators=(",", ":")).encode() + + return hashlib.sha256(serialized).hexdigest(), identity + + +def save_fixture(path, entries): + data = json.dumps(entries, indent=2).encode() + fd, temporary = tempfile.mkstemp(prefix=".fixture-", dir=FIXTURES) + try: + os.fchmod(fd, 0o600) + with os.fdopen(fd, "wb") as file: + file.write(data) + os.replace(temporary, path) + finally: + if os.path.exists(temporary): + os.unlink(temporary) + + +FIXTURES = Path("./fixtures") +FIXTURES.mkdir(parents=True, exist_ok=True) +REPLAY_POSITIONS = {} + + +class Proxy(BaseHTTPRequestHandler): + protocol_version = "HTTP/1.1" + + def handle_request(self): + try: + headers = {} + for name, value in self.headers.items(): + name = name.lower() + if not name.startswith("x-awz") and not name.startswith("x-osc"): + headers[name] = value + + length = int(headers.get("content-length", "0")) + if length < 0 or length > MAX_BODY: + raise ValueError("invalid or oversized Content-Length") + body = self.rfile.read(length) + + key, identity = fixture_key(self.command, self.path, body) + path = FIXTURES / f"{key}.json" + + if MODE == "replay": + if not path.exists(): + self.reply(404, {}, b"no matching fixture\n") + return + entries = json.loads(path.read_text()) + position = REPLAY_POSITIONS.get(key, 0) + if position >= len(entries): + self.reply(409, {}, b"fixture sequence exhausted\n") + return + REPLAY_POSITIONS[key] = position + 1 + response = entries[position] + self.reply( + response["status"], + response["headers"], + base64.b64decode(response["body_base64"]), + ) + return + + connection = http.client.HTTPSConnection( + UPSTREAM_HOST, UPSTREAM_PORT, timeout=30 + ) + try: + connection.putrequest( + self.command, self.path, skip_host=True, skip_accept_encoding=True + ) + + headers.update( + SIGNER.sign(self.command, UPSTREAM_HOST, self.path, body) + ) + + for name, value in headers.items(): + print(name, "->", value) + connection.putheader(name, value) + print(body) + connection.endheaders(body) + + upstream_response = connection.getresponse() + response_body = upstream_response.read() + response_headers = { + name.lower(): value + for name, value in upstream_response.getheaders() + if name.lower() in RECORDED_RESPONSE_HEADERS + } + status = upstream_response.status + + finally: + connection.close() + + entries = json.loads(path.read_text()) if path.exists() else [] + entries.append( + { + "status": status, + "headers": response_headers, + "body_base64": base64.b64encode(response_body).decode(), + } + ) + save_fixture(path, entries) + self.reply(status, response_headers, response_body) + except PermissionError as exc: + self.reply(401, {}, f"{exc}\n".encode()) + except (ValueError, UnicodeError) as exc: + self.reply(400, {}, f"{exc}\n".encode()) + except Exception: + self.log_exception() + self.reply(502, {}, b"proxy error\n") + + def log_exception(self): + import traceback + + traceback.print_exc() + + def reply(self, status, headers, body): + self.send_response(status) + for name, value in headers.items(): + self.send_header(name, value) + self.send_header("Content-Length", str(len(body))) + self.end_headers() + if self.command != "HEAD": + self.wfile.write(body) + + do_GET = handle_request + do_POST = handle_request + do_PUT = handle_request + do_PATCH = handle_request + do_DELETE = handle_request + do_HEAD = handle_request + + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description="test proxy VCR server") + parser.add_argument("mode", choices=("record", "replay")) + parser.add_argument("--host", default="127.0.0.1", help="listen address") + parser.add_argument("--port", type=int, default=8000, help="listen port") + parser.add_argument("--upstream-host", default="api.eu-west-2.outscale.com") + parser.add_argument("--upstream-port", type=int, default=443) + parser.add_argument("--region", default=os.environ.get("OSC_REGION", "eu-west-2")) + parser.add_argument("--access-key", default=os.environ.get("OSC_ACCESS_KEY", "")) + parser.add_argument("--secret-key", default=os.environ.get("OSC_SECRET_KEY", "")) + args = parser.parse_args() + MODE = args.mode + UPSTREAM_HOST = args.upstream_host + UPSTREAM_PORT = args.upstream_port + SIGNER = RemoteSigner(args.access_key, args.secret_key, args.region, "api") + server_address = (args.host, args.port) + httpd = HTTPServer(server_address, Proxy) + httpd.serve_forever() diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2b95b48a..a10ff8db 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,11 +14,11 @@ permissions: jobs: auto-build: environment: auto-build - runs-on: ubuntu-24.04 + runs-on: ubuntu-26.04 steps: - - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 - - uses: chainguard-dev/actions/setup-gitsign@3e76343fe029f8e2a10bfbec0da8f437e5dab7a5 # main - - uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: chainguard-dev/actions/setup-gitsign@a25ce483d875a46f4c837e85e32e0fda602693f5 # v1.8.1 + - uses: actions/setup-java@77dd5b2ce225ea11469928ac317850245a74ae78 # v6.2.0 with: distribution: 'temurin' java-version: '11' @@ -36,7 +36,7 @@ jobs: run: | echo "sdk_version=$(cat ./sdk_version)" >> "$GITHUB_OUTPUT" - name: Create Pull Request - uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 # v8.1.0 + uses: peter-evans/create-pull-request@3ffccacd46053766916f087ce41d627c0b8cf2d1 # v8.1.3 with: committer: "Outscale Bot " author: "Outscale Bot " diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index d67cbd32..b12a02b8 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -29,22 +29,22 @@ jobs: build-mode: none steps: - name: Checkout repository - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Setup Java - uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5 + uses: actions/setup-java@77dd5b2ce225ea11469928ac317850245a74ae78 # v6.2.0 with: distribution: 'temurin' java-version: '11' cache: 'maven' - name: Initialize CodeQL - uses: github/codeql-action/init@89a39a4e59826350b863aa6b6252a07ad50cf83e # v4 + uses: github/codeql-action/init@33d7b85da1a04171e211befe2c739303b9a4c066 # v4.39.3 with: languages: ${{ matrix.language }} build-mode: ${{ matrix.build-mode }} - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@89a39a4e59826350b863aa6b6252a07ad50cf83e # v4 + uses: github/codeql-action/analyze@33d7b85da1a04171e211befe2c739303b9a4c066 # v4.39.3 with: category: "/language:${{matrix.language}}" diff --git a/.github/workflows/compliance.yml b/.github/workflows/compliance.yml index 5dd10854..5ea00460 100644 --- a/.github/workflows/compliance.yml +++ b/.github/workflows/compliance.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest steps: - name: โฌ‡๏ธ Checkout - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - name: Plumber diff --git a/.github/workflows/gitleaks.yml b/.github/workflows/gitleaks.yml index 9ba650cf..670da022 100644 --- a/.github/workflows/gitleaks.yml +++ b/.github/workflows/gitleaks.yml @@ -19,6 +19,6 @@ jobs: fetch-depth: 0 persist-credentials: false - - uses: outscale/.github/gitleaks@2d75eac744aeab89dc784a17c9c99e9881c6e30d # v1.2.0 + - uses: outscale/.github/gitleaks@cc76c3e03f3c7a83a09914b1ed65b7fea5605fb8 # v1.5.1 with: gitleaks-license: ${{ secrets.GITLEAKS_LICENSE }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000..3773e6a4 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,30 @@ +name: Lint + +on: + workflow_call: {} + +permissions: + contents: read + +jobs: + lint-reuse: + runs-on: ubuntu-latest + steps: + - name: โฌ‡๏ธ Checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - name: ๐Ÿ”๏ธ Check Reuse + run: make reuse-test + + lint: + runs-on: ubuntu-latest + steps: + - name: โฌ‡๏ธ Checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - name: โฌ‡๏ธ Setup Toolchain + uses: ./.github/actions/common-ci + - name: ๐Ÿ”๏ธ Check Style + run: mvn spotless:check diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 4f1ec156..3d6aedfe 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -12,8 +12,8 @@ jobs: environment: publish runs-on: ubuntu-24.04 steps: - - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 - - uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: actions/setup-java@77dd5b2ce225ea11469928ac317850245a74ae78 # v6.2.0 with: distribution: 'temurin' java-version: '11' diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 3fbf381d..336b2b61 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -5,41 +5,25 @@ on: branches: [ main ] permissions: - pull-requests: write - contents: write - id-token: write + contents: read jobs: - reuse-test: - runs-on: ubuntu-24.04 + lint: + uses: ./.github/workflows/lint.yml + tests: + runs-on: ubuntu-latest steps: - - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 - - name: Reuse specification test - run: make reuse-test - examples-test: - runs-on: [authenticated, Linux] - steps: - - name: ๐Ÿ”’๐Ÿงน Setup Vault & Frieza - id: secrets - uses: outscale/.github/vault-frieza-clean@eb7bd1e0360703d0ad355bce46029ae8d49bac04 - with: - vault_role: outscale-osc-sdk-java - osc_account: oak - - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 - - uses: dtolnay/rust-toolchain@686976e191b89faba57d3206551f0f330d8cb249 # stable - - uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5 + - name: โฌ‡๏ธ Checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: - distribution: 'temurin' - java-version: '11' - cache: 'maven' - - name: Install maven - run: apt install maven - - name: Local Tests - run: ./local_tests.sh - - name: Example tests - if: "! contains(github.event.pull_request.labels.*.name, 'dependencies')" + persist-credentials: false + - name: ๐Ÿš€ Lunch VCR Server + run: | + python3 ./.github/scripts/vcr.py replay & + - name: ๐Ÿงช Run Tests + uses: ./.github/actions/run-test env: - OSC_ACCESS_KEY: ${{ steps.secrets.outputs.access_key }} - OSC_SECRET_KEY: ${{ steps.secrets.outputs.secret_key }} - OSC_REGION: ${{ steps.secrets.outputs.region }} - run: make examples-test + OSC_ACCESS_KEY: 1111222233334444 + OSC_SECRET_KEY: AAAABBBBCCCCDDDDEEEEFFFF + OSC_REGION: gh-test-1 + OSC_ENDPOINT_API: http://127.0.0.1:8000/api/v1 diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml new file mode 100644 index 00000000..54489464 --- /dev/null +++ b/.github/workflows/push.yml @@ -0,0 +1,38 @@ +name: push on main + +on: + push: + branches: [ main ] + schedule: + - cron: "30 2 * * 1" + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: read + id-token: write + +jobs: + lint: + uses: ./.github/workflows/lint.yml + tests: + runs-on: [authenticated, Linux] + steps: + - name: โฌ‡๏ธ Checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - name: ๐Ÿ”’๐Ÿงน Setup Vault & Frieza + id: secrets + uses: outscale/.github/vault-frieza-clean@5bb625dd5ae3c7712cef931f168e91899f4f0055 # v0.18.0 + with: + vault_role: outscale-osc-sdk-java + osc_account: oak + - name: ๐Ÿงช Run Tests + uses: ./.github/actions/run-test + env: + OSC_ACCESS_KEY: ${{ steps.secrets.outputs.access_key }} + OSC_SECRET_KEY: ${{ steps.secrets.outputs.secret_key }} + OSC_REGION: ${{ steps.secrets.outputs.region }} diff --git a/.github/workflows/sync-vcr-fixtures.yml b/.github/workflows/sync-vcr-fixtures.yml new file mode 100644 index 00000000..51d1858c --- /dev/null +++ b/.github/workflows/sync-vcr-fixtures.yml @@ -0,0 +1,56 @@ +name: sync vcr fixtures + +on: + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: write + id-token: write + +jobs: + sync: + runs-on: [authenticated, Linux] + steps: + - name: โฌ‡๏ธ Checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - name: ๐Ÿ”’๐Ÿงน Setup Vault & Frieza + id: secrets + uses: outscale/.github/vault-frieza-clean@5bb625dd5ae3c7712cef931f168e91899f4f0055 # v0.18.0 + with: + vault_role: outscale-osc-sdk-java + osc_account: oak + - name: ๐Ÿš€ Start VCR Record Server + env: + OSC_ACCESS_KEY: ${{ steps.secrets.outputs.access_key }} + OSC_SECRET_KEY: ${{ steps.secrets.outputs.secret_key }} + OSC_REGION: ${{ steps.secrets.outputs.region }} + run: | + rm -rf fixtures + python3 ./.github/scripts/vcr.py record \ + --upstream-host "api.${OSC_REGION}.outscale.com" & + - name: ๐Ÿงช Run Tests + uses: ./.github/actions/run-test + env: + OSC_ACCESS_KEY: 1111222233334444 + OSC_SECRET_KEY: AAAABBBBCCCCDDDDEEEE + OSC_REGION: gh-test-1 + OSC_ENDPOINT_API: http://127.0.0.1:8000/api/v1 + - name: ๐Ÿ›‘ Stop VCR Record Server + if: always() + run: pkill -f "vcr.py record" || true + - name: ๐Ÿ’พ Commit fixtures + uses: peter-evans/create-pull-request@3ffccacd46053766916f087ce41d627c0b8cf2d1 # v8.1.3 + with: + committer: "Outscale Bot " + author: "Outscale Bot " + commit-message: "๐Ÿ“ธ chore(test): update VCR fixtures" + token: "${{ env.token }}" + labels: "kind/feature" + env: + sdk_version: ${{ steps.get-sdk-version.outputs.sdk_version }} + api_version: ${{ github.event.inputs.api_version }} + token: ${{ secrets.GH_TOKEN || secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 689f7588..aab3450d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,4 @@ backup/ backup-native .sdk/ osc-api/ -**/target \ No newline at end of file +**/target diff --git a/Makefile b/Makefile index 39c37c66..10de95e9 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,6 @@ SDK_VERSION=$(shell cat sdk_version) USER_ID=$(shell id -u) GROUP_ID=$(shell id -g) OPENAPI_IMG=openapitools/openapi-generator-cli:v7.17.0 -#OPENAPI_IMG=outscale/openapi-generator:java-awsv4-signature SHELL := /bin/bash all: help @@ -34,7 +33,7 @@ reuse-test: docker run --rm --volume $(PWD):/data fsfe/reuse:6.2 lint .PHONY: examples-test -examples-test: example-volumes example-region example-vm example-config_file example-config_env example-password_auth +examples-test: example-volumes example-region example-vm example-config_env @echo examples are OK .PHONY: example-volumes @@ -52,21 +51,11 @@ example-vm: local-deploy @echo testing examples/vm example... make -C examples/vm build run -.PHONY: example-config_file -example-config_file: local-deploy - @echo testing examples/config_file example... - make -C examples/config_file build run - .PHONY: example-config_env example-config_env: local-deploy @echo testing examples/config_env example... make -C examples/config_env build run -.PHONY: example-password_auth -example-password_auth: local-deploy - @echo testing examples/password_auth example... - make -C examples/password_auth build run - # Used by bot to auto-release # GH_TOKEN and SSH_PRIVATE_KEY are needed .PHONY: auto-release @@ -77,6 +66,14 @@ auto-release: auto-release-cleanup osc-api-check release-check-duplicate release auto-release-cleanup: rm -rf .auto-release-abort || true +.PHONY: osc-api-check +osc-api-check: + bash .github/scripts/osc-api-check.sh + +.PHONY: release-check-duplicate +release-check-duplicate: + bash .github/scripts/release-check-duplicate.sh + .PHONY: release-build release-build: bash .github/scripts/release-build.sh diff --git a/REUSE.toml b/REUSE.toml index c3ef94a1..6a8f59e7 100644 --- a/REUSE.toml +++ b/REUSE.toml @@ -10,7 +10,7 @@ SPDX-FileCopyrightText = "2019 Outscale SAS " SPDX-License-Identifier = "CC-BY-4.0" [[annotations]] -path = ["Makefile", "sdk_version", "api_version", "**.java", ".git**", "src/**", "dist/**", "**.yml", "**.yaml", "examples/**", "pom.xml", "pom.xml.template", "sdk/**", "bundle/**" ,"sbom/**"] +path = ["Makefile", "sdk_version", "api_version", "**.java", ".git**", "src/**", "dist/**", "**.yml", "**.yaml", "examples/**", "pom.xml", "pom.xml.template", "sdk/**", "bundle/**" ,"sbom/**", "fixtures/**"] precedence = "aggregate" SPDX-FileCopyrightText = "2019 Outscale SAS " SPDX-License-Identifier = "BSD-3-Clause" diff --git a/examples/config_env/pom.xml b/examples/config_env/pom.xml index 35e1c64b..6d6b5c6f 100644 --- a/examples/config_env/pom.xml +++ b/examples/config_env/pom.xml @@ -28,7 +28,7 @@ io.github.outscale osc-sdk-java - 0.11.0 + 0.12.0 diff --git a/examples/config_env/src/main/java/io/github/outscale/example/App.java b/examples/config_env/src/main/java/io/github/outscale/example/App.java index 14c44a67..2b760ca5 100644 --- a/examples/config_env/src/main/java/io/github/outscale/example/App.java +++ b/examples/config_env/src/main/java/io/github/outscale/example/App.java @@ -18,6 +18,8 @@ public static void main(String[] args) throws ConfigurationException { if (confEnv == null) { return; } + + System.err.println(confEnv.toString()); ApiClient apiClient = null; try { @@ -30,6 +32,7 @@ public static void main(String[] args) throws ConfigurationException { if (apiClient == null) { return; } + System.err.println(apiClient.toString()); VmApi apiInstance = new VmApi(apiClient); ReadVmsRequest createAccessKeyRequest = new ReadVmsRequest(); // CreateAccessKeyRequest | diff --git a/examples/config_file/Makefile b/examples/config_file/Makefile deleted file mode 100644 index 2d113b20..00000000 --- a/examples/config_file/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -build: - mvn clean compile assembly:single - -run: - java -jar target/configfile-1.0-SNAPSHOT-jar-with-dependencies.jar diff --git a/examples/config_file/README.md b/examples/config_file/README.md deleted file mode 100644 index 90560428..00000000 --- a/examples/config_file/README.md +++ /dev/null @@ -1,14 +0,0 @@ -This examples demonstrates hwo to use a file to provide credentials to the SDK. - -# Installation -``` -make build -``` - -# Execution -``` -export OSC_ACCESS_KEY=... -export OSC_SECRET_KEY=... -export OSC_REGION=... -make run -``` \ No newline at end of file diff --git a/examples/config_file/pom.xml b/examples/config_file/pom.xml deleted file mode 100644 index 8a7d5334..00000000 --- a/examples/config_file/pom.xml +++ /dev/null @@ -1,80 +0,0 @@ - - - - 4.0.0 - - io.github.outscale.example - configfile - 1.0-SNAPSHOT - - region - - http://www.example.com - - - UTF-8 - 1.8 - 1.8 - - - - - junit - junit - 4.13.1 - test - - - io.github.outscale - osc-sdk-java - 0.11.0 - - - - - - - - - - maven-clean-plugin - 3.1.0 - - - - maven-resources-plugin - 3.0.2 - - - maven-compiler-plugin - 3.8.0 - - - org.apache.maven.plugins - maven-assembly-plugin - 2.6 - - - - io.github.outscale.example.App - - - - jar-with-dependencies - - - - - make-assembly - package - - single - - - - - - - - diff --git a/examples/config_file/pom.xml.template b/examples/config_file/pom.xml.template deleted file mode 100644 index 08163363..00000000 --- a/examples/config_file/pom.xml.template +++ /dev/null @@ -1,80 +0,0 @@ - - - - 4.0.0 - - io.github.outscale.example - configfile - 1.0-SNAPSHOT - - region - - http://www.example.com - - - UTF-8 - 1.7 - 1.7 - - - - - junit - junit - 4.13.1 - test - - - io.github.outscale - osc-sdk-java - SDK_VERSION - - - - - - - - - - maven-clean-plugin - 3.1.0 - - - - maven-resources-plugin - 3.0.2 - - - maven-compiler-plugin - 3.8.0 - - - org.apache.maven.plugins - maven-assembly-plugin - 2.6 - - - - io.github.outscale.example.App - - - - jar-with-dependencies - - - - - make-assembly - package - - single - - - - - - - - diff --git a/examples/config_file/src/main/java/io/github/outscale/example/App.java b/examples/config_file/src/main/java/io/github/outscale/example/App.java deleted file mode 100644 index 0ab10f15..00000000 --- a/examples/config_file/src/main/java/io/github/outscale/example/App.java +++ /dev/null @@ -1,99 +0,0 @@ -package io.github.outscale.example; - -import java.io.BufferedWriter; -import java.io.FileNotFoundException; -import java.io.FileWriter; -import java.io.IOException; - -// Import classes: -import io.github.outscale.osc_sdk_java.client.ApiClient; -import io.github.outscale.osc_sdk_java.client.ApiException; -import io.github.outscale.osc_sdk_java.client.Configuration; -import io.github.outscale.osc_sdk_java.client.ConfigurationException; -import io.github.outscale.osc_sdk_java.client.ConfigurationFile; -import io.github.outscale.osc_sdk_java.client.JSON; -import io.github.outscale.osc_sdk_java.client.model.*; -import io.github.outscale.osc_sdk_java.client.handler.RegionApi; -import io.github.outscale.osc_sdk_java.client.handler.VmApi; - -public class App { - - public static void createConfigurationFile(String path) { - String accessKey = System.getenv("OSC_ACCESS_KEY"); - String secretKey = System.getenv("OSC_SECRET_KEY"); - String region = System.getenv("OSC_REGION"); - String endpointApi = System.getenv("OSC_ENDPOINT_API_NOPROTO"); - String protocol = System.getenv("OSC_PROTOCOL"); - - if (endpointApi != null) { - endpointApi = String.format("\"endpoints\": {\"api\": \"%s\"},", endpointApi); - } else { - endpointApi = ""; - } - - if (protocol != null) { - protocol = String.format("\"protocol\": \"%s\",", protocol); - } else { - protocol = ""; - } - - String content = String.format( - "{\"default\": {%s%s\"access_key\": \"%s\", \"secret_key\": \"%s\", \"region\": \"%s\"}}", - endpointApi, protocol, - accessKey, secretKey, region); - - try (BufferedWriter bw = new BufferedWriter(new FileWriter(path))) { - bw.write(content); - } catch (IOException e) { - System.err.println("Error during the read of the file"); - return; - } - - } - - public static void main(String[] args) { - - String path = "/tmp/osc-sdk-java-ConfigurationFile"; - createConfigurationFile(path); - - ConfigurationFile confFile = null; - try { - confFile = ConfigurationFile.loadConfigFile(path); - } catch (ConfigurationException e1) { - System.err.println(e1.toString()); - System.exit(1); - } - if (confFile == null) { - return; - } - - ApiClient apiClient = null; - try { - apiClient = confFile.getApiClient("default"); - } catch (ConfigurationException e1) { - System.err.println(e1.toString()); - System.exit(1); - } - - if (apiClient == null) { - return; - } - - VmApi apiInstance = new VmApi(apiClient); - ReadVmsRequest createAccessKeyRequest = new ReadVmsRequest(); // CreateAccessKeyRequest | - FiltersVm filter = new FiltersVm(); - createAccessKeyRequest.setFilters(filter); - try { - ReadVmsResponse result = apiInstance.readVms(createAccessKeyRequest); - System.out.println(result); - } catch (ApiException e) { - System.err.println("Exception when calling AccessKeyApi#createAccessKey"); - System.err.println("Status code: " + e.getCode()); - System.err.println("Reason: " + e.getResponseBody()); - System.err.println("Response headers: " + e.getResponseHeaders()); - e.printStackTrace(); - System.exit(1); - } - - } -} diff --git a/examples/config_file/src/test/java/io/github/outscale/example/AppTest.java b/examples/config_file/src/test/java/io/github/outscale/example/AppTest.java deleted file mode 100644 index 2d5526ac..00000000 --- a/examples/config_file/src/test/java/io/github/outscale/example/AppTest.java +++ /dev/null @@ -1,18 +0,0 @@ -package io.github.outscale.example; - -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -/** - * Unit test for simple App. - */ -public class AppTest { - /** - * Rigorous Test :-) - */ - @Test - public void shouldAnswerWithTrue() { - assertTrue(true); - } -} diff --git a/examples/password_auth/Makefile b/examples/password_auth/Makefile deleted file mode 100644 index 2eec8080..00000000 --- a/examples/password_auth/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -build: - mvn clean compile assembly:single - -run: - java -jar target/password_auth-1.0-SNAPSHOT-jar-with-dependencies.jar \ No newline at end of file diff --git a/examples/password_auth/README.md b/examples/password_auth/README.md deleted file mode 100644 index b84043a2..00000000 --- a/examples/password_auth/README.md +++ /dev/null @@ -1,13 +0,0 @@ -This examples demonstrates how to use username and password to provide credentials to the SDK. - -# Installation -``` -make build -``` - -# Execution -``` -export OSC_USERNAME=... -export OSC_PASSWORD=... -make run -``` \ No newline at end of file diff --git a/examples/password_auth/pom.xml b/examples/password_auth/pom.xml deleted file mode 100644 index c71586cd..00000000 --- a/examples/password_auth/pom.xml +++ /dev/null @@ -1,79 +0,0 @@ - - - - 4.0.0 - - io.github.outscale.example - password_auth - 1.0-SNAPSHOT - - region - - http://www.example.com - - - UTF-8 - 1.8 - 1.8 - - - - - junit - junit - 4.13.1 - test - - - io.github.outscale - osc-sdk-java - 0.11.0 - - - - - - - - - maven-clean-plugin - 3.1.0 - - - - maven-resources-plugin - 3.0.2 - - - maven-compiler-plugin - 3.8.0 - - - org.apache.maven.plugins - maven-assembly-plugin - 2.6 - - - - io.github.outscale.example.App - - - - jar-with-dependencies - - - - - make-assembly - package - - single - - - - - - - - diff --git a/examples/password_auth/pom.xml.template b/examples/password_auth/pom.xml.template deleted file mode 100644 index 3fc77d4b..00000000 --- a/examples/password_auth/pom.xml.template +++ /dev/null @@ -1,79 +0,0 @@ - - - - 4.0.0 - - io.github.outscale.example - password_auth - 1.0-SNAPSHOT - - region - - http://www.example.com - - - UTF-8 - 1.7 - 1.7 - - - - - junit - junit - 4.13.1 - test - - - io.github.outscale - osc-sdk-java - SDK_VERSION - - - - - - - - - maven-clean-plugin - 3.1.0 - - - - maven-resources-plugin - 3.0.2 - - - maven-compiler-plugin - 3.8.0 - - - org.apache.maven.plugins - maven-assembly-plugin - 2.6 - - - - io.github.outscale.example.App - - - - jar-with-dependencies - - - - - make-assembly - package - - single - - - - - - - - diff --git a/examples/password_auth/src/main/java/io/github/outscale/example/App.java b/examples/password_auth/src/main/java/io/github/outscale/example/App.java deleted file mode 100644 index 3ec658a0..00000000 --- a/examples/password_auth/src/main/java/io/github/outscale/example/App.java +++ /dev/null @@ -1,35 +0,0 @@ -package io.github.outscale.example; - -// Import classes: -import io.github.outscale.osc_sdk_java.client.*; -import io.github.outscale.osc_sdk_java.client.handler.AccountApi; -import io.github.outscale.osc_sdk_java.client.handler.ApiAccessPolicyApi; -import io.github.outscale.osc_sdk_java.client.handler.VmApi; -import io.github.outscale.osc_sdk_java.client.model.*; - -public class App { - public static void main(String[] args) { - ApiClient defaultClient = Configuration.getDefaultApiClient(); - String username = System.getenv("OSC_USERNAME"); - String password = System.getenv("OSC_PASSWORD"); - defaultClient.setUsername(username); - defaultClient.setPassword(password); - String endpoint = System.getenv("OSC_ENDPOINT_API_PROTO"); - if (endpoint != null) - defaultClient.setBasePath(endpoint); - - ApiAccessPolicyApi api = new ApiAccessPolicyApi(defaultClient); - ReadApiAccessPolicyRequest request = new ReadApiAccessPolicyRequest(); // CreateAccessKeyRequest | - try { - ReadApiAccessPolicyResponse result = api.readApiAccessPolicy(request); - System.out.println(result); - } catch (ApiException e) { - System.err.println("Exception when calling AccessKeyApi#createAccessKey"); - System.err.println("Status code: " + e.getCode()); - System.err.println("Reason: " + e.getResponseBody()); - System.err.println("Response headers: " + e.getResponseHeaders()); - e.printStackTrace(); - System.exit(1); - } - } -} diff --git a/examples/password_auth/src/test/java/io/github/outscale/example/AppTest.java b/examples/password_auth/src/test/java/io/github/outscale/example/AppTest.java deleted file mode 100644 index 2d5526ac..00000000 --- a/examples/password_auth/src/test/java/io/github/outscale/example/AppTest.java +++ /dev/null @@ -1,18 +0,0 @@ -package io.github.outscale.example; - -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -/** - * Unit test for simple App. - */ -public class AppTest { - /** - * Rigorous Test :-) - */ - @Test - public void shouldAnswerWithTrue() { - assertTrue(true); - } -} diff --git a/examples/vm/pom.xml b/examples/vm/pom.xml index a6895f85..3a542538 100644 --- a/examples/vm/pom.xml +++ b/examples/vm/pom.xml @@ -28,7 +28,7 @@ io.github.outscale osc-sdk-java - 0.11.0 + 0.12.0 diff --git a/examples/vm/src/main/java/io/github/outscale/example/App.java b/examples/vm/src/main/java/io/github/outscale/example/App.java index 3538f3b5..32b44f3e 100644 --- a/examples/vm/src/main/java/io/github/outscale/example/App.java +++ b/examples/vm/src/main/java/io/github/outscale/example/App.java @@ -12,7 +12,7 @@ public static void main(String[] args) { String secretKey = System.getenv("OSC_SECRET_KEY"); String region = System.getenv("OSC_REGION"); defaultClient.setAWS4Configuration(accessKey, secretKey, region, "api"); - String endpoint = System.getenv("OSC_ENDPOINT_API_PROTO"); + String endpoint = System.getenv("OSC_ENDPOINT_API"); if (endpoint != null) defaultClient.setBasePath(endpoint); diff --git a/examples/volumes/src/main/java/io/github/outscale/example/App.java b/examples/volumes/src/main/java/io/github/outscale/example/App.java index 65cadac1..a9ae0107 100644 --- a/examples/volumes/src/main/java/io/github/outscale/example/App.java +++ b/examples/volumes/src/main/java/io/github/outscale/example/App.java @@ -11,7 +11,7 @@ public static void main(String[] args) { String accessKey = System.getenv("OSC_ACCESS_KEY"); String secretKey = System.getenv("OSC_SECRET_KEY"); String region = System.getenv("OSC_REGION"); - String endpoint = System.getenv("OSC_ENDPOINT_API_PROTO"); + String endpoint = System.getenv("OSC_ENDPOINT_API"); if (endpoint != null) defaultClient.setBasePath(endpoint); diff --git a/fixtures/913e3dad1aefed1977f4893b48cb78ccff525ca2bb818eee68707c6e815cb133.json b/fixtures/913e3dad1aefed1977f4893b48cb78ccff525ca2bb818eee68707c6e815cb133.json new file mode 100644 index 00000000..423b001a --- /dev/null +++ b/fixtures/913e3dad1aefed1977f4893b48cb78ccff525ca2bb818eee68707c6e815cb133.json @@ -0,0 +1,9 @@ +[ + { + "status": 200, + "headers": { + "content-type": "application/json" + }, + "body_base64": "eyJWb2x1bWVzIjpbeyJWb2x1bWVJZCI6InZvbC02Y2UzMWZmZCIsIlZvbHVtZVR5cGUiOiJpbzEiLCJUYWdzIjpbXSwiU3RhdGUiOiJpbi11c2UiLCJTaXplIjoxMDAsIlNuYXBzaG90SWQiOiJzbmFwLWQ5MTc5NjE4IiwiTGlua2VkVm9sdW1lcyI6W3siVm9sdW1lSWQiOiJ2b2wtNmNlMzFmZmQiLCJWbUlkIjoiaS03NmJjZGIxZCIsIlN0YXRlIjoiYXR0YWNo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GUiOiIyMDI2LTEwLTIzVDEyOjEwOjE4LjQyNloifV0sIlJlc3BvbnNlQ29udGV4dCI6eyJSZXF1ZXN0SWQiOiJkODllYTMxOS02MzU2LTQ0NGEtOWZkMS1iNzMwOGFjZjFhZDMifX0=" + } +] diff --git a/fixtures/a7ba16ba63ec44eb79255b67f03aecb9a2d5e4265f75e857f75923685b889600.json b/fixtures/a7ba16ba63ec44eb79255b67f03aecb9a2d5e4265f75e857f75923685b889600.json new file mode 100644 index 00000000..024cf178 --- /dev/null +++ b/fixtures/a7ba16ba63ec44eb79255b67f03aecb9a2d5e4265f75e857f75923685b889600.json @@ -0,0 +1,16 @@ +[ + { + "status": 200, + "headers": { + "content-type": "application/json" + }, + "body_base64": "eyJWbXMiOlt7IlZtSW5pdGlhdGVkU2h1dGRvd25CZWhhdmlvciI6InN0b3AiLCJWbUlkIjoiaS03NmJjZGIxZCIsIlVzZXJEYXRhIjoiIiwiU3RhdGVSZWFzb24iOiIiLCJUYWdzIjpbeyJWYWx1ZSI6IjE3MS4zMy4xMDYuNiIsIktleSI6Im9zYy5mY3UuZWlwLmF1dG8tYXR0YWNoIn0seyJWYWx1ZSI6ImJhciIsIktleSI6ImZvbyJ9LHsiVmFsdWUiOiJ2bTEiLCJLZXkiOiJOYW1lIn1dLCJCc3VPcHRpbWl6ZWQiOmZhbHNlLCJIeXBlcnZpc29yIjoia3ZtIiwiUHJpdmF0ZUlwIjoiMTAuMTAuMi4xMzQiLCJLZXlwYWlyTmFtZSI6IkxNQUMtQzI3VFEwNC1FVSIsIkltYWdlSWQiOiJhbWktMzA2ZThjZWYiLCJTdGF0ZSI6InJ1bm5pbmciLCJEZWxldGlvblByb3RlY3Rpb24iOnRydWUsIkJvb3RNb2RlIjoibGVnYWN5IiwiU2VjdXJpdHlHcm91cHMiOlt7IlNlY3VyaXR5R3JvdXBOYW1lIjoibW9zaC1zZyIsIlNlY3VyaXR5R3JvdXBJZCI6InNnLTI2MmE0ODE0In0seyJTZWN1cml0e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3VicmVnaW9uTmFtZSI6ImV1LXdlc3QtMmEifSwiUHVibGljRG5zTmFtZSI6Im93cy0xNDgtMjUzLTExMC0xNDQuZXUtd2VzdC0yLmNvbXB1dGUub3V0c2NhbGUuY29tIiwiUmVzZXJ2YXRpb25JZCI6InItY2I0ZGY3NWEiLCJUcG1FbmFibGVkIjpmYWxzZSwiUm9vdERldmljZVR5cGUiOiJlYnMiLCJSb290RGV2aWNlTmFtZSI6Ii9kZXYvc2RhMSIsIlNodXRkb3duQmVoYXZpb3JDb25maWd1cmF0aW9uIjp7Ikhvc3RBY3Rpb24iOiJzdG9wIiwiR3Vlc3RBY3Rpb24iOiJzdG9wIn19XSwiUmVzcG9uc2VDb250ZXh0Ijp7IlJlcXVlc3RJZCI6ImU3ZTdkZmFkLTE1OWYtNDQ1ZS1iOWI0LTQwMzcyZGU1NTExNSJ9fQ==" + } +] \ No newline at end of file diff --git a/local_tests.sh b/local_tests.sh deleted file mode 100755 index 2cd61e99..00000000 --- a/local_tests.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/sh - -# Copyright (c) Outscale SAS -# -# SPDX-License-Identifier: BSD-3-Clause - -export OSC_PASSWORD='ashita wa dochida' -export OSC_LOGIN=joe -export OSC_USERNAME=joe - -export OMI_ID="ami-90067666" - -export OSC_SECRET_KEY=0000001111112222223333334444445555555666 -export OSC_ACCESS_KEY=11112211111110000000 - -export OSC_ENDPOINT_API_PROTO="http://localhost:3000/api/v1" -export OSC_ENDPOINT_API_NOPROTO="localhost:3000/api/v1" -export OSC_ENDPOINT_API="localhost:3000/api/v1" -export OSC_REGION="vp-ware-3" -export OSC_PROTOCOL="http" - -export OSC_USING_RICOCHET="oui" - -if [ "$#" -eq 0 ]; then - - if [ ! -d "osc-ricochet-2" ]; then - git clone https://github.com/outscale-mgo/osc-ricochet-2 - fi - - cd osc-ricochet-2 - pkill ricochet - - cargo build --profile 'sdks' - cargo run --profile 'sdks' -- ./ricochet.json &> /dev/null & - cd .. - - sleep 5 -fi - -set -e - -make examples-test diff --git a/pom.xml b/pom.xml index 0a8399e6..66f9ff7d 100644 --- a/pom.xml +++ b/pom.xml @@ -91,6 +91,36 @@ + + com.diffplug.spotless + spotless-maven-plugin + ${spotless.version} + + + + + .gitignore + + + + + true + 4 + + + + + + 1.17.0 + + true + + + + + + + org.apache.maven.plugins maven-source-plugin diff --git a/sdk/pom.xml b/sdk/pom.xml index 3bde03d8..299349a2 100644 --- a/sdk/pom.xml +++ b/sdk/pom.xml @@ -139,35 +139,6 @@ org.apache.maven.plugins maven-javadoc-plugin - - com.diffplug.spotless - spotless-maven-plugin - ${spotless.version} - - - - - .gitignore - - - - - true - 4 - - - - - - 1.8 - - true - - - - - - org.apache.maven.plugins maven-gpg-plugin diff --git a/sdk/src/main/java/io/github/outscale/osc_sdk_java/client/ConfigurationEnv.java b/sdk/src/main/java/io/github/outscale/osc_sdk_java/client/ConfigurationEnv.java index adaa8950..571f30fa 100644 --- a/sdk/src/main/java/io/github/outscale/osc_sdk_java/client/ConfigurationEnv.java +++ b/sdk/src/main/java/io/github/outscale/osc_sdk_java/client/ConfigurationEnv.java @@ -20,33 +20,37 @@ public static ConfigurationEnv loadConfigEnv() throws ConfigurationException { configurationEnv.profile.setProtocol(System.getenv("OSC_PROTOCOL")); try { if (System.getenv("OSC_MAX_RETRIES") != null) { - configurationEnv.profile.setMaxRetries(Integer.parseInt(System.getenv("OSC_MAX_RETRIES"))); + configurationEnv.profile.setMaxRetries( + Integer.parseInt(System.getenv("OSC_MAX_RETRIES"))); } - } catch (NumberFormatException e){ + } catch (NumberFormatException e) { throw new ConfigurationException("OSC_MAX_RETRIES is not a valid integer"); } try { if (System.getenv("OSC_RETRY_BACKOFF_FACTOR") != null) { - configurationEnv.profile.setRetryBackoffFactor(Float.parseFloat(System.getenv("OSC_RETRY_BACKOFF_FACTOR"))); + configurationEnv.profile.setRetryBackoffFactor( + Float.parseFloat(System.getenv("OSC_RETRY_BACKOFF_FACTOR"))); } - } catch (NumberFormatException e){ + } catch (NumberFormatException e) { throw new ConfigurationException("OSC_RETRY_BACKOFF_FACTOR is not a valid float"); } try { if (System.getenv("OSC_RETRY_BACKOFF_JITTER") != null) { - configurationEnv.profile.setRetryBackoffJitter(Float.parseFloat(System.getenv("OSC_RETRY_BACKOFF_JITTER"))); + configurationEnv.profile.setRetryBackoffJitter( + Float.parseFloat(System.getenv("OSC_RETRY_BACKOFF_JITTER"))); } - } catch (NumberFormatException e){ + } catch (NumberFormatException e) { throw new ConfigurationException("OSC_RETRY_BACKOFF_Jitter is not a valid float"); } try { if (System.getenv("OSC_RETRY_BACKOFF_MAX") != null) { - configurationEnv.profile.setRetryBackoffMax(Float.parseFloat(System.getenv("OSC_RETRY_BACKOFF_MAX"))); + configurationEnv.profile.setRetryBackoffMax( + Float.parseFloat(System.getenv("OSC_RETRY_BACKOFF_MAX"))); } - } catch (NumberFormatException e){ + } catch (NumberFormatException e) { throw new ConfigurationException("OSC_RETRY_BACKOFF_MAX is not a valid float"); } diff --git a/sdk/src/main/java/io/github/outscale/osc_sdk_java/client/ConfigurationInitializer.java b/sdk/src/main/java/io/github/outscale/osc_sdk_java/client/ConfigurationInitializer.java index a77a873e..7b3a67cf 100644 --- a/sdk/src/main/java/io/github/outscale/osc_sdk_java/client/ConfigurationInitializer.java +++ b/sdk/src/main/java/io/github/outscale/osc_sdk_java/client/ConfigurationInitializer.java @@ -1,7 +1,5 @@ package io.github.outscale.osc_sdk_java.client; -import dev.failsafe.Failsafe; -import dev.failsafe.Policy; import dev.failsafe.RateLimiter; import dev.failsafe.RetryPolicy; import java.io.BufferedReader; @@ -21,7 +19,6 @@ import java.util.Base64; import java.util.HashMap; import okhttp3.OkHttpClient; -import okhttp3.Request; import okhttp3.Response; import okhttp3.tls.HandshakeCertificates; import okhttp3.tls.HeldCertificate; @@ -54,16 +51,16 @@ protected ApiClient getApiClient(Profile profile) throws ConfigurationException apiClient.setAWS4Configuration(accessKey, secretKey, region, "api"); StringBuilder urlBuilder = new StringBuilder(); - if (selectedProfile.getProtocol() != null && selectedProfile.getProtocol().length() > 0) { - urlBuilder.append(selectedProfile.getProtocol() + "://"); - } else { - urlBuilder.append("https://"); - } - Endpoint endpoints = selectedProfile.getEndpoints(); if (endpoints != null && endpoints.getApi() != null && endpoints.getApi().length() > 0) { urlBuilder.append(endpoints.getApi()); } else { + if (selectedProfile.getProtocol() != null + && selectedProfile.getProtocol().length() > 0) { + urlBuilder.append(selectedProfile.getProtocol() + "://"); + } else { + urlBuilder.append("https://"); + } urlBuilder.append("api.{region}.outscale.com/api/v1"); } @@ -203,7 +200,6 @@ protected ApiClient getApiClient(Profile profile) throws ConfigurationException .heldCertificate(clientCertificate) .build(); - OkHttpClient client = new OkHttpClient.Builder() .sslSocketFactory( @@ -222,32 +218,36 @@ protected ApiClient getApiClient(Profile profile) throws ConfigurationException protected RetryPolicy getRetryPolicy(Profile profile) { int max_retires = profile.getMaxRetry() != null ? profile.getMaxRetry() : 3; - Duration backoff_factor = profile.getRetryBackoffFactor() != null ? - Duration.ofMillis(Math.round(profile.getRetryBackoffFactor() * 1000)) : - Duration.ofSeconds(2); - Duration backoff_max = profile.getRetryBackoffMax() != null ? - Duration.ofMillis(Math.round(profile.getRetryBackoffMax() * 1000)) : - Duration.ofSeconds(15); - Duration backoff_jitter = profile.getRetryBackoffJitter() != null ? - Duration.ofMillis(Math.round(profile.getRetryBackoffJitter() * 500)) : - Duration.ofSeconds(1); + Duration backoff_factor = + profile.getRetryBackoffFactor() != null + ? Duration.ofMillis(Math.round(profile.getRetryBackoffFactor() * 1000)) + : Duration.ofSeconds(2); + Duration backoff_max = + profile.getRetryBackoffMax() != null + ? Duration.ofMillis(Math.round(profile.getRetryBackoffMax() * 1000)) + : Duration.ofSeconds(15); + Duration backoff_jitter = + profile.getRetryBackoffJitter() != null + ? Duration.ofMillis(Math.round(profile.getRetryBackoffJitter() * 500)) + : Duration.ofSeconds(1); if (backoff_jitter.compareTo(backoff_factor) > 0) { backoff_jitter = backoff_factor; } return RetryPolicy.builder() - .withMaxRetries(max_retires) - .withBackoff(backoff_factor, backoff_max) - .withJitter(backoff_jitter) - .build(); + .withMaxRetries(max_retires) + .withBackoff(backoff_factor, backoff_max) + .withJitter(backoff_jitter) + .build(); } protected RateLimiter getLimiter(Profile profile) { int max_req = profile.getLimiterMaxRequests() != null ? profile.getLimiterMaxRequests() : 5; - Duration window = profile.getLimiterWindow() != null ? - Duration.ofMillis(Math.round(profile.getLimiterWindow() * 1000)) : - Duration.ofSeconds(1); + Duration window = + profile.getLimiterWindow() != null + ? Duration.ofMillis(Math.round(profile.getLimiterWindow() * 1000)) + : Duration.ofSeconds(1); return RateLimiter.smoothBuilder(max_req, window).build(); - } + } } diff --git a/sdk/src/main/java/io/github/outscale/osc_sdk_java/client/Profile.java b/sdk/src/main/java/io/github/outscale/osc_sdk_java/client/Profile.java index 5e98bbf2..f75b613f 100644 --- a/sdk/src/main/java/io/github/outscale/osc_sdk_java/client/Profile.java +++ b/sdk/src/main/java/io/github/outscale/osc_sdk_java/client/Profile.java @@ -11,7 +11,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; import java.util.HashSet; -import com.google.gson.JsonElement; public class Profile { public static final String SERIALIZED_NAME_ACCESS_KEY = "access_key"; @@ -26,28 +25,36 @@ public class Profile { public static final String SERIALIZED_NAME_X509_CLIENT_CERT = "x509_client_cert"; - /** @deprecated X.509 client certificate support is deprecated. */ + /** + * @deprecated X.509 client certificate support is deprecated. + */ @Deprecated @SerializedName(SERIALIZED_NAME_X509_CLIENT_CERT) private String x509ClientCert; public static final String SERIALIZED_NAME_X509_CLIENT_CERT_B64 = "x509_client_cert_b64"; - /** @deprecated X.509 client certificate support is deprecated. */ + /** + * @deprecated X.509 client certificate support is deprecated. + */ @Deprecated @SerializedName(SERIALIZED_NAME_X509_CLIENT_CERT_B64) private String x509ClientCertB64; public static final String SERIALIZED_NAME_X509_CLIENT_KEY = "x509_client_key"; - /** @deprecated X.509 client key support is deprecated. */ + /** + * @deprecated X.509 client key support is deprecated. + */ @Deprecated @SerializedName(SERIALIZED_NAME_X509_CLIENT_KEY) private String x509ClientKey; public static final String SERIALIZED_NAME_X509_CLIENT_KEY_B64 = "x509_client_key_b64"; - /** @deprecated X.509 client key support is deprecated. */ + /** + * @deprecated X.509 client key support is deprecated. + */ @Deprecated @SerializedName(SERIALIZED_NAME_X509_CLIENT_KEY_B64) private String x509ClientKeyB64; @@ -92,7 +99,6 @@ public class Profile { @SerializedName(SERIALIZED_NAME_RETRY_BACKOFF_MAX) private Float retry_backoff_max; - private Integer limiter_max_requests; private Integer limiter_window; @@ -144,7 +150,7 @@ public String toString() { sb.append("class Profile {\n"); sb.append(" accessKey: ").append(accessKey).append("\n"); - if (secretKey.isEmpty()) { + if (secretKey == null || secretKey.isEmpty()) { sb.append(" secretKey: ").append(secretKey).append("\n"); } else { sb.append(" secretKey: ***\n"); @@ -155,7 +161,7 @@ public String toString() { sb.append(" x509ClientCertB64: ").append(x509ClientCertB64).append("\n"); sb.append(" x509ClientKey: ").append(x509ClientKey).append("\n"); - if (x509ClientKeyB64.isEmpty()) { + if (x509ClientKeyB64 == null || x509ClientKeyB64.isEmpty()) { sb.append(" x509ClientKeyB64: ").append(x509ClientKeyB64).append("\n"); } else { sb.append(" x509ClientKeyB64: ***\n"); @@ -198,25 +204,33 @@ public String getSecretKey() { return secretKey; } - /** @deprecated X.509 client certificate support is deprecated. */ + /** + * @deprecated X.509 client certificate support is deprecated. + */ @Deprecated public String getX509ClientCert() { return x509ClientCert; } - /** @deprecated X.509 client certificate support is deprecated. */ + /** + * @deprecated X.509 client certificate support is deprecated. + */ @Deprecated public String getX509ClientCertB64() { return x509ClientCertB64; } - /** @deprecated X.509 client key support is deprecated. */ + /** + * @deprecated X.509 client key support is deprecated. + */ @Deprecated public String getX509ClientKey() { return x509ClientKey; } - /** @deprecated X.509 client key support is deprecated. */ + /** + * @deprecated X.509 client key support is deprecated. + */ @Deprecated public String getX509ClientKeyB64() { return x509ClientKeyB64; @@ -242,7 +256,7 @@ public Integer getLimiterMaxRequests() { return limiter_max_requests; } - + public Integer getLimiterWindow() { return limiter_window; @@ -272,25 +286,33 @@ public void setSecretKey(String secretKey) { this.secretKey = secretKey; } - /** @deprecated X.509 client certificate support is deprecated. */ + /** + * @deprecated X.509 client certificate support is deprecated. + */ @Deprecated public void setX509ClientCert(String x509ClientCert) { this.x509ClientCert = x509ClientCert; } - /** @deprecated X.509 client certificate support is deprecated. */ + /** + * @deprecated X.509 client certificate support is deprecated. + */ @Deprecated public void setX509ClientCertB64(String x509ClientCertB64) { this.x509ClientCertB64 = x509ClientCertB64; } - /** @deprecated X.509 client key support is deprecated. */ + /** + * @deprecated X.509 client key support is deprecated. + */ @Deprecated public void setX509ClientKey(String x509ClientKey) { this.x509ClientKey = x509ClientKey; } - /** @deprecated X.509 client key support is deprecated. */ + /** + * @deprecated X.509 client key support is deprecated. + */ @Deprecated public void setX509ClientKeyB64(String x509ClientKeyB64) { this.x509ClientKeyB64 = x509ClientKeyB64; diff --git a/sdk/templates/JSON.mustache b/sdk/templates/JSON.mustache index 5ef02660..6bd8bef6 100644 --- a/sdk/templates/JSON.mustache +++ b/sdk/templates/JSON.mustache @@ -401,6 +401,11 @@ public class JSON { return null; default: String date = in.nextString(); + // ponytail: API sends full ISO date-times for some `format: date` fields; + // truncate to the date part. Upgrade path: spec fix to date-time upstream. + if (date.length() > 10 && date.charAt(10) == 'T') { + date = date.substring(0, 10); + } return LocalDate.parse(date, formatter); } } diff --git a/sdk/templates/libraries/okhttp-gson/JSON.mustache b/sdk/templates/libraries/okhttp-gson/JSON.mustache index eeb26cb9..a73befc6 100644 --- a/sdk/templates/libraries/okhttp-gson/JSON.mustache +++ b/sdk/templates/libraries/okhttp-gson/JSON.mustache @@ -426,6 +426,11 @@ public class JSON { return null; default: String date = in.nextString(); + // ponytail: API sends full ISO date-times for some `format: date` fields; + // truncate to the date part. Upgrade path: spec fix to date-time upstream. + if (date.length() > 10 && date.charAt(10) == 'T') { + date = date.substring(0, 10); + } return LocalDate.parse(date, formatter); } }