Merge branch 'next' of github.com:certimate-go/certimate into next

This commit is contained in:
Yoan.liu
2026-08-27 20:32:57 +08:00
496 changed files with 7119 additions and 1379 deletions
+434
View File
@@ -0,0 +1,434 @@
name: "GitHub Pull Requests Checker"
on:
issue_comment:
types: [created]
concurrency:
group: gh_pr_check-${{ github.event.issue.number }}
cancel-in-progress: true
permissions:
contents: read
pull-requests: read
statuses: write
jobs:
pr-guard:
if: >
github.event.issue.pull_request &&
contains(fromJSON('["OWNER", "MEMBER"]'), github.event.comment.author_association) &&
startsWith(github.event.comment.body, '/pr-check')
runs-on: ubuntu-latest
steps:
- name: Log
run: |
echo "Triggered by @${{ github.event.comment.user.login }}"
echo "On PR #${{ github.event.issue.number }}"
- name: Get PR details
id: pr_details
uses: actions/github-script@v9
with:
script: |
const { data: pr } = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number,
});
core.setOutput("git_head_repo", pr.head.repo.full_name);
core.setOutput("git_head_ref", pr.head.ref);
core.setOutput("git_head_sha", pr.head.sha);
console.log(`git head repo: ${pr.head.repo.full_name}, ref: ${pr.head.ref}, sha: ${pr.head.sha}`);
outputs:
git_head_repo: ${{ steps.pr_details.outputs.git_head_repo }}
git_head_ref: ${{ steps.pr_details.outputs.git_head_ref }}
git_head_sha: ${{ steps.pr_details.outputs.git_head_sha }}
no_compile: ${{ contains(github.event.comment.body, '-no-compile') }}
no_test: ${{ contains(github.event.comment.body, '-no-test') }}
no_lint: ${{ contains(github.event.comment.body, '-no-lint') }}
compile-build:
if: needs.pr-guard.outputs.no_compile != 'true'
needs: pr-guard
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Initialize Actions status
if: matrix.os == 'ubuntu-latest'
uses: actions/github-script@v9
with:
script: |
await github.rest.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
sha: "${{ needs.pr-guard.outputs.git_head_sha }}",
state: "pending",
context: "pr-check/compile-build",
description: "Running...",
target_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`,
});
- name: Checkout
uses: actions/checkout@v7
with:
ref: refs/pull/${{ github.event.issue.number }}/merge
fetch-depth: 1
persist-credentials: false
submodules: true
- name: Set up Node.js
uses: actions/setup-node@v7
with:
node-version: 24
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: "go.mod"
- name: Check Node.js dependencies
run: |
npm --prefix=./ui ci
- name: Build Node.js
run: |
npm --prefix=./ui run build
- name: Build Go
env:
CGO_ENABLED: 0
run: |
go build -v -ldflags "-s -w" -trimpath -o ./dist/certimate ./
unit-test:
if: needs.pr-guard.outputs.no_test != 'true'
needs: pr-guard
runs-on: ubuntu-latest
steps:
- name: Initialize Actions status
uses: actions/github-script@v9
with:
script: |
await github.rest.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
sha: "${{ needs.pr-guard.outputs.git_head_sha }}",
state: "pending",
context: "pr-check/unit-test",
description: "Running...",
target_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`,
});
- name: Checkout
uses: actions/checkout@v7
with:
ref: refs/pull/${{ github.event.issue.number }}/merge
fetch-depth: 1
persist-credentials: false
submodules: true
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: "go.mod"
- name: Run Go unit tests
id: gotest
if: success() || failure()
continue-on-error: true
run: |
# Exclude paths below:
EXCLUDES=(
"./pkg/core/certmgr/providers-tester/"
"./pkg/core/deployer/providers-tester/"
"./pkg/core/notifier/providers-tester/"
"./pkg/core/purger/providers-tester/"
"./pkg/sdk3rd-forked/"
)
GO_PKGS=$(go list -f '{{if or .TestGoFiles .XTestGoFiles}}{{.ImportPath}}{{end}}' ./... | grep -Ev $(IFS='|'; echo "${EXCLUDES[*]}"))
echo " "
echo "Testing packages:"
echo "$GO_PKGS"
echo " "
if ! go test -race -v $GO_PKGS; then
echo "::error::Failed to run 'go test', please fix the issues." >&2
exit 1
else
go test -tags=tester -c -o /dev/null ./...
echo "'go test' passed."
fi
- name: Check state
if: always()
run: |
if [[ "${{ steps.gotest.outcome }}" == "failure" ]]; then
echo "::error::Some cases failed."
exit 1
fi
lint-format:
if: needs.pr-guard.outputs.no_lint != 'true'
needs: pr-guard
runs-on: ubuntu-latest
steps:
- name: Initialize Actions status
uses: actions/github-script@v9
with:
script: |
await github.rest.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
sha: "${{ needs.pr-guard.outputs.git_head_sha }}",
state: "pending",
context: "pr-check/lint-format",
description: "Running...",
target_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`,
});
- name: Checkout
uses: actions/checkout@v7
with:
ref: refs/pull/${{ github.event.issue.number }}/merge
fetch-depth: 1
persist-credentials: false
submodules: true
- name: Set up Node.js
uses: actions/setup-node@v7
with:
node-version: 24
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: "go.mod"
# 暂时禁用,避免 Prettier 配置冲突导致检查失败
# - name: Run Node.js code linter
# id: jslint
# if: success() || failure()
# continue-on-error: true
# run: |
# git reset --hard HEAD
# git clean -df
# cd ui
# npm ci
# echo "Running 'eslint' ..."
# if ! npx eslint . --quiet; then
# echo "::error::'eslint' resulted in changes, please format files and commit them:"
# exit 1
# else
# echo "'eslint' passed."
# fi
- name: Run Node.js code formatter
id: jsfmt
if: success() || failure()
continue-on-error: true
run: |
git reset --hard HEAD
git clean -df
cd ui
npm ci
echo "Running 'eslint --fix' ..."
npx eslint . --fix --output-file=/dev/null
if ! git diff --quiet; then
echo "::error::'eslint --fix' resulted in changes, please format files and commit them:"
git diff --exit-code
exit 1
else
echo "'eslint --fix' passed."
fi
- name: Run Go code linter
id: golint
if: success() || failure()
continue-on-error: true
run: |
git reset --hard HEAD
git clean -df
# Exclude paths below:
EXCLUDES=(
"./pkg/sdk3rd-forked/"
"./pkg/sdk3rd-trimmed/"
)
GO_MODULE=$(go list -m)
GO_PKGS=$(go list ./... | grep -Ev $(IFS='|'; echo "${EXCLUDES[*]}"))
EXCLUDE_FUNC=()
for pkg in ${GO_PKGS}; do
pkg_path="./${pkg#$GO_MODULE/}"
if [ ! -d "$pkg_path" ]; then
EXCLUDE_FUNC+=("$pkg")
continue
fi
if ! grep -RqE '//nolint:(all|govet)' "$pkg_path"/*.go 2>/dev/null; then
EXCLUDE_FUNC+=("$pkg")
fi
done
GO_PKGS=$(printf '%s\n' "${EXCLUDE_FUNC[@]}")
echo " "
echo "Linting packages:"
echo "$GO_PKGS"
echo " "
echo "Running 'go vet' ..."
if ! echo "$GO_PKGS" | xargs go vet; then
echo "::error::Failed to run 'go vet', please fix the issues."
exit 1
else
echo "'go vet' passed."
fi
- name: Run Go code formatter
id: gofmt
if: success() || failure()
continue-on-error: true
run: |
git reset --hard HEAD
git clean -df
go install mvdan.cc/gofumpt@latest
gofumpt --version
# Exclude paths below:
EXCLUDES=(
"./pkg/sdk3rd-forked/"
"./pkg/sdk3rd-trimmed/"
)
EXCLUDE_FUNC=()
for ex in "${EXCLUDES[@]}"; do
EXCLUDE_FUNC+=(-path "${ex}*" -prune -o)
done
GO_FILES="$(
find . \
"${EXCLUDE_FUNC[@]}" \
-type f -name "*.go" \
-print
)"
echo " "
echo "Formatting files:"
echo "$GO_FILES"
echo " "
echo "Running 'gofumpt' ..."
echo "$GO_FILES" | xargs -d '\n' gofumpt -l -w
if ! git diff --quiet; then
echo "::error::'gofumpt' resulted in changes, please format files and commit them:"
git diff --exit-code
exit 1
else
echo "'gofumpt' passed."
fi
- name: Check state
if: always()
run: |
if [[ "${{ steps.jslint.outcome }}" == "failure" ||
"${{ steps.jsfmt.outcome }}" == "failure" ||
"${{ steps.golint.outcome }}" == "failure" ||
"${{ steps.gofmt.outcome }}" == "failure" ]]; then
echo "::error::Some cases failed."
exit 1
fi
ending:
needs: [pr-guard, compile-build, unit-test, lint-format]
if: always() && needs.pr-guard.result == 'success'
runs-on: ubuntu-latest
permissions:
pull-requests: write
statuses: write
steps:
- name: Compute overall state
id: overall_state
run: |
# 最终状态:
# - 任一失败 → failure
# - 任一手动取消/超时 → cancelled
# - 全部成功 → success
RESULTS="${{ needs.compile-build.result }} ${{ needs.unit-test.result }} ${{ needs.lint-format.result }}"
if echo "$RESULTS" | grep -q "failure\|error"; then
echo "state=failure" >> "$GITHUB_OUTPUT"
elif echo "$RESULTS" | grep -q "cancelled"; then
echo "state=cancelled" >> "$GITHUB_OUTPUT"
else
echo "state=success" >> "$GITHUB_OUTPUT"
fi
- name: Set Actions status
uses: actions/github-script@v7
with:
script: |
const jobs = [
{
ctx: "pr-check/compile-build",
result: "${{ needs.compile-build.result }}",
skipped: "${{ needs.pr-guard.outputs.no_compile }}",
},
{
ctx: "pr-check/unit-test",
result: "${{ needs.unit-test.result }}",
skipped: "${{ needs.pr-guard.outputs.no_test }}",
},
{
ctx: "pr-check/lint-format",
result: "${{ needs.lint-format.result }}",
skipped: "${{ needs.pr-guard.outputs.no_lint }}",
},
];
const states = {
"success": "success",
"failure": "failure",
"cancelled": "error"
};
for (const j of jobs) {
if (j.skipped === "true") continue;
const state = states[j.result] || "error";
const desc = state === "success" ? "Passed"
: state === "failure" ? "Failed"
: "Cancelled";
await github.rest.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
sha: "${{ needs.pr-guard.outputs.git_head_sha }}",
state: state,
context: j.ctx,
description: desc,
target_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`,
});
}
- name: Create comment
uses: actions/github-script@v9
with:
script: |
const stateIcon = "${{ steps.overall_state.outputs.state }}" === "success" ? "✅"
: "${{ steps.overall_state.outputs.state }}" === "failure" ? "❌"
: "";
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: ${{ github.event.issue.number }},
body: stateIcon + "PR check done, overall result: **" + "${{ steps.overall_state.outputs.state }}" + "**\n" +
"- _compile-build_: **" + ("${{ needs.pr-guard.outputs.no_compile }}" === "true" ? "skipped" : "${{ needs.compile-build.result }}") + "**\n" +
"- _unit-test_: **" + ("${{ needs.pr-guard.outputs.no_test }}" === "true" ? "skipped" : "${{ needs.unit-test.result }}") + "**\n" +
"- _lint-format_: **" + ("${{ needs.pr-guard.outputs.no_lint }}" === "true" ? "skipped" : "${{ needs.lint-format.result }}") + "**\n\n" +
"Click to [view details](" + `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}` + ").",
});
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+10 -2
View File
@@ -11,9 +11,9 @@ on:
workflow_dispatch:
inputs:
tag:
description: "Tag version to be used for Docker image"
description: "Existing git tag to build and push (e.g. v0.4.31). Does not move the tag or recreate the GitHub Release."
required: true
default: "latest"
default: "v0.4.31"
jobs:
prepare-ui:
@@ -22,6 +22,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v7
with:
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref }}
fetch-depth: 1
persist-credentials: false
@@ -49,6 +50,7 @@ jobs:
- name: Checkout code
uses: actions/checkout@v7
with:
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref }}
fetch-depth: 1
persist-credentials: false
submodules: true
@@ -76,6 +78,8 @@ jobs:
type=ref,event=pr
type=semver,pattern=v{{version}}
type=semver,pattern=v{{major}}.{{minor}}
type=semver,pattern=v{{version}},value=${{ inputs.tag }},enable=${{ github.event_name == 'workflow_dispatch' }}
type=semver,pattern=v{{major}}.{{minor}},value=${{ inputs.tag }},enable=${{ github.event_name == 'workflow_dispatch' }}
- name: Log in to DOCKERHUB
uses: docker/login-action@v4
@@ -104,3 +108,7 @@ jobs:
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
tags: ${{ steps.meta.outputs.tags }}
# Aliyun ACR rejects Buildx default provenance attestations
# (application/vnd.oci.empty.v1+json).
provenance: false
sbom: false
@@ -103,3 +103,7 @@ jobs:
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
tags: ${{ steps.meta.outputs.tags }}
# Aliyun ACR rejects Buildx default provenance attestations
# (application/vnd.oci.empty.v1+json).
provenance: false
sbom: false
+1 -1
View File
@@ -14,7 +14,7 @@ __debug_bin*
.tmp*
vendor
build
dist
/certimate
/certimate.exe
+1
View File
@@ -8,6 +8,7 @@
"*.css": "tailwindcss",
"Dockerfile_*": "dockerfile"
},
"files.encoding": "utf8",
"go.useLanguageServer": true,
"gopls": {
"formatting.gofumpt": true,
+1 -1
View File
@@ -1,6 +1,6 @@
# 定义变量
BINARY_NAME=certimate
BUILD_DIR=build
BUILD_DIR=dist
# 支持的操作系统和架构列表
OS_ARCH=\
+4 -4
View File
@@ -138,12 +138,12 @@ This repository is available under the [MIT License](https://opensource.org/lice
## ⭐ Star History
Star Certificate on GitHub and be instantly notified of new releases!
Star Certimate on GitHub and be instantly notified of new releases!
<a href="https://www.star-history.com/?repos=certimate-go%2Fcertimate&type=date&legend=bottom-right">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=certimate-go/certimate&type=date&theme=dark&legend=bottom-right&sealed_token=AgSJWuhVJZ3c0ObBtRjr082YXnvEJdtzvse3YxJGfkUtB4nEs9RrHwwf2u41HTSOt-pU-h4lfJXzTAvRMNwKlvdEPY_BoV935TmriioBUABY69Offs4Ze9_f5mv2QP5yD5m3e5tv-HkNrHnkVVzJ2uDmJQkt6ta9Mg90DogAf4FK1mva-dd3DqZVkbw1" />
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=certimate-go/certimate&type=date&legend=bottom-right&sealed_token=AgSJWuhVJZ3c0ObBtRjr082YXnvEJdtzvse3YxJGfkUtB4nEs9RrHwwf2u41HTSOt-pU-h4lfJXzTAvRMNwKlvdEPY_BoV935TmriioBUABY69Offs4Ze9_f5mv2QP5yD5m3e5tv-HkNrHnkVVzJ2uDmJQkt6ta9Mg90DogAf4FK1mva-dd3DqZVkbw1" />
<img alt="Stargazers over time" src="https://api.star-history.com/chart?repos=certimate-go/certimate&type=date&legend=bottom-right&sealed_token=AgSJWuhVJZ3c0ObBtRjr082YXnvEJdtzvse3YxJGfkUtB4nEs9RrHwwf2u41HTSOt-pU-h4lfJXzTAvRMNwKlvdEPY_BoV935TmriioBUABY69Offs4Ze9_f5mv2QP5yD5m3e5tv-HkNrHnkVVzJ2uDmJQkt6ta9Mg90DogAf4FK1mva-dd3DqZVkbw1" />
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=certimate-go/certimate&type=date&theme=dark&legend=bottom-right&sealed_token=H4DPGE1XAt_F9BtU6OvSVvl5JuCYxptPOWaNf2PJ-jnenuG4X9BoFD21CJyriYWd-2kUWZabZ3yzUivF-6Q0gxFQythEiGTEvMQZuyz2lwn3ZEsMkdra35MkGHqr7dPjtgEJI6bD_-y_rZkm0r5POO6ChejyCg78P3sT_BmCt6HIbu_Jy8FqRB8IRl39" />
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=certimate-go/certimate&type=date&legend=bottom-right&sealed_token=H4DPGE1XAt_F9BtU6OvSVvl5JuCYxptPOWaNf2PJ-jnenuG4X9BoFD21CJyriYWd-2kUWZabZ3yzUivF-6Q0gxFQythEiGTEvMQZuyz2lwn3ZEsMkdra35MkGHqr7dPjtgEJI6bD_-y_rZkm0r5POO6ChejyCg78P3sT_BmCt6HIbu_Jy8FqRB8IRl39" />
<img alt="Star History Chart" src="https://api.star-history.com/chart?repos=certimate-go/certimate&type=date&legend=bottom-right&sealed_token=H4DPGE1XAt_F9BtU6OvSVvl5JuCYxptPOWaNf2PJ-jnenuG4X9BoFD21CJyriYWd-2kUWZabZ3yzUivF-6Q0gxFQythEiGTEvMQZuyz2lwn3ZEsMkdra35MkGHqr7dPjtgEJI6bD_-y_rZkm0r5POO6ChejyCg78P3sT_BmCt6HIbu_Jy8FqRB8IRl39" />
</picture>
</a>
+3 -3
View File
@@ -144,8 +144,8 @@ Certimate 遵循 [MIT License](https://opensource.org/licenses/MIT) 开源协议
<a href="https://www.star-history.com/?repos=certimate-go%2Fcertimate&type=date&legend=bottom-right">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=certimate-go/certimate&type=date&theme=dark&legend=bottom-right&sealed_token=AgSJWuhVJZ3c0ObBtRjr082YXnvEJdtzvse3YxJGfkUtB4nEs9RrHwwf2u41HTSOt-pU-h4lfJXzTAvRMNwKlvdEPY_BoV935TmriioBUABY69Offs4Ze9_f5mv2QP5yD5m3e5tv-HkNrHnkVVzJ2uDmJQkt6ta9Mg90DogAf4FK1mva-dd3DqZVkbw1" />
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=certimate-go/certimate&type=date&legend=bottom-right&sealed_token=AgSJWuhVJZ3c0ObBtRjr082YXnvEJdtzvse3YxJGfkUtB4nEs9RrHwwf2u41HTSOt-pU-h4lfJXzTAvRMNwKlvdEPY_BoV935TmriioBUABY69Offs4Ze9_f5mv2QP5yD5m3e5tv-HkNrHnkVVzJ2uDmJQkt6ta9Mg90DogAf4FK1mva-dd3DqZVkbw1" />
<img alt="Stargazers over time" src="https://api.star-history.com/chart?repos=certimate-go/certimate&type=date&legend=bottom-right&sealed_token=AgSJWuhVJZ3c0ObBtRjr082YXnvEJdtzvse3YxJGfkUtB4nEs9RrHwwf2u41HTSOt-pU-h4lfJXzTAvRMNwKlvdEPY_BoV935TmriioBUABY69Offs4Ze9_f5mv2QP5yD5m3e5tv-HkNrHnkVVzJ2uDmJQkt6ta9Mg90DogAf4FK1mva-dd3DqZVkbw1" />
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=certimate-go/certimate&type=date&theme=dark&legend=bottom-right&sealed_token=H4DPGE1XAt_F9BtU6OvSVvl5JuCYxptPOWaNf2PJ-jnenuG4X9BoFD21CJyriYWd-2kUWZabZ3yzUivF-6Q0gxFQythEiGTEvMQZuyz2lwn3ZEsMkdra35MkGHqr7dPjtgEJI6bD_-y_rZkm0r5POO6ChejyCg78P3sT_BmCt6HIbu_Jy8FqRB8IRl39" />
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=certimate-go/certimate&type=date&legend=bottom-right&sealed_token=H4DPGE1XAt_F9BtU6OvSVvl5JuCYxptPOWaNf2PJ-jnenuG4X9BoFD21CJyriYWd-2kUWZabZ3yzUivF-6Q0gxFQythEiGTEvMQZuyz2lwn3ZEsMkdra35MkGHqr7dPjtgEJI6bD_-y_rZkm0r5POO6ChejyCg78P3sT_BmCt6HIbu_Jy8FqRB8IRl39" />
<img alt="Star History Chart" src="https://api.star-history.com/chart?repos=certimate-go/certimate&type=date&legend=bottom-right&sealed_token=H4DPGE1XAt_F9BtU6OvSVvl5JuCYxptPOWaNf2PJ-jnenuG4X9BoFD21CJyriYWd-2kUWZabZ3yzUivF-6Q0gxFQythEiGTEvMQZuyz2lwn3ZEsMkdra35MkGHqr7dPjtgEJI6bD_-y_rZkm0r5POO6ChejyCg78P3sT_BmCt6HIbu_Jy8FqRB8IRl39" />
</picture>
</a>
+1 -1
View File
@@ -1,4 +1,4 @@
package cmd
package cmd
import (
"fmt"
+2 -2
View File
@@ -61,7 +61,7 @@ require (
github.com/pavlo-v-chernykh/keystore-go/v4 v4.5.0
github.com/pkg/sftp v1.13.11
github.com/pocketbase/dbx v1.12.0
github.com/pocketbase/pocketbase v0.39.9
github.com/pocketbase/pocketbase v0.39.10
github.com/povsister/scp v0.0.0-20250701154629-777cf82de5df
github.com/pquerna/otp v1.5.0
github.com/samber/lo v1.53.0
@@ -262,7 +262,7 @@ require (
modernc.org/libc v1.74.1 // indirect
modernc.org/mathutil v1.7.1 // indirect
modernc.org/memory v1.11.0 // indirect
modernc.org/sqlite v1.54.0 // indirect
modernc.org/sqlite v1.55.0 // indirect
)
replace gitlab.ecloud.com/ecloud/ecloudsdkcloudcore v1.0.0 => ./pkg/sdk3rd-forked/gitlab.ecloud.com/ecloud/ecloudsdkcloudcore@v1.0.0+mod
+4 -4
View File
@@ -763,8 +763,8 @@ github.com/pocketbase/dbx v1.12.0 h1:/oLErM+A0b4xI0PWTGPqSDVjzix48PqI/bng2l0PzoA
github.com/pocketbase/dbx v1.12.0/go.mod h1:xXRCIAKTHMgUCyCKZm55pUOdvFziJjQfXaWKhu2vhMs=
github.com/pocketbase/ozzo-validation/v4 v4.3.0 h1:uKBDVma7bZqgR2a6AwE+k9hkuDFfiZMpBHQdZ1z3iQs=
github.com/pocketbase/ozzo-validation/v4 v4.3.0/go.mod h1:6XNjSTw/Jb2F8LOkKO3oyzIWExbrGiYoS4uVxVwz90g=
github.com/pocketbase/pocketbase v0.39.9 h1:zmrvbWJwBlb+iXst02uD6zNqNpiyG86KtlOJjd+Bhx4=
github.com/pocketbase/pocketbase v0.39.9/go.mod h1:6l4ZFFa8kNkxLSumxzVm+DtczfUz86Wqow0bQYiXEkQ=
github.com/pocketbase/pocketbase v0.39.10 h1:2j8TDJRuo3aAC8Y8F9WFux0SwYcxeDCgEYQxxdWkwGE=
github.com/pocketbase/pocketbase v0.39.10/go.mod h1:tSX3anHQ7Ul6dPV9WhlEc6No1DtklGF69iwnVNW3BEE=
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s=
github.com/povsister/scp v0.0.0-20250701154629-777cf82de5df h1:zEgSHrxo8f6hGG1xCaqunfBq8hlfDmFd1JM0QXiQi7o=
@@ -1497,8 +1497,8 @@ modernc.org/opt v0.2.0 h1:tGyef5ApycA7FSEOMraay9SaTk5zmbx7Tu+cJs4QKZg=
modernc.org/opt v0.2.0/go.mod h1:03fq9lsNfvkYSfxrfUhZCWPk1lm4cq4N+Bh//bEtgns=
modernc.org/sortutil v1.2.1 h1:+xyoGf15mM3NMlPDnFqrteY07klSFxLElE2PVuWIJ7w=
modernc.org/sortutil v1.2.1/go.mod h1:7ZI3a3REbai7gzCLcotuw9AC4VZVpYMjDzETGsSMqJE=
modernc.org/sqlite v1.54.0 h1:JCxR4qwkJvOaqAoYcgDoO25Nc+ROg6EJ2LfBVzdrgog=
modernc.org/sqlite v1.54.0/go.mod h1:4ntCLuNmnH8+GNqjka1wNg7KJd5/Hi5FYp8K+XQ7GZw=
modernc.org/sqlite v1.55.0 h1:hIFh0MCH0rGinQ/4KYb5/UbCkRkb+UP+OkLCVWa5MTM=
modernc.org/sqlite v1.55.0/go.mod h1:4ntCLuNmnH8+GNqjka1wNg7KJd5/Hi5FYp8K+XQ7GZw=
modernc.org/strutil v1.2.1 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0=
modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A=
modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y=
+119
View File
@@ -0,0 +1,119 @@
package acmeaccount
import (
"context"
"fmt"
"github.com/certimate-go/certimate/internal/certacme"
"github.com/certimate-go/certimate/internal/domain"
"github.com/certimate-go/certimate/internal/domain/dtos"
)
type acmeAccountRepository interface {
List(ctx context.Context, page, perPage int, ca string) ([]*domain.ACMEAccount, int64, error)
GetById(ctx context.Context, id string) (*domain.ACMEAccount, error)
}
type Service struct {
repo acmeAccountRepository
}
func NewService(repo acmeAccountRepository) *Service {
return &Service{repo: repo}
}
func (s *Service) List(ctx context.Context, req *dtos.ACMEAccountListReq) (*dtos.ACMEAccountListResp, error) {
page := 1
perPage := 15
ca := ""
if req != nil {
page = req.Page
perPage = req.PerPage
ca = req.CA
}
if page < 1 {
page = 1
}
if perPage < 1 {
perPage = 15
}
if perPage > 100 {
perPage = 100
}
accounts, total, err := s.repo.List(ctx, page, perPage, ca)
if err != nil {
return nil, fmt.Errorf("failed to list acme accounts: %w", err)
}
items := make([]*dtos.ACMEAccountView, 0, len(accounts))
for _, account := range accounts {
items = append(items, toView(account))
}
return &dtos.ACMEAccountListResp{
Items: items,
TotalItems: total,
Page: page,
PerPage: perPage,
}, nil
}
func (s *Service) Import(ctx context.Context, req *dtos.ACMEAccountImportReq) (*dtos.ACMEAccountImportResp, error) {
if req == nil {
return nil, domain.NewError(400, "request body is empty")
}
account, err := certacme.ImportACMEAccount(ctx, &certacme.ImportACMEAccountOptions{
CA: req.CA,
ACMEDirUrl: req.ACMEDirUrl,
PrivateKeyPem: req.PrivateKeyPem,
Email: req.Email,
})
if err != nil {
return nil, err
}
return &dtos.ACMEAccountImportResp{Item: toView(account)}, nil
}
func (s *Service) Export(ctx context.Context, accountId string) (*dtos.ACMEAccountExportResp, error) {
if accountId == "" {
return nil, domain.NewError(400, "the account id is empty")
}
account, err := s.repo.GetById(ctx, accountId)
if err != nil {
if domain.IsRecordNotFoundError(err) {
return nil, domain.ErrRecordNotFound
}
return nil, fmt.Errorf("failed to get acme account: %w", err)
}
if account.PrivateKey == "" {
return nil, domain.NewError(404, "private key is empty")
}
return &dtos.ACMEAccountExportResp{PrivateKeyPem: account.PrivateKey}, nil
}
func (s *Service) Rotate(ctx context.Context, accountId string) (*dtos.ACMEAccountRotateResp, error) {
account, err := certacme.RotateACMEAccountKey(ctx, accountId)
if err != nil {
return nil, err
}
return &dtos.ACMEAccountRotateResp{Item: toView(account)}, nil
}
func toView(account *domain.ACMEAccount) *dtos.ACMEAccountView {
if account == nil {
return nil
}
return &dtos.ACMEAccountView{
Id: account.Id,
CA: account.CA,
Email: account.Email,
ACMEDirectoryUrl: account.ACMEDirectoryUrl,
ACMEAccountUrl: account.ACMEAccountUrl,
CreatedAt: account.CreatedAt,
UpdatedAt: account.UpdatedAt,
}
}
+160
View File
@@ -0,0 +1,160 @@
package acmeaccount
import (
"context"
"testing"
"time"
"github.com/certimate-go/certimate/internal/domain"
"github.com/certimate-go/certimate/internal/domain/dtos"
)
type mockRepo struct {
accounts []*domain.ACMEAccount
byID map[string]*domain.ACMEAccount
page int
perPage int
ca string
}
func (m *mockRepo) List(ctx context.Context, page, perPage int, ca string) ([]*domain.ACMEAccount, int64, error) {
m.page = page
m.perPage = perPage
m.ca = ca
filtered := make([]*domain.ACMEAccount, 0)
for _, a := range m.accounts {
if ca != "" && a.CA != ca {
continue
}
filtered = append(filtered, a)
}
total := int64(len(filtered))
if page < 1 {
page = 1
}
if perPage < 1 {
perPage = 15
}
start := (page - 1) * perPage
if start >= len(filtered) {
return []*domain.ACMEAccount{}, total, nil
}
end := start + perPage
if end > len(filtered) {
end = len(filtered)
}
return filtered[start:end], total, nil
}
func (m *mockRepo) GetById(ctx context.Context, id string) (*domain.ACMEAccount, error) {
if a, ok := m.byID[id]; ok {
return a, nil
}
return nil, domain.ErrRecordNotFound
}
func TestList_OmitsPrivateKeyAndPaginates(t *testing.T) {
repo := &mockRepo{
accounts: []*domain.ACMEAccount{
{
Meta: domain.Meta{Id: "a1", CreatedAt: time.Now(), UpdatedAt: time.Now()},
CA: "letsencrypt",
Email: "a@example.com",
PrivateKey: "-----BEGIN EC PRIVATE KEY-----\nSECRET\n-----END EC PRIVATE KEY-----",
ACMEDirectoryUrl: "https://acme-v02.api.letsencrypt.org/directory",
ACMEAccountUrl: "https://acme-v02.api.letsencrypt.org/acme/acct/1",
},
{
Meta: domain.Meta{Id: "a2", CreatedAt: time.Now(), UpdatedAt: time.Now()},
CA: "zerossl",
Email: "b@example.com",
PrivateKey: "SECRET2",
ACMEDirectoryUrl: "https://acme.zerossl.com/v2/DV90",
ACMEAccountUrl: "https://acme.zerossl.com/v2/DV90/account/2",
},
},
}
svc := NewService(repo)
resp, err := svc.List(context.Background(), &dtos.ACMEAccountListReq{Page: 1, PerPage: 1})
if err != nil {
t.Fatal(err)
}
if len(resp.Items) != 1 {
t.Fatalf("expected 1 item, got %d", len(resp.Items))
}
if resp.TotalItems != 2 {
t.Fatalf("totalItems = %d", resp.TotalItems)
}
if resp.Page != 1 || resp.PerPage != 1 {
t.Fatalf("page/perPage = %d/%d", resp.Page, resp.PerPage)
}
if resp.Items[0].Email != "a@example.com" {
t.Fatalf("email = %q", resp.Items[0].Email)
}
if resp.Items[0].Id != "a1" || resp.Items[0].ACMEAccountUrl == "" {
t.Fatalf("unexpected view: %+v", resp.Items[0])
}
}
func TestList_FilterByCA(t *testing.T) {
repo := &mockRepo{
accounts: []*domain.ACMEAccount{
{Meta: domain.Meta{Id: "a1"}, CA: "letsencrypt", Email: "a@example.com"},
{Meta: domain.Meta{Id: "a2"}, CA: "zerossl", Email: "b@example.com"},
},
}
svc := NewService(repo)
resp, err := svc.List(context.Background(), &dtos.ACMEAccountListReq{Page: 1, PerPage: 10, CA: "zerossl"})
if err != nil {
t.Fatal(err)
}
if len(resp.Items) != 1 || resp.TotalItems != 1 || resp.Items[0].CA != "zerossl" {
t.Fatalf("unexpected: %+v total=%d", resp.Items, resp.TotalItems)
}
if repo.ca != "zerossl" {
t.Fatalf("repo ca = %q", repo.ca)
}
}
func TestExport_ReturnsPEM(t *testing.T) {
pem := "-----BEGIN EC PRIVATE KEY-----\nTEST\n-----END EC PRIVATE KEY-----"
repo := &mockRepo{
byID: map[string]*domain.ACMEAccount{
"a1": {
Meta: domain.Meta{Id: "a1"},
PrivateKey: pem,
},
},
}
svc := NewService(repo)
resp, err := svc.Export(context.Background(), "a1")
if err != nil {
t.Fatal(err)
}
if resp.PrivateKeyPem != pem {
t.Fatalf("pem mismatch")
}
}
func TestExport_NotFound(t *testing.T) {
svc := NewService(&mockRepo{byID: map[string]*domain.ACMEAccount{}})
_, err := svc.Export(context.Background(), "missing")
if !domain.IsRecordNotFoundError(err) {
t.Fatalf("expected not found, got %v", err)
}
}
func TestToView_Nil(t *testing.T) {
if toView(nil) != nil {
t.Fatal("expected nil")
}
}
func TestImport_NilRequest(t *testing.T) {
svc := NewService(&mockRepo{})
_, err := svc.Import(context.Background(), nil)
if err == nil {
t.Fatal("expected error")
}
_ = &dtos.ACMEAccountImportReq{}
}
+2 -2
View File
@@ -1,7 +1,7 @@
package app
package app
const (
AppName = "Certimate"
AppVersion = "0.4.29"
AppVersion = "0.4.31"
AppUserAgent = AppName + "/" + AppVersion
)
+173
View File
@@ -0,0 +1,173 @@
package certacme
import (
"context"
"crypto"
"fmt"
"strings"
"github.com/go-acme/lego/v5/acme"
"github.com/go-acme/lego/v5/lego"
"github.com/certimate-go/certimate/internal/app"
"github.com/certimate-go/certimate/internal/domain"
"github.com/certimate-go/certimate/internal/repository"
xcert "github.com/certimate-go/certimate/pkg/utils/cert"
)
type ImportACMEAccountOptions struct {
CA string
ACMEDirUrl string
PrivateKeyPem string
Email string
}
func ImportACMEAccount(ctx context.Context, opts *ImportACMEAccountOptions) (*ACMEAccount, error) {
if opts == nil {
return nil, domain.NewError(400, "the import options are nil")
}
if strings.TrimSpace(opts.CA) == "" {
return nil, domain.NewError(400, "the ca is empty")
}
if strings.TrimSpace(opts.PrivateKeyPem) == "" {
return nil, domain.NewError(400, "the private key is empty")
}
dirUrl, err := resolveImportDirectoryURL(opts.CA, opts.ACMEDirUrl)
if err != nil {
return nil, err
}
privKey, err := xcert.ParsePrivateKeyFromPEM(opts.PrivateKeyPem)
if err != nil {
return nil, domain.NewError(400, fmt.Sprintf("invalid private key pem: %v", err))
}
signer, ok := privKey.(crypto.Signer)
if !ok {
return nil, domain.NewError(400, "private key is not a crypto.Signer")
}
keyPEM, err := xcert.ConvertPrivateKeyToPEM(privKey, false)
if err != nil {
keyPEM = opts.PrivateKeyPem
}
placeholder := &acme.Account{}
tempEmail := strings.TrimSpace(opts.Email)
if tempEmail == "" {
tempEmail = "import@local"
}
legoUser := &importLegoUser{
email: tempEmail,
privateKey: signer,
registration: &acme.ExtendedAccount{
Account: *placeholder,
Location: "",
},
}
legoCfg := lego.NewConfig(legoUser)
legoCfg.UserAgent = app.AppUserAgent
legoCfg.CADirURL = dirUrl
legoClient, err := lego.NewClient(legoCfg)
if err != nil {
return nil, fmt.Errorf("failed to create lego client: %w", err)
}
resolved, err := legoClient.Registration.ResolveAccountByKey(ctx)
if err != nil {
return nil, domain.NewError(404, fmt.Sprintf("failed to resolve acme account by key: %v", err))
}
if resolved == nil || resolved.Location == "" {
return nil, domain.NewError(404, "acme account not found for the given private key")
}
email := extractEmailFromContacts(resolved.Contact)
if email == "" {
email = strings.TrimSpace(opts.Email)
}
if email == "" {
return nil, domain.NewError(400, "the account has no email contact; please provide an email")
}
accountRepo := repository.NewACMEAccountRepository()
existing, err := accountRepo.GetByCAAndAcctUrl(ctx, opts.CA, resolved.Location)
if err != nil && !domain.IsRecordNotFoundError(err) {
return nil, fmt.Errorf("failed to check existing acme account: %w", err)
}
if existing != nil {
return nil, domain.NewError(409, "acme account already exists")
}
if byEmail, err := accountRepo.GetByCAAndEmail(ctx, opts.CA, dirUrl, email); err == nil && byEmail != nil {
if byEmail.ACMEAccountUrl == resolved.Location {
return nil, domain.NewError(409, "acme account already exists")
}
} else if err != nil && !domain.IsRecordNotFoundError(err) {
return nil, fmt.Errorf("failed to check existing acme account by email: %w", err)
}
account := &ACMEAccount{
CA: opts.CA,
Email: email,
PrivateKey: keyPEM,
ACMEDirectoryUrl: dirUrl,
ACMEAccountUrl: resolved.Location,
ResourceObject: &resolved.Account,
}
if _, err := accountRepo.Save(ctx, account); err != nil {
return nil, fmt.Errorf("failed to save acme account record: %w", err)
}
return account, nil
}
func resolveImportDirectoryURL(ca, explicitDir string) (string, error) {
if strings.TrimSpace(explicitDir) != "" {
return strings.TrimSpace(explicitDir), nil
}
provider := domain.CAProviderType(ca)
if provider == domain.CAProviderTypeACMECA {
return "", domain.NewError(400, "acmeDirUrl is required for custom ACME CA")
}
dirUrl, err := getCADirUrl(provider, nil, "")
if err != nil {
return "", domain.NewError(400, err.Error())
}
return dirUrl, nil
}
func extractEmailFromContacts(contacts []string) string {
for _, c := range contacts {
c = strings.TrimSpace(c)
if strings.HasPrefix(strings.ToLower(c), "mailto:") {
email := strings.TrimSpace(c[len("mailto:"):])
if email != "" {
return email
}
}
}
return ""
}
type importLegoUser struct {
email string
privateKey crypto.Signer
registration *acme.ExtendedAccount
}
func (u *importLegoUser) GetEmail() string {
return u.email
}
func (u *importLegoUser) GetRegistration() *acme.ExtendedAccount {
return u.registration
}
func (u *importLegoUser) GetPrivateKey() crypto.Signer {
return u.privateKey
}
+48
View File
@@ -0,0 +1,48 @@
package certacme
import "testing"
func TestExtractEmailFromContacts(t *testing.T) {
tests := []struct {
name string
contacts []string
want string
}{
{"empty", nil, ""},
{"mailto", []string{"mailto:user@example.com"}, "user@example.com"},
{"mixed", []string{"tel:+1", "mailto:u@x.com"}, "u@x.com"},
{"whitespace", []string{" mailto: spaced@x.com "}, "spaced@x.com"},
{"no mailto", []string{"user@example.com"}, ""},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := extractEmailFromContacts(tt.contacts)
if got != tt.want {
t.Fatalf("got %q want %q", got, tt.want)
}
})
}
}
func TestResolveImportDirectoryURL(t *testing.T) {
dir, err := resolveImportDirectoryURL("letsencrypt", "")
if err != nil {
t.Fatal(err)
}
if dir != "https://acme-v02.api.letsencrypt.org/directory" {
t.Fatalf("dir = %q", dir)
}
dir, err = resolveImportDirectoryURL("letsencrypt", "https://custom.example/directory")
if err != nil {
t.Fatal(err)
}
if dir != "https://custom.example/directory" {
t.Fatalf("override dir = %q", dir)
}
_, err = resolveImportDirectoryURL("acmeca", "")
if err == nil {
t.Fatal("expected error for acmeca without dir")
}
}
+91
View File
@@ -0,0 +1,91 @@
package certacme
import (
"context"
"crypto/ecdsa"
"crypto/elliptic"
"crypto/rand"
"fmt"
"github.com/go-acme/lego/v5/acme"
"github.com/go-acme/lego/v5/lego"
"github.com/certimate-go/certimate/internal/app"
"github.com/certimate-go/certimate/internal/domain"
"github.com/certimate-go/certimate/internal/repository"
xcert "github.com/certimate-go/certimate/pkg/utils/cert"
)
func RotateACMEAccountKey(ctx context.Context, accountId string) (*ACMEAccount, error) {
if accountId == "" {
return nil, domain.NewError(400, "the account id is empty")
}
accountRepo := repository.NewACMEAccountRepository()
account, err := accountRepo.GetById(ctx, accountId)
if err != nil {
if domain.IsRecordNotFoundError(err) {
return nil, domain.ErrRecordNotFound
}
return nil, fmt.Errorf("failed to get acme account: %w", err)
}
currentKey := account.GetPrivateKey()
if currentKey == nil {
return nil, domain.NewError(400, "stored private key is invalid or empty")
}
newKey, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
if err != nil {
return nil, fmt.Errorf("failed to generate new account key: %w", err)
}
newKeyPEM, err := xcert.ConvertECPrivateKeyToPEM(newKey, false)
if err != nil {
return nil, fmt.Errorf("failed to encode new account key: %w", err)
}
reg := account.GetRegistration()
if reg == nil || reg.Location == "" {
return nil, domain.NewError(400, "account registration location is empty")
}
legoUser := &importLegoUser{
email: account.Email,
privateKey: currentKey,
registration: reg,
}
legoCfg := lego.NewConfig(legoUser)
legoCfg.UserAgent = app.AppUserAgent
legoCfg.CADirURL = account.ACMEDirectoryUrl
legoClient, err := lego.NewClient(legoCfg)
if err != nil {
return nil, fmt.Errorf("failed to create lego client: %w", err)
}
if err := legoClient.Registration.KeyRollover(ctx, newKey); err != nil {
return nil, fmt.Errorf("failed to rollover acme account key: %w", err)
}
legoUser.privateKey = newKey
legoUser.registration = &acme.ExtendedAccount{
Account: *account.ResourceObject,
Location: account.ACMEAccountUrl,
}
legoCfg2 := lego.NewConfig(legoUser)
legoCfg2.UserAgent = app.AppUserAgent
legoCfg2.CADirURL = account.ACMEDirectoryUrl
legoClient2, err := lego.NewClient(legoCfg2)
if err == nil {
if refreshed, qerr := legoClient2.Registration.QueryRegistration(ctx); qerr == nil && refreshed != nil {
account.ResourceObject = &refreshed.Account
}
}
account.PrivateKey = newKeyPEM
if _, err := accountRepo.Save(ctx, account); err != nil {
return nil, fmt.Errorf("failed to save rotated acme account: %w", err)
}
return account, nil
}
+45
View File
@@ -0,0 +1,45 @@
package certacme
import (
"context"
"errors"
"fmt"
"time"
"github.com/go-acme/lego/v5/acme/api"
xcert "github.com/certimate-go/certimate/pkg/utils/cert"
)
type ARIInfo struct {
WindowStart time.Time
WindowEnd time.Time
NextRefreshAt time.Time
Supported bool
}
func (c *ACMEClient) GetARIInfo(ctx context.Context, certPEM string) (*ARIInfo, error) {
if certPEM == "" {
return nil, fmt.Errorf("the certificate PEM is empty")
}
certX509, err := xcert.ParseCertificateFromPEM(certPEM)
if err != nil {
return nil, fmt.Errorf("failed to parse certificate PEM: %w", err)
}
renewalInfo, err := c.client.Certificate.GetRenewalInfo(ctx, certX509)
if err != nil {
if errors.Is(err, api.ErrNoARI) {
return &ARIInfo{Supported: false}, nil
}
return nil, err
}
return &ARIInfo{
WindowStart: renewalInfo.SuggestedWindow.Start,
WindowEnd: renewalInfo.SuggestedWindow.End,
NextRefreshAt: time.Now().Add(renewalInfo.RetryAfter),
Supported: true,
}, nil
}
+16 -2
View File
@@ -54,6 +54,7 @@ type ObtainCertificateRequest struct {
ACMEProfile string
// ARI 相关
DisableARI bool
ARIReplacesAccountUrl string
ARIReplacesCertId string
}
@@ -66,6 +67,8 @@ type ObtainCertificateResponse struct {
PrivateKey string
ACMEAccountUrl string
ACMECertificateUrl string
ARIInfo *ARIInfo
ARIError string
ARIReplaced bool
}
@@ -183,7 +186,7 @@ func (c *ACMEClient) ObtainCertificate(ctx context.Context, request *ObtainCerti
}
}
return &ObtainCertificateResponse{
obtainResp := &ObtainCertificateResponse{
CAProvider: domain.CAProviderType(c.account.CA),
CSR: strings.TrimSpace(string(resp.CSR)),
FullChainCertificate: strings.TrimSpace(string(resp.Certificate)),
@@ -192,5 +195,16 @@ func (c *ACMEClient) ObtainCertificate(ctx context.Context, request *ObtainCerti
ACMEAccountUrl: c.account.ACMEAccountUrl,
ACMECertificateUrl: resp.CertURL,
ARIReplaced: req.ReplacesCertID != "",
}, nil
}
if !request.DisableARI {
ariInfo, err := c.GetARIInfo(ctx, obtainResp.FullChainCertificate)
if err != nil {
obtainResp.ARIError = err.Error()
} else {
obtainResp.ARIInfo = ariInfo
}
}
return obtainResp, nil
}
+24
View File
@@ -0,0 +1,24 @@
package deployers
import (
"fmt"
"github.com/certimate-go/certimate/internal/domain"
"github.com/certimate-go/certimate/pkg/core"
dplyimpl "github.com/certimate-go/certimate/pkg/core/deployer/providers/axisnow"
xmaps "github.com/certimate-go/certimate/pkg/utils/maps"
)
func init() {
Registries.MustRegister(domain.DeploymentProviderTypeAxisNow, func(options *ProviderFactoryOptions) (core.Deployer, error) {
credentials := domain.AccessConfigForAxisNow{}
if err := xmaps.Populate(options.ProviderAccessConfig, &credentials); err != nil {
return nil, fmt.Errorf("failed to populate provider access config: %w", err)
}
provider, err := dplyimpl.NewDeployer(&dplyimpl.DeployerConfig{
ApiToken: credentials.ApiToken,
})
return provider, err
})
}
@@ -0,0 +1,27 @@
package deployers
import (
"fmt"
"github.com/certimate-go/certimate/internal/domain"
"github.com/certimate-go/certimate/pkg/core"
dplyimpl "github.com/certimate-go/certimate/pkg/core/deployer/providers/huaweiibmc"
xmaps "github.com/certimate-go/certimate/pkg/utils/maps"
)
func init() {
Registries.MustRegister(domain.DeploymentProviderTypeHuaweiIBMC, func(options *ProviderFactoryOptions) (core.Deployer, error) {
credentials := domain.AccessConfigForHuaweiIBMC{}
if err := xmaps.Populate(options.ProviderAccessConfig, &credentials); err != nil {
return nil, fmt.Errorf("failed to populate Huawei iBMC access config: %w", err)
}
provider, err := dplyimpl.NewDeployer(&dplyimpl.DeployerConfig{
Host: credentials.Host,
Username: credentials.Username,
Password: credentials.Password,
AllowInsecureConnections: credentials.AllowInsecureConnections,
AutoRestart: xmaps.GetBool(options.ProviderExtendedConfig, "autoRestart"),
})
return provider, err
})
}
@@ -0,0 +1,29 @@
package deployers
import (
"fmt"
"github.com/certimate-go/certimate/internal/domain"
"github.com/certimate-go/certimate/pkg/core"
dplyimpl "github.com/certimate-go/certimate/pkg/core/deployer/providers/proxmoxbs"
xmaps "github.com/certimate-go/certimate/pkg/utils/maps"
)
func init() {
Registries.MustRegister(domain.DeploymentProviderTypeProxmoxBS, func(options *ProviderFactoryOptions) (core.Deployer, error) {
credentials := domain.AccessConfigForProxmoxBS{}
if err := xmaps.Populate(options.ProviderAccessConfig, &credentials); err != nil {
return nil, fmt.Errorf("failed to populate provider access config: %w", err)
}
provider, err := dplyimpl.NewDeployer(&dplyimpl.DeployerConfig{
ServerUrl: credentials.ServerUrl,
ApiToken: credentials.ApiToken,
ApiTokenSecret: credentials.ApiTokenSecret,
AllowInsecureConnections: credentials.AllowInsecureConnections,
NodeName: xmaps.GetString(options.ProviderExtendedConfig, "nodeName"),
AutoRestart: xmaps.GetBool(options.ProviderExtendedConfig, "autoRestart"),
})
return provider, err
})
}
@@ -17,12 +17,12 @@ func init() {
}
provider, err := dplyimpl.NewDeployer(&dplyimpl.DeployerConfig{
AccessKeyId: credentials.AccessKeyId,
SecretAccessKey: credentials.SecretAccessKey,
ZoneId: xmaps.GetString(options.ProviderExtendedConfig, "zoneId"),
DeployTarget: xmaps.GetString(options.ProviderExtendedConfig, "deployTarget"),
LoadbalancerId: xmaps.GetString(options.ProviderExtendedConfig, "loadbalancerId"),
ListenerId: xmaps.GetString(options.ProviderExtendedConfig, "listenerId"),
AccessKeyId: credentials.AccessKeyId,
SecretAccessKey: credentials.SecretAccessKey,
ZoneId: xmaps.GetString(options.ProviderExtendedConfig, "zoneId"),
DeployTarget: xmaps.GetString(options.ProviderExtendedConfig, "deployTarget"),
LoadbalancerId: xmaps.GetString(options.ProviderExtendedConfig, "loadbalancerId"),
ListenerId: xmaps.GetString(options.ProviderExtendedConfig, "listenerId"),
})
return provider, err
})
+19 -1
View File
@@ -87,6 +87,10 @@ type AccessConfigForAWS struct {
SecretAccessKey string `json:"secretAccessKey"`
}
type AccessConfigForAxisNow struct {
ApiToken string `json:"apiToken"`
}
type AccessConfigForAzure struct {
TenantId string `json:"tenantId"`
ClientId string `json:"clientId"`
@@ -344,6 +348,13 @@ type AccessConfigForHuaweiCloud struct {
EnterpriseProjectId string `json:"enterpriseProjectId,omitempty"`
}
type AccessConfigForHuaweiIBMC struct {
Host string `json:"host"`
Username string `json:"username"`
Password string `json:"password"`
AllowInsecureConnections bool `json:"allowInsecureConnections,omitempty"`
}
type AccessConfigForInfomaniak struct {
AccessToken string `json:"accessToken"`
}
@@ -478,10 +489,17 @@ type AccessConfigForPowerDNS struct {
AllowInsecureConnections bool `json:"allowInsecureConnections,omitempty"`
}
type AccessConfigForProxmoxBS struct {
ServerUrl string `json:"serverUrl"`
ApiToken string `json:"apiToken"`
ApiTokenSecret string `json:"apiTokenSecret"`
AllowInsecureConnections bool `json:"allowInsecureConnections,omitempty"`
}
type AccessConfigForProxmoxVE struct {
ServerUrl string `json:"serverUrl"`
ApiToken string `json:"apiToken"`
ApiTokenSecret string `json:"apiTokenSecret,omitempty"`
ApiTokenSecret string `json:"apiTokenSecret"`
AllowInsecureConnections bool `json:"allowInsecureConnections,omitempty"`
}
+45
View File
@@ -0,0 +1,45 @@
package dtos
import "time"
type ACMEAccountView struct {
Id string `json:"id"`
CA string `json:"ca"`
Email string `json:"email"`
ACMEDirectoryUrl string `json:"acmeDirUrl"`
ACMEAccountUrl string `json:"acmeAcctUrl"`
CreatedAt time.Time `json:"created"`
UpdatedAt time.Time `json:"updated"`
}
type ACMEAccountListReq struct {
Page int `json:"-"`
PerPage int `json:"-"`
CA string `json:"-"`
}
type ACMEAccountListResp struct {
Items []*ACMEAccountView `json:"items"`
TotalItems int64 `json:"totalItems"`
Page int `json:"page"`
PerPage int `json:"perPage"`
}
type ACMEAccountImportReq struct {
PrivateKeyPem string `json:"privateKeyPem"`
CA string `json:"ca"`
ACMEDirUrl string `json:"acmeDirUrl,omitempty"`
Email string `json:"email,omitempty"`
}
type ACMEAccountImportResp struct {
Item *ACMEAccountView `json:"item"`
}
type ACMEAccountExportResp struct {
PrivateKeyPem string `json:"privateKeyPem"`
}
type ACMEAccountRotateResp struct {
Item *ACMEAccountView `json:"item"`
}
+6
View File
@@ -25,6 +25,7 @@ const (
AccessProviderTypeAPISIX = AccessProviderType("apisix")
AccessProviderTypeArvanCloud = AccessProviderType("arvancloud")
AccessProviderTypeAWS = AccessProviderType("aws")
AccessProviderTypeAxisNow = AccessProviderType("axisnow")
AccessProviderTypeAzure = AccessProviderType("azure")
AccessProviderTypeBaiduCloud = AccessProviderType("baiducloud")
AccessProviderTypeBaishan = AccessProviderType("baishan")
@@ -75,6 +76,7 @@ const (
AccessProviderTypeHostingde = AccessProviderType("hostingde")
AccessProviderTypeHostinger = AccessProviderType("hostinger")
AccessProviderTypeHuaweiCloud = AccessProviderType("huaweicloud")
AccessProviderTypeHuaweiIBMC = AccessProviderType("huaweiibmc")
AccessProviderTypeInfomaniak = AccessProviderType("infomaniak")
AccessProviderTypeIONOS = AccessProviderType("ionos")
AccessProviderTypeJDCloud = AccessProviderType("jdcloud")
@@ -101,6 +103,7 @@ const (
AccessProviderTypeOVHcloud = AccessProviderType("ovhcloud")
AccessProviderTypePorkbun = AccessProviderType("porkbun")
AccessProviderTypePowerDNS = AccessProviderType("powerdns")
AccessProviderTypeProxmoxBS = AccessProviderType("proxmoxbs")
AccessProviderTypeProxmoxVE = AccessProviderType("proxmoxve")
AccessProviderTypeQingCloud = AccessProviderType("qingcloud")
AccessProviderTypeRainYun = AccessProviderType("rainyun")
@@ -339,6 +342,7 @@ const (
DeploymentProviderTypeAWSCloudFront = DeploymentProviderType(AccessProviderTypeAWS + "-cloudfront")
DeploymentProviderTypeAWSIAM = DeploymentProviderType(AccessProviderTypeAWS + "-iam")
DeploymentProviderTypeAWSNLB = DeploymentProviderType(AccessProviderTypeAWS + "-nlb")
DeploymentProviderTypeAxisNow = DeploymentProviderType(AccessProviderTypeAxisNow)
DeploymentProviderTypeAzureKeyVault = DeploymentProviderType(AccessProviderTypeAzure + "-keyvault")
DeploymentProviderTypeBaiduCloudAppBLB = DeploymentProviderType(AccessProviderTypeBaiduCloud + "-appblb")
DeploymentProviderTypeBaiduCloudBLB = DeploymentProviderType(AccessProviderTypeBaiduCloud + "-blb")
@@ -389,6 +393,7 @@ const (
DeploymentProviderTypeHuaweiCloudSCM = DeploymentProviderType(AccessProviderTypeHuaweiCloud + "-scm")
DeploymentProviderTypeHuaweiCloudVOD = DeploymentProviderType(AccessProviderTypeHuaweiCloud + "-vod")
DeploymentProviderTypeHuaweiCloudWAF = DeploymentProviderType(AccessProviderTypeHuaweiCloud + "-waf")
DeploymentProviderTypeHuaweiIBMC = DeploymentProviderType(AccessProviderTypeHuaweiIBMC)
DeploymentProviderTypeJDCloudALB = DeploymentProviderType(AccessProviderTypeJDCloud + "-alb")
DeploymentProviderTypeJDCloudCDN = DeploymentProviderType(AccessProviderTypeJDCloud + "-cdn")
DeploymentProviderTypeJDCloudLive = DeploymentProviderType(AccessProviderTypeJDCloud + "-live")
@@ -406,6 +411,7 @@ const (
DeploymentProviderTypeNetlify = DeploymentProviderType(AccessProviderTypeNetlify)
DeploymentProviderTypeNginxProxyManager = DeploymentProviderType(AccessProviderTypeNginxProxyManager)
DeploymentProviderTypeOracleCloudCertificatesMgmt = DeploymentProviderType(AccessProviderTypeOracleCloud + "-certificatesmgmt")
DeploymentProviderTypeProxmoxBS = DeploymentProviderType(AccessProviderTypeProxmoxBS)
DeploymentProviderTypeProxmoxVE = DeploymentProviderType(AccessProviderTypeProxmoxVE)
DeploymentProviderTypeQingCloudLB = DeploymentProviderType(AccessProviderTypeQingCloud + "-lb")
DeploymentProviderTypeRainYunRCDN = DeploymentProviderType(AccessProviderTypeRainYun + "-rcdn")
+61
View File
@@ -52,6 +52,67 @@ func (r *ACMEAccountRepository) GetByCAAndAcctUrl(ctx context.Context, ca string
return r.castRecordToModel(record)
}
func (r *ACMEAccountRepository) GetById(ctx context.Context, id string) (*domain.ACMEAccount, error) {
record, err := app.GetApp().FindRecordById(domain.CollectionNameACMEAccount, id)
if err != nil {
if errors.Is(err, sql.ErrNoRows) {
return nil, domain.ErrRecordNotFound
}
return nil, err
}
return r.castRecordToModel(record)
}
func (r *ACMEAccountRepository) List(ctx context.Context, page, perPage int, ca string) ([]*domain.ACMEAccount, int64, error) {
if page < 1 {
page = 1
}
if perPage < 1 {
perPage = 15
}
if perPage > 100 {
perPage = 100
}
filter := ""
params := dbx.Params{}
var countExprs []dbx.Expression
if ca != "" {
filter = "ca={:ca}"
params["ca"] = ca
countExprs = append(countExprs, dbx.HashExp{"ca": ca})
}
total, err := app.GetApp().CountRecords(domain.CollectionNameACMEAccount, countExprs...)
if err != nil {
return nil, 0, err
}
offset := (page - 1) * perPage
records, err := app.GetApp().FindRecordsByFilter(
domain.CollectionNameACMEAccount,
filter,
"ca,created",
perPage,
offset,
params,
)
if err != nil {
return nil, 0, err
}
accounts := make([]*domain.ACMEAccount, 0, len(records))
for _, record := range records {
account, err := r.castRecordToModel(record)
if err != nil {
return nil, 0, err
}
accounts = append(accounts, account)
}
return accounts, total, nil
}
func (r *ACMEAccountRepository) Save(ctx context.Context, acmeAccount *domain.ACMEAccount) (*domain.ACMEAccount, error) {
collection, err := app.GetApp().FindCollectionByNameOrId(domain.CollectionNameACMEAccount)
if err != nil {
+80
View File
@@ -0,0 +1,80 @@
package handlers
import (
"context"
"strconv"
"github.com/pocketbase/pocketbase/core"
"github.com/pocketbase/pocketbase/tools/router"
"github.com/certimate-go/certimate/internal/domain/dtos"
"github.com/certimate-go/certimate/internal/rest/resp"
)
type acmeAccountService interface {
List(ctx context.Context, req *dtos.ACMEAccountListReq) (*dtos.ACMEAccountListResp, error)
Import(ctx context.Context, req *dtos.ACMEAccountImportReq) (*dtos.ACMEAccountImportResp, error)
Export(ctx context.Context, accountId string) (*dtos.ACMEAccountExportResp, error)
Rotate(ctx context.Context, accountId string) (*dtos.ACMEAccountRotateResp, error)
}
type ACMEAccountsHandler struct {
service acmeAccountService
}
func NewACMEAccountsHandler(router *router.RouterGroup[*core.RequestEvent], service acmeAccountService) {
handler := &ACMEAccountsHandler{service: service}
group := router.Group("/acme-accounts")
group.GET("", handler.list)
group.POST("/import", handler.importAccount)
group.POST("/{accountId}/export", handler.exportAccount)
group.POST("/{accountId}/rotate", handler.rotateAccount)
}
func (handler *ACMEAccountsHandler) list(e *core.RequestEvent) error {
page, _ := strconv.Atoi(e.Request.URL.Query().Get("page"))
perPage, _ := strconv.Atoi(e.Request.URL.Query().Get("perPage"))
ca := e.Request.URL.Query().Get("ca")
res, err := handler.service.List(e.Request.Context(), &dtos.ACMEAccountListReq{
Page: page,
PerPage: perPage,
CA: ca,
})
if err != nil {
return resp.Err(e, err)
}
return resp.Ok(e, res)
}
func (handler *ACMEAccountsHandler) importAccount(e *core.RequestEvent) error {
req := &dtos.ACMEAccountImportReq{}
if err := e.BindBody(req); err != nil {
return resp.Err(e, err)
}
res, err := handler.service.Import(e.Request.Context(), req)
if err != nil {
return resp.Err(e, err)
}
return resp.Ok(e, res)
}
func (handler *ACMEAccountsHandler) exportAccount(e *core.RequestEvent) error {
accountId := e.Request.PathValue("accountId")
res, err := handler.service.Export(e.Request.Context(), accountId)
if err != nil {
return resp.Err(e, err)
}
return resp.Ok(e, res)
}
func (handler *ACMEAccountsHandler) rotateAccount(e *core.RequestEvent) error {
accountId := e.Request.PathValue("accountId")
res, err := handler.service.Rotate(e.Request.Context(), accountId)
if err != nil {
return resp.Err(e, err)
}
return resp.Ok(e, res)
}
+3
View File
@@ -5,6 +5,7 @@ import (
"github.com/pocketbase/pocketbase/core"
"github.com/pocketbase/pocketbase/tools/router"
"github.com/certimate-go/certimate/internal/acmeaccount"
"github.com/certimate-go/certimate/internal/certificate"
"github.com/certimate-go/certimate/internal/notify"
"github.com/certimate-go/certimate/internal/pluginhost"
@@ -37,6 +38,7 @@ func BindRouter(router *router.Router[*core.RequestEvent]) {
statisticsSvc = statistics.NewStatisticsService(statisticsRepo)
notifySvc = notify.NewNotifyService(accessRepo)
providerSchemaSvc = providerschema.NewProviderSchemaService(providerSchemaRepo)
acmeAccountSvc := acmeaccount.NewService(acmeAccountRepo)
group := router.Group("/api")
group.Bind(apis.RequireSuperuserAuth())
@@ -48,4 +50,5 @@ func BindRouter(router *router.Router[*core.RequestEvent]) {
handlers.NewPluginCatalogHandler(group, pluginhost.GlobalCatalog())
handlers.NewPluginAdminHandler(group)
handlers.NewPluginMarketHandler(group, pluginhost.GlobalMarketService())
handlers.NewACMEAccountsHandler(group, acmeAccountSvc)
}
+1 -1
View File
@@ -1,4 +1,4 @@
package settings
package settings
import (
"github.com/certimate-go/certimate/internal/app"
+3 -3
View File
@@ -1,4 +1,4 @@
package settings
package settings
import (
"context"
@@ -17,7 +17,7 @@ func GetGlobalSettingsForSSLProvider() domain.SettingsContentForSSLProvider {
if content == nil {
content = domain.SettingsContent{}
}
return *(content.(domain.SettingsContent)).AsSSLProvider()
return *content.(domain.SettingsContent).AsSSLProvider()
}
func GetGlobalSettingsForPersistence() domain.SettingsContentForPersistence {
@@ -27,7 +27,7 @@ func GetGlobalSettingsForPersistence() domain.SettingsContentForPersistence {
if content == nil {
content = domain.SettingsContent{}
}
return *(content.(domain.SettingsContent)).AsPersistence()
return *content.(domain.SettingsContent).AsPersistence()
}
func registerSettingsStoreByName(settingsName string) error {
+1 -1
View File
@@ -1,4 +1,4 @@
package settings
package settings
import (
"github.com/certimate-go/certimate/internal/domain"
+1 -1
View File
@@ -1,4 +1,4 @@
package ftp
package ftp
import (
"github.com/jlaffaye/ftp"
+1 -1
View File
@@ -1,4 +1,4 @@
package s3
package s3
import (
"bytes"
+1 -1
View File
@@ -1,4 +1,4 @@
package s3
package s3
const (
SignatureV2 = "v2"
+1 -1
View File
@@ -1,4 +1,4 @@
package smtp
package smtp
import (
"context"
+1 -1
View File
@@ -1,4 +1,4 @@
package smtp
package smtp
const (
defaultPort int = 25
+1 -1
View File
@@ -1,4 +1,4 @@
package smtp
package smtp
import (
"github.com/wneessen/go-mail"
+4
View File
@@ -10,6 +10,10 @@ type accessRepository interface {
GetById(ctx context.Context, id string) (*domain.Access, error)
}
type acmeAccountRepository interface {
GetByCAAndAcctUrl(ctx context.Context, ca string, acctUrl string) (*domain.ACMEAccount, error)
}
type certificateRepository interface {
GetById(ctx context.Context, id string) (*domain.Certificate, error)
GetByWorkflowRunIdAndNodeId(ctx context.Context, workflowRunId string, workflowNodeId string) (*domain.Certificate, error)
+78 -2
View File
@@ -10,7 +10,9 @@ import (
"strings"
"time"
"github.com/go-acme/lego/v5/acme"
"github.com/go-acme/lego/v5/acme/api"
legocert "github.com/go-acme/lego/v5/certificate"
"github.com/go-acme/lego/v5/lego"
"github.com/samber/lo"
"github.com/xhit/go-str2duration/v2"
@@ -55,6 +57,7 @@ type bizApplyNodeExecutor struct {
nodeExecutor
accessRepo accessRepository
acmeAccountRepo acmeAccountRepository
certificateRepo certificateRepository
wfoutputRepo workflowOutputRepository
}
@@ -215,15 +218,31 @@ func (ne *bizApplyNodeExecutor) checkCanSkip(execCtx *NodeExecutionContext, last
return false, "the last requested certificate has been revoked"
}
now := time.Now()
ariTriggered := false
if !thisNodeCfg.DisableARI {
ariTriggered = ne.evaluateARI(now, lastCertificate, func() (*certacme.ARIInfo, error) {
return ne.getARIInfoForCertificate(execCtx, lastCertificate)
})
}
renewalInterval := time.Duration(thisNodeCfg.SkipBeforeExpiryDays) * time.Hour * 24
expirationTime := time.Until(lastCertificate.ValidityNotAfter)
daysLeft := int(math.Floor(expirationTime.Hours() / 24))
if expirationTime > renewalInterval {
staticTriggered := expirationTime <= renewalInterval
if !ariTriggered && !staticTriggered {
daysUntilRenewal := int(math.Ceil((expirationTime - renewalInterval).Hours() / 24))
return true, fmt.Sprintf("the last requested certificate expires in %d day(s), a renewal will be performed when the remaining validity is less than %d day(s), and the next renewal will be in %d day(s)", daysLeft, thisNodeCfg.SkipBeforeExpiryDays, daysUntilRenewal)
}
return false, fmt.Sprintf("the last requested certificate expires in %d day(s), the renewal window period has been reached", daysLeft)
switch {
case ariTriggered && staticTriggered:
return false, fmt.Sprintf("the last requested certificate expires in %d day(s), renewal triggered by both ARI suggestedWindow and SkipBeforeExpiryDays threshold", daysLeft)
case ariTriggered:
return false, fmt.Sprintf("the last requested certificate expires in %d day(s), renewal triggered by ARI suggestedWindow", daysLeft)
default:
return false, fmt.Sprintf("the last requested certificate expires in %d day(s), renewal triggered by SkipBeforeExpiryDays threshold", daysLeft)
}
}
return false, ""
@@ -345,6 +364,7 @@ func (ne *bizApplyNodeExecutor) execObtainCertificate(execCtx *NodeExecutionCont
HttpDelayWait: nodeCfg.HttpDelayWait,
PreferredChain: nodeCfg.PreferredChain,
ACMEProfile: nodeCfg.ACMEProfile,
DisableARI: nodeCfg.DisableARI,
ARIReplacesAccountUrl: lo.
If(nodeCfg.DisableARI || lastCertificate == nil, "").
ElseF(func() string {
@@ -437,6 +457,61 @@ func (ne *bizApplyNodeExecutor) execObtainCertificate(execCtx *NodeExecutionCont
return obtainResp, nil
}
func (ne *bizApplyNodeExecutor) getARIInfoForCertificate(execCtx *NodeExecutionContext, certificate *domain.Certificate) (*certacme.ARIInfo, error) {
if certificate == nil {
return nil, fmt.Errorf("the certificate is nil")
}
if certificate.ACMEAccountUrl == "" {
return nil, fmt.Errorf("the certificate has no ACME account URL")
}
acmeAcct, err := ne.acmeAccountRepo.GetByCAAndAcctUrl(execCtx.Context(), certificate.CA, certificate.ACMEAccountUrl)
if err != nil {
return nil, fmt.Errorf("failed to get ACME account by URL: %w", err)
}
acmeClient, err := certacme.NewACMEClientWithAccount(acmeAcct)
if err != nil {
return nil, fmt.Errorf("failed to initialize ACME client: %w", err)
}
return acmeClient.GetARIInfo(execCtx.Context(), certificate.Certificate)
}
func (ne *bizApplyNodeExecutor) evaluateARI(now time.Time, certificate *domain.Certificate, fetch func() (*certacme.ARIInfo, error)) bool {
ariInfo, err := fetch()
if err != nil {
ne.logger.Warn("could not refresh ARI info", slog.String("certificateId", certificate.Id), slog.Any("error", err))
return false
}
if ariInfo == nil || !ariInfo.Supported {
return false
}
return shouldRenewByARI(ariInfo.WindowStart, ariInfo.WindowEnd, now)
}
func shouldRenewByARI(windowStart, windowEnd, now time.Time) bool {
if windowStart.IsZero() || windowEnd.IsZero() {
return false
}
renewalInfo := &legocert.RenewalInfo{
ExtendedRenewalInfo: &acme.ExtendedRenewalInfo{
RenewalInfo: acme.RenewalInfo{
SuggestedWindow: acme.Window{
Start: windowStart,
End: windowEnd,
},
},
},
}
return renewalInfo.ShouldRenewAt(now, 0) != nil ||
(!now.Before(windowStart) && !now.After(windowEnd)) ||
now.After(windowEnd)
}
func (ne *bizApplyNodeExecutor) setOuputsOfResult(execCtx *NodeExecutionContext, execRes *NodeExecutionResult, certificate *domain.Certificate, persistent bool) {
if certificate != nil {
key := "certificate"
@@ -492,6 +567,7 @@ func newBizApplyNodeExecutor() NodeExecutor {
return &bizApplyNodeExecutor{
nodeExecutor: nodeExecutor{logger: slog.Default()},
accessRepo: repository.NewAccessRepository(),
acmeAccountRepo: repository.NewACMEAccountRepository(),
certificateRepo: repository.NewCertificateRepository(),
wfoutputRepo: repository.NewWorkflowOutputRepository(),
}
@@ -0,0 +1,98 @@
package engine
import (
"errors"
"log/slog"
"testing"
"time"
"github.com/certimate-go/certimate/internal/certacme"
"github.com/certimate-go/certimate/internal/domain"
)
func TestShouldRenewByARI(t *testing.T) {
now := time.Date(2026, 6, 9, 12, 0, 0, 0, time.UTC)
tests := []struct {
name string
windowStart time.Time
windowEnd time.Time
want bool
}{
{
name: "inactive window does not renew",
windowStart: now.Add(time.Hour),
windowEnd: now.Add(2 * time.Hour),
want: false,
},
{
name: "active window renews",
windowStart: now.Add(-time.Hour),
windowEnd: now.Add(time.Hour),
want: true,
},
{
name: "passed window renews",
windowStart: now.Add(-2 * time.Hour),
windowEnd: now.Add(-time.Hour),
want: true,
},
{
name: "zero window does not renew",
want: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := shouldRenewByARI(tt.windowStart, tt.windowEnd, now); got != tt.want {
t.Fatalf("shouldRenewByARI() = %v, want %v", got, tt.want)
}
})
}
}
func TestEvaluateARI(t *testing.T) {
now := time.Date(2026, 8, 7, 12, 0, 0, 0, time.UTC)
ne := &bizApplyNodeExecutor{nodeExecutor: nodeExecutor{logger: slog.Default()}}
t.Run("supported active window triggers renewal", func(t *testing.T) {
fetch := func() (*certacme.ARIInfo, error) {
return &certacme.ARIInfo{WindowStart: now.Add(-time.Hour), WindowEnd: now.Add(time.Hour), Supported: true}, nil
}
if !ne.evaluateARI(now, &domain.Certificate{}, fetch) {
t.Fatal("expected ARI renewal within the active window")
}
})
t.Run("unsupported CA does not trigger", func(t *testing.T) {
fetch := func() (*certacme.ARIInfo, error) {
return &certacme.ARIInfo{Supported: false}, nil
}
if ne.evaluateARI(now, &domain.Certificate{}, fetch) {
t.Fatal("expected no ARI renewal when CA is unsupported")
}
})
t.Run("fetch error does not trigger and does not block", func(t *testing.T) {
fetch := func() (*certacme.ARIInfo, error) {
return nil, errors.New("503 service unavailable")
}
if ne.evaluateARI(now, &domain.Certificate{}, fetch) {
t.Fatal("expected no ARI renewal on fetch error")
}
})
t.Run("queries every run regardless of past refresh", func(t *testing.T) {
calls := 0
fetch := func() (*certacme.ARIInfo, error) {
calls++
return &certacme.ARIInfo{WindowStart: now.Add(-time.Hour), WindowEnd: now.Add(time.Hour), Supported: true}, nil
}
_ = ne.evaluateARI(now, &domain.Certificate{}, fetch)
_ = ne.evaluateARI(now, &domain.Certificate{}, fetch)
if calls != 2 {
t.Fatalf("expected renewal-info fetched on every run (2 calls), got %d", calls)
}
})
}
+1 -1
View File
@@ -1,4 +1,4 @@
package workflow
package workflow
import (
"context"
+1 -1
View File
@@ -1,4 +1,4 @@
package workflow
package workflow
import (
"sync"
+1 -1
View File
@@ -1,4 +1,4 @@
package workflow
package workflow
import (
"context"
+1 -1
View File
@@ -1,4 +1,4 @@
package snaps
package snaps
// This is a definition backup of WorkflowNode for v0.3.
type WorkflowNode struct {
+1 -1
View File
@@ -1,4 +1,4 @@
package core
package core
import (
"github.com/go-acme/lego/v5/challenge"
@@ -1,3 +1,6 @@
//nolint:composites
//nolint:govet
package internal
import (
@@ -1,4 +1,4 @@
package internal
package internal
import (
"context"
@@ -14,7 +14,6 @@ import (
linodesdk "github.com/certimate-go/certimate/pkg/sdk3rd/linode"
)
// Environment variables names.
const (
envNamespace = "LINODE_"
@@ -1,4 +1,4 @@
package internal
package internal
import (
"context"
@@ -1,3 +1,5 @@
//go:build tester
package onepanelssl_test
import (
@@ -5,12 +7,12 @@ import (
"github.com/stretchr/testify/require"
tester "github.com/certimate-go/certimate/pkg/core/certmgr/providers-tester"
impl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/1panel"
it "github.com/certimate-go/certimate/pkg/core/certmgr/testing"
)
var (
fp = it.Args("1PANEL_")
fp = tester.InitArgs("1PANEL_")
fTestCertPath string
fTestKeyPath string
fServerUrl string
@@ -29,7 +31,7 @@ func init() {
/*
Shell command to run this test:
go test -v ./1panel_test.go -args \
go test -tags=tester -v ./1panel_test.go -args \
--1PANEL_TESTCERTPATH="/path/to/your-test-cert.pem" \
--1PANEL_TESTKEYPATH="/path/to/your-test-key.pem" \
--1PANEL_SERVERURL="http://127.0.0.1:20410" \
@@ -47,6 +49,6 @@ func TestProvider(t *testing.T) {
})
require.NoError(t, err)
it.TestUpload(t, provider, it.TestUploadArgs{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
tester.Upload(t, provider, tester.UploadInput{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
})
}
@@ -1,3 +1,5 @@
//go:build tester
package aliyuncas_test
import (
@@ -5,12 +7,12 @@ import (
"github.com/stretchr/testify/require"
tester "github.com/certimate-go/certimate/pkg/core/certmgr/providers-tester"
impl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/aliyun-cas"
it "github.com/certimate-go/certimate/pkg/core/certmgr/testing"
)
var (
fp = it.Args("ALIYUNCAS_")
fp = tester.InitArgs("ALIYUNCAS_")
fTestCertPath string
fTestKeyPath string
fAccessKeyId string
@@ -29,7 +31,7 @@ func init() {
/*
Shell command to run this test:
go test -v ./aliyun_cas_test.go -args \
go test -tags=tester -v ./aliyun_cas_test.go -args \
--ALIYUNCAS_TESTCERTPATH="/path/to/your-test-cert.pem" \
--ALIYUNCAS_TESTKEYPATH="/path/to/your-test-key.pem" \
--ALIYUNCAS_ACCESSKEYID="your-access-key-id" \
@@ -47,6 +49,6 @@ func TestProvider(t *testing.T) {
})
require.NoError(t, err)
it.TestUpload(t, provider, it.TestUploadArgs{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
tester.Upload(t, provider, tester.UploadInput{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
})
}
@@ -1,3 +1,5 @@
//go:build tester
package aliyunslb_test
import (
@@ -5,12 +7,12 @@ import (
"github.com/stretchr/testify/require"
tester "github.com/certimate-go/certimate/pkg/core/certmgr/providers-tester"
impl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/aliyun-slb"
it "github.com/certimate-go/certimate/pkg/core/certmgr/testing"
)
var (
fp = it.Args("ALIYUNSLB_")
fp = tester.InitArgs("ALIYUNSLB_")
fTestCertPath string
fTestKeyPath string
fAccessKeyId string
@@ -29,7 +31,7 @@ func init() {
/*
Shell command to run this test:
go test -v ./aliyun_slb_test.go -args \
go test -tags=tester -v ./aliyun_slb_test.go -args \
--ALIYUNSLB_TESTCERTPATH="/path/to/your-test-cert.pem" \
--ALIYUNSLB_TESTKEYPATH="/path/to/your-test-key.pem" \
--ALIYUNSLB_ACCESSKEYID="your-access-key-id" \
@@ -47,6 +49,6 @@ func TestProvider(t *testing.T) {
})
require.NoError(t, err)
it.TestUpload(t, provider, it.TestUploadArgs{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
tester.Upload(t, provider, tester.UploadInput{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
})
}
@@ -1,3 +1,5 @@
//go:build tester
package awsacm_test
import (
@@ -5,12 +7,12 @@ import (
"github.com/stretchr/testify/require"
tester "github.com/certimate-go/certimate/pkg/core/certmgr/providers-tester"
impl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/aws-acm"
it "github.com/certimate-go/certimate/pkg/core/certmgr/testing"
)
var (
fp = it.Args("AWSACM_")
fp = tester.InitArgs("AWSACM_")
fTestCertPath string
fTestKeyPath string
fAccessKeyId string
@@ -29,7 +31,7 @@ func init() {
/*
Shell command to run this test:
go test -v ./aws_acm_test.go -args \
go test -tags=tester -v ./aws_acm_test.go -args \
--AWSACM_TESTCERTPATH="/path/to/your-test-cert.pem" \
--AWSACM_TESTKEYPATH="/path/to/your-test-key.pem" \
--AWSACM_ACCESSKEYID="your-access-key-id" \
@@ -47,6 +49,6 @@ func TestProvider(t *testing.T) {
})
require.NoError(t, err)
it.TestUpload(t, provider, it.TestUploadArgs{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
tester.Upload(t, provider, tester.UploadInput{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
})
}
@@ -1,3 +1,5 @@
//go:build tester
package awsiam_test
import (
@@ -5,12 +7,12 @@ import (
"github.com/stretchr/testify/require"
tester "github.com/certimate-go/certimate/pkg/core/certmgr/providers-tester"
impl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/aws-iam"
it "github.com/certimate-go/certimate/pkg/core/certmgr/testing"
)
var (
fp = it.Args("AWSIAM_")
fp = tester.InitArgs("AWSIAM_")
fTestCertPath string
fTestKeyPath string
fAccessKeyId string
@@ -29,7 +31,7 @@ func init() {
/*
Shell command to run this test:
go test -v ./aws_iam_test.go -args \
go test -tags=tester -v ./aws_iam_test.go -args \
--AWSIAM_TESTCERTPATH="/path/to/your-test-cert.pem" \
--AWSIAM_TESTKEYPATH="/path/to/your-test-key.pem" \
--AWSIAM_ACCESSKEYID="your-access-key-id" \
@@ -47,6 +49,6 @@ func TestProvider(t *testing.T) {
})
require.NoError(t, err)
it.TestUpload(t, provider, it.TestUploadArgs{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
tester.Upload(t, provider, tester.UploadInput{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
})
}
@@ -0,0 +1,46 @@
//go:build tester
package axisnow_test
import (
"testing"
"github.com/stretchr/testify/require"
tester "github.com/certimate-go/certimate/pkg/core/certmgr/providers-tester"
impl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/axisnow"
)
var (
fp = tester.InitArgs("AXISNOW_")
fTestCertPath string
fTestKeyPath string
fApiToken string
)
func init() {
fp.DefineString(&fTestCertPath, "TESTCERTPATH")
fp.DefineString(&fTestKeyPath, "TESTKEYPATH")
fp.DefineString(&fApiToken, "APITOKEN")
}
/*
Shell command to run this test:
go test -tags=tester -v ./axisnow_test.go -args \
--AXISNOW_TESTCERTPATH="/path/to/your-test-cert.pem" \
--AXISNOW_TESTKEYPATH="/path/to/your-test-key.pem" \
--AXISNOW_APITOKEN="your-api-token"
*/
func TestProvider(t *testing.T) {
fp.Parse()
t.Run("Upload", func(t *testing.T) {
provider, err := impl.NewCertmgr(&impl.CertmgrConfig{
ApiToken: fApiToken,
})
require.NoError(t, err)
tester.Upload(t, provider, tester.UploadInput{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
})
}
@@ -1,3 +1,5 @@
//go:build tester
package azurekeyvault_test
import (
@@ -5,12 +7,12 @@ import (
"github.com/stretchr/testify/require"
tester "github.com/certimate-go/certimate/pkg/core/certmgr/providers-tester"
impl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/azure-keyvault"
it "github.com/certimate-go/certimate/pkg/core/certmgr/testing"
)
var (
fp = it.Args("AZUREKEYVAULT_")
fp = tester.InitArgs("AZUREKEYVAULT_")
fTestCertPath string
fTestKeyPath string
fTenantId string
@@ -33,7 +35,7 @@ func init() {
/*
Shell command to run this test:
go test -v ./azure_keyvault_test.go -args \
go test -tags=tester -v ./azure_keyvault_test.go -args \
--AZUREKEYVAULT_TESTCERTPATH="/path/to/your-test-cert.pem" \
--AZUREKEYVAULT_TESTKEYPATH="/path/to/your-test-key.pem" \
--AZUREKEYVAULT_TENANTID="your-tenant-id" \
@@ -55,6 +57,6 @@ func TestProvider(t *testing.T) {
})
require.NoError(t, err)
it.TestUpload(t, provider, it.TestUploadArgs{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
tester.Upload(t, provider, tester.UploadInput{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
})
}
@@ -1,3 +1,5 @@
//go:build tester
package baiducloudcert_test
import (
@@ -5,12 +7,12 @@ import (
"github.com/stretchr/testify/require"
tester "github.com/certimate-go/certimate/pkg/core/certmgr/providers-tester"
impl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/baiducloud-cert"
it "github.com/certimate-go/certimate/pkg/core/certmgr/testing"
)
var (
fp = it.Args("BAIDUCLOUDCERT_")
fp = tester.InitArgs("BAIDUCLOUDCERT_")
fTestCertPath string
fTestKeyPath string
fAccessKeyId string
@@ -27,7 +29,7 @@ func init() {
/*
Shell command to run this test:
go test -v ./baiducloud_cert_test.go -args \
go test -tags=tester -v ./baiducloud_cert_test.go -args \
--BAIDUCLOUDCERT_TESTCERTPATH="/path/to/your-test-cert.pem" \
--BAIDUCLOUDCERT_TESTKEYPATH="/path/to/your-test-key.pem" \
--BAIDUCLOUDCERT_ACCESSKEYID="your-access-key-id" \
@@ -43,6 +45,6 @@ func TestProvider(t *testing.T) {
})
require.NoError(t, err)
it.TestUpload(t, provider, it.TestUploadArgs{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
tester.Upload(t, provider, tester.UploadInput{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
})
}
@@ -1,3 +1,5 @@
//go:build tester
package baishancdn_test
import (
@@ -5,12 +7,12 @@ import (
"github.com/stretchr/testify/require"
tester "github.com/certimate-go/certimate/pkg/core/certmgr/providers-tester"
impl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/baishan-cdn"
it "github.com/certimate-go/certimate/pkg/core/certmgr/testing"
)
var (
fp = it.Args("BAISHANCDN_")
fp = tester.InitArgs("BAISHANCDN_")
fTestCertPath string
fTestKeyPath string
fApiToken string
@@ -25,7 +27,7 @@ func init() {
/*
Shell command to run this test:
go test -v ./baishan_cdn_test.go -args \
go test -tags=tester -v ./baishan_cdn_test.go -args \
--BAISHANCDN_TESTCERTPATH="/path/to/your-test-cert.pem" \
--BAISHANCDN_TESTKEYPATH="/path/to/your-test-key.pem" \
--BAISHANCDN_APITOKEN="your-api-token"
@@ -39,6 +41,6 @@ func TestProvider(t *testing.T) {
})
require.NoError(t, err)
it.TestUpload(t, provider, it.TestUploadArgs{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
tester.Upload(t, provider, tester.UploadInput{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
})
}
@@ -1,3 +1,5 @@
//go:build tester
package bytepluscdn_test
import (
@@ -5,12 +7,12 @@ import (
"github.com/stretchr/testify/require"
tester "github.com/certimate-go/certimate/pkg/core/certmgr/providers-tester"
impl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/byteplus-cdn"
it "github.com/certimate-go/certimate/pkg/core/certmgr/testing"
)
var (
fp = it.Args("BYTEPLUSCDN_")
fp = tester.InitArgs("BYTEPLUSCDN_")
fTestCertPath string
fTestKeyPath string
fAccessKeyId string
@@ -27,7 +29,7 @@ func init() {
/*
Shell command to run this test:
go test -v ./byteplus_cdn_test.go -args \
go test -tags=tester -v ./byteplus_cdn_test.go -args \
--BYTEPLUSCDN_TESTCERTPATH="/path/to/your-test-cert.pem" \
--BYTEPLUSCDN_TESTKEYPATH="/path/to/your-test-key.pem" \
--BYTEPLUSCDN_ACCESSKEYID="your-access-key-id" \
@@ -43,6 +45,6 @@ func TestProvider(t *testing.T) {
})
require.NoError(t, err)
it.TestUpload(t, provider, it.TestUploadArgs{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
tester.Upload(t, provider, tester.UploadInput{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
})
}
@@ -1,3 +1,5 @@
//go:build tester
package bytepluscertcenter_test
import (
@@ -5,12 +7,12 @@ import (
"github.com/stretchr/testify/require"
tester "github.com/certimate-go/certimate/pkg/core/certmgr/providers-tester"
impl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/byteplus-certcenter"
it "github.com/certimate-go/certimate/pkg/core/certmgr/testing"
)
var (
fp = it.Args("BYTEPLUSCERTCENTER_")
fp = tester.InitArgs("BYTEPLUSCERTCENTER_")
fTestCertPath string
fTestKeyPath string
fAccessKeyId string
@@ -27,7 +29,7 @@ func init() {
/*
Shell command to run this test:
go test -v ./byteplus_certcenter_test.go -args \
go test -tags=tester -v ./byteplus_certcenter_test.go -args \
--BYTEPLUSCERTCENTER_TESTCERTPATH="/path/to/your-test-cert.pem" \
--BYTEPLUSCERTCENTER_TESTKEYPATH="/path/to/your-test-key.pem" \
--BYTEPLUSCERTCENTER_ACCESSKEYID="your-access-key-id" \
@@ -43,6 +45,6 @@ func TestProvider(t *testing.T) {
})
require.NoError(t, err)
it.TestUpload(t, provider, it.TestUploadArgs{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
tester.Upload(t, provider, tester.UploadInput{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
})
}
@@ -1,3 +1,5 @@
//go:build tester
package byteplusmedialive_test
import (
@@ -5,12 +7,12 @@ import (
"github.com/stretchr/testify/require"
tester "github.com/certimate-go/certimate/pkg/core/certmgr/providers-tester"
impl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/byteplus-medialive"
it "github.com/certimate-go/certimate/pkg/core/certmgr/testing"
)
var (
fp = it.Args("BYTEPLUSMEDIALIVE_")
fp = tester.InitArgs("BYTEPLUSMEDIALIVE_")
fTestCertPath string
fTestKeyPath string
fAccessKeyId string
@@ -27,7 +29,7 @@ func init() {
/*
Shell command to run this test:
go test -v ./byteplus_medialive_test.go -args \
go test -tags=tester -v ./byteplus_medialive_test.go -args \
--BYTEPLUSMEDIALIVE_TESTCERTPATH="/path/to/your-test-cert.pem" \
--BYTEPLUSMEDIALIVE_TESTKEYPATH="/path/to/your-test-key.pem" \
--BYTEPLUSMEDIALIVE_ACCESSKEYID="your-access-key-id" \
@@ -43,6 +45,6 @@ func TestProvider(t *testing.T) {
})
require.NoError(t, err)
it.TestUpload(t, provider, it.TestUploadArgs{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
tester.Upload(t, provider, tester.UploadInput{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
})
}
@@ -1,3 +1,5 @@
//go:build tester
package cmcccloudvlb_test
import (
@@ -5,12 +7,12 @@ import (
"github.com/stretchr/testify/require"
tester "github.com/certimate-go/certimate/pkg/core/certmgr/providers-tester"
impl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/cmcccloud-vlb"
it "github.com/certimate-go/certimate/pkg/core/certmgr/testing"
)
var (
fp = it.Args("CMCCCLOUDVLB_")
fp = tester.InitArgs("CMCCCLOUDVLB_")
fTestCertPath string
fTestKeyPath string
fAccessKeyId string
@@ -29,7 +31,7 @@ func init() {
/*
Shell command to run this test:
go test -v ./cmcccloud_vlb_test.go -args \
go test -tags=tester -v ./cmcccloud_vlb_test.go -args \
--CMCCCLOUDVLB_TESTCERTPATH="/path/to/your-test-cert.pem" \
--CMCCCLOUDVLB_TESTKEYPATH="/path/to/your-test-key.pem" \
--CMCCCLOUDVLB_ACCESSKEYID="your-access-key-id" \
@@ -48,6 +50,6 @@ func TestProvider(t *testing.T) {
})
require.NoError(t, err)
it.TestUpload(t, provider, it.TestUploadArgs{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
tester.Upload(t, provider, tester.UploadInput{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
})
}
@@ -1,3 +1,5 @@
//go:build tester
package ctcccloudao_test
import (
@@ -5,12 +7,12 @@ import (
"github.com/stretchr/testify/require"
tester "github.com/certimate-go/certimate/pkg/core/certmgr/providers-tester"
impl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/ctcccloud-ao"
it "github.com/certimate-go/certimate/pkg/core/certmgr/testing"
)
var (
fp = it.Args("CTCCCLOUDAO_")
fp = tester.InitArgs("CTCCCLOUDAO_")
fTestCertPath string
fTestKeyPath string
fAccessKeyId string
@@ -27,7 +29,7 @@ func init() {
/*
Shell command to run this test:
go test -v ./ctcccloud_ao_test.go -args \
go test -tags=tester -v ./ctcccloud_ao_test.go -args \
--CTCCCLOUDAO_TESTCERTPATH="/path/to/your-test-cert.pem" \
--CTCCCLOUDAO_TESTKEYPATH="/path/to/your-test-key.pem" \
--CTCCCLOUDAO_ACCESSKEYID="your-access-key-id" \
@@ -43,6 +45,6 @@ func TestProvider(t *testing.T) {
})
require.NoError(t, err)
it.TestUpload(t, provider, it.TestUploadArgs{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
tester.Upload(t, provider, tester.UploadInput{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
})
}
@@ -1,3 +1,5 @@
//go:build tester
package ctcccloudcdn_test
import (
@@ -5,12 +7,12 @@ import (
"github.com/stretchr/testify/require"
tester "github.com/certimate-go/certimate/pkg/core/certmgr/providers-tester"
impl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/ctcccloud-cdn"
it "github.com/certimate-go/certimate/pkg/core/certmgr/testing"
)
var (
fp = it.Args("CTCCCLOUDCDN_")
fp = tester.InitArgs("CTCCCLOUDCDN_")
fTestCertPath string
fTestKeyPath string
fAccessKeyId string
@@ -27,7 +29,7 @@ func init() {
/*
Shell command to run this test:
go test -v ./ctcccloud_cdn_test.go -args \
go test -tags=tester -v ./ctcccloud_cdn_test.go -args \
--CTCCCLOUDCDN_TESTCERTPATH="/path/to/your-test-cert.pem" \
--CTCCCLOUDCDN_TESTKEYPATH="/path/to/your-test-key.pem" \
--CTCCCLOUDCDN_ACCESSKEYID="your-access-key-id" \
@@ -43,6 +45,6 @@ func TestProvider(t *testing.T) {
})
require.NoError(t, err)
it.TestUpload(t, provider, it.TestUploadArgs{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
tester.Upload(t, provider, tester.UploadInput{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
})
}
@@ -1,3 +1,5 @@
//go:build tester
package ctcccloudcms_test
import (
@@ -5,12 +7,12 @@ import (
"github.com/stretchr/testify/require"
tester "github.com/certimate-go/certimate/pkg/core/certmgr/providers-tester"
impl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/ctcccloud-cms"
it "github.com/certimate-go/certimate/pkg/core/certmgr/testing"
)
var (
fp = it.Args("CTCCCLOUDCMS_")
fp = tester.InitArgs("CTCCCLOUDCMS_")
fTestCertPath string
fTestKeyPath string
fAccessKeyId string
@@ -27,7 +29,7 @@ func init() {
/*
Shell command to run this test:
go test -v ./ctcccloud_cms_test.go -args \
go test -tags=tester -v ./ctcccloud_cms_test.go -args \
--CTCCCLOUDCMS_TESTCERTPATH="/path/to/your-test-cert.pem" \
--CTCCCLOUDCMS_TESTKEYPATH="/path/to/your-test-key.pem" \
--CTCCCLOUDCMS_ACCESSKEYID="your-access-key-id" \
@@ -43,6 +45,6 @@ func TestProvider(t *testing.T) {
})
require.NoError(t, err)
it.TestUpload(t, provider, it.TestUploadArgs{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
tester.Upload(t, provider, tester.UploadInput{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
})
}
@@ -1,3 +1,5 @@
//go:build tester
package ctcccloudelb_test
import (
@@ -5,12 +7,12 @@ import (
"github.com/stretchr/testify/require"
tester "github.com/certimate-go/certimate/pkg/core/certmgr/providers-tester"
impl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/ctcccloud-elb"
it "github.com/certimate-go/certimate/pkg/core/certmgr/testing"
)
var (
fp = it.Args("CTCCCLOUDELB_")
fp = tester.InitArgs("CTCCCLOUDELB_")
fTestCertPath string
fTestKeyPath string
fAccessKeyId string
@@ -29,7 +31,7 @@ func init() {
/*
Shell command to run this test:
go test -v ./ctcccloud_elb_test.go -args \
go test -tags=tester -v ./ctcccloud_elb_test.go -args \
--CTCCCLOUDELB_TESTCERTPATH="/path/to/your-test-cert.pem" \
--CTCCCLOUDELB_TESTKEYPATH="/path/to/your-test-key.pem" \
--CTCCCLOUDELB_ACCESSKEYID="your-access-key-id" \
@@ -47,6 +49,6 @@ func TestProvider(t *testing.T) {
})
require.NoError(t, err)
it.TestUpload(t, provider, it.TestUploadArgs{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
tester.Upload(t, provider, tester.UploadInput{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
})
}
@@ -1,3 +1,5 @@
//go:build tester
package ctcccloudicdn_test
import (
@@ -5,12 +7,12 @@ import (
"github.com/stretchr/testify/require"
tester "github.com/certimate-go/certimate/pkg/core/certmgr/providers-tester"
impl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/ctcccloud-icdn"
it "github.com/certimate-go/certimate/pkg/core/certmgr/testing"
)
var (
fp = it.Args("CTCCCLOUDICDN_")
fp = tester.InitArgs("CTCCCLOUDICDN_")
fTestCertPath string
fTestKeyPath string
fAccessKeyId string
@@ -27,7 +29,7 @@ func init() {
/*
Shell command to run this test:
go test -v ./ctcccloud_icdn_test.go -args \
go test -tags=tester -v ./ctcccloud_icdn_test.go -args \
--CTCCCLOUDICDN_TESTCERTPATH="/path/to/your-test-cert.pem" \
--CTCCCLOUDICDN_TESTKEYPATH="/path/to/your-test-key.pem" \
--CTCCCLOUDICDN_ACCESSKEYID="your-access-key-id" \
@@ -43,6 +45,6 @@ func TestProvider(t *testing.T) {
})
require.NoError(t, err)
it.TestUpload(t, provider, it.TestUploadArgs{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
tester.Upload(t, provider, tester.UploadInput{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
})
}
@@ -1,3 +1,5 @@
//go:build tester
package ctcccloudlvdn_test
import (
@@ -5,12 +7,12 @@ import (
"github.com/stretchr/testify/require"
tester "github.com/certimate-go/certimate/pkg/core/certmgr/providers-tester"
impl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/ctcccloud-lvdn"
it "github.com/certimate-go/certimate/pkg/core/certmgr/testing"
)
var (
fp = it.Args("CTCCCLOUDLVDN_")
fp = tester.InitArgs("CTCCCLOUDLVDN_")
fTestCertPath string
fTestKeyPath string
fAccessKeyId string
@@ -27,7 +29,7 @@ func init() {
/*
Shell command to run this test:
go test -v ./ctcccloud_lvdn_test.go -args \
go test -tags=tester -v ./ctcccloud_lvdn_test.go -args \
--CTCCCLOUDLVDN_TESTCERTPATH="/path/to/your-test-cert.pem" \
--CTCCCLOUDLVDN_TESTKEYPATH="/path/to/your-test-key.pem" \
--CTCCCLOUDLVDN_ACCESSKEYID="your-access-key-id" \
@@ -43,6 +45,6 @@ func TestProvider(t *testing.T) {
})
require.NoError(t, err)
it.TestUpload(t, provider, it.TestUploadArgs{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
tester.Upload(t, provider, tester.UploadInput{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
})
}
@@ -1,3 +1,5 @@
//go:build tester
package digitaloceancertificate_test
import (
@@ -5,12 +7,12 @@ import (
"github.com/stretchr/testify/require"
tester "github.com/certimate-go/certimate/pkg/core/certmgr/providers-tester"
impl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/digitalocean-certificate"
it "github.com/certimate-go/certimate/pkg/core/certmgr/testing"
)
var (
fp = it.Args("DIGITALOCEANCERTIFICATE_")
fp = tester.InitArgs("DIGITALOCEANCERTIFICATE_")
fTestCertPath string
fTestKeyPath string
fAccessToken string
@@ -25,7 +27,7 @@ func init() {
/*
Shell command to run this test:
go test -v ./digitalocean_certificate_test.go -args \
go test -tags=tester -v ./digitalocean_certificate_test.go -args \
--DIGITALOCEANCERTIFICATE_TESTCERTPATH="/path/to/your-test-cert.pem" \
--DIGITALOCEANCERTIFICATE_TESTKEYPATH="/path/to/your-test-key.pem" \
--DIGITALOCEANCERTIFICATE_ACCESSTOKEN="your-access-token"
@@ -39,6 +41,6 @@ func TestProvider(t *testing.T) {
})
require.NoError(t, err)
it.TestUpload(t, provider, it.TestUploadArgs{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
tester.Upload(t, provider, tester.UploadInput{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
})
}
@@ -0,0 +1,50 @@
//go:build tester
package dogecloud_test
import (
"testing"
"github.com/stretchr/testify/require"
tester "github.com/certimate-go/certimate/pkg/core/certmgr/providers-tester"
impl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/dogecloud"
)
var (
fp = tester.InitArgs("DOGECLOUD_")
fTestCertPath string
fTestKeyPath string
fAccessKey string
fSecretKey string
)
func init() {
fp.DefineString(&fTestCertPath, "TESTCERTPATH")
fp.DefineString(&fTestKeyPath, "TESTKEYPATH")
fp.DefineString(&fAccessKey, "ACCESSKEY")
fp.DefineString(&fSecretKey, "SECRETKEY")
}
/*
Shell command to run this test:
go test -tags=tester -v ./dogecloud_test.go -args \
--DOGECLOUD_TESTCERTPATH="/path/to/your-test-cert.pem" \
--DOGECLOUD_TESTKEYPATH="/path/to/your-test-key.pem" \
--DOGECLOUD_ACCESSKEY="your-access-key" \
--DOGECLOUD_SECRETKEY="your-secret-key"
*/
func TestProvider(t *testing.T) {
fp.Parse()
t.Run("Upload", func(t *testing.T) {
provider, err := impl.NewCertmgr(&impl.CertmgrConfig{
AccessKey: fAccessKey,
SecretKey: fSecretKey,
})
require.NoError(t, err)
tester.Upload(t, provider, tester.UploadInput{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
})
}
@@ -1,3 +1,5 @@
//go:build tester
package dokploy_test
import (
@@ -5,12 +7,12 @@ import (
"github.com/stretchr/testify/require"
tester "github.com/certimate-go/certimate/pkg/core/certmgr/providers-tester"
impl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/dokploy"
it "github.com/certimate-go/certimate/pkg/core/certmgr/testing"
)
var (
fp = it.Args("DOKPLOY_")
fp = tester.InitArgs("DOKPLOY_")
fTestCertPath string
fTestKeyPath string
fServerUrl string
@@ -27,7 +29,7 @@ func init() {
/*
Shell command to run this test:
go test -v ./dokploy_test.go -args \
go test -tags=tester -v ./dokploy_test.go -args \
--DOKPLOY_TESTCERTPATH="/path/to/your-test-cert.pem" \
--DOKPLOY_TESTKEYPATH="/path/to/your-test-key.pem" \
--DOKPLOY_SERVERURL="http://127.0.0.1:3000" \
@@ -44,6 +46,6 @@ func TestProvider(t *testing.T) {
})
require.NoError(t, err)
it.TestUpload(t, provider, it.TestUploadArgs{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
tester.Upload(t, provider, tester.UploadInput{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
})
}
@@ -1,3 +1,5 @@
//go:build tester
package gcorecdn_test
import (
@@ -5,12 +7,12 @@ import (
"github.com/stretchr/testify/require"
tester "github.com/certimate-go/certimate/pkg/core/certmgr/providers-tester"
impl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/gcore-cdn"
it "github.com/certimate-go/certimate/pkg/core/certmgr/testing"
)
var (
fp = it.Args("GCORECDN_")
fp = tester.InitArgs("GCORECDN_")
fTestCertPath string
fTestKeyPath string
fApiToken string
@@ -25,7 +27,7 @@ func init() {
/*
Shell command to run this test:
go test -v ./gcore_cdn_test.go -args \
go test -tags=tester -v ./gcore_cdn_test.go -args \
--GCORECDN_TESTCERTPATH="/path/to/your-test-cert.pem" \
--GCORECDN_TESTKEYPATH="/path/to/your-test-key.pem" \
--GCORECDN_APITOKEN="your-api-token"
@@ -39,6 +41,6 @@ func TestProvider(t *testing.T) {
})
require.NoError(t, err)
it.TestUpload(t, provider, it.TestUploadArgs{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
tester.Upload(t, provider, tester.UploadInput{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
})
}
@@ -1,3 +1,5 @@
//go:build tester
package googlecloudcertificatemanager_test
import (
@@ -6,12 +8,12 @@ import (
"github.com/stretchr/testify/require"
tester "github.com/certimate-go/certimate/pkg/core/certmgr/providers-tester"
impl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/googlecloud-certificatemanager"
it "github.com/certimate-go/certimate/pkg/core/certmgr/testing"
)
var (
fp = it.Args("GOOGLECLOUDCERTIFICATEMANAGER_")
fp = tester.InitArgs("GOOGLECLOUDCERTIFICATEMANAGER_")
fTestCertPath string
fTestKeyPath string
fProjectId string
@@ -28,7 +30,7 @@ func init() {
/*
Shell command to run this test:
go test -v ./googlecloud_certificatemanager_test.go -args \
go test -tags=tester -v ./googlecloud_certificatemanager_test.go -args \
--GOOGLECLOUDCERTIFICATEMANAGER_TESTCERTPATH="/path/to/your-test-cert.pem" \
--GOOGLECLOUDCERTIFICATEMANAGER_TESTKEYPATH="/path/to/your-test-key.pem" \
--GOOGLECLOUDCERTIFICATEMANAGER_PROJECTID="your-project-id" \
@@ -49,6 +51,6 @@ func TestProvider(t *testing.T) {
})
require.NoError(t, err)
it.TestUpload(t, provider, it.TestUploadArgs{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
tester.Upload(t, provider, tester.UploadInput{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
})
}
@@ -1,3 +1,5 @@
//go:build tester
package huaweicloudelb_test
import (
@@ -5,12 +7,12 @@ import (
"github.com/stretchr/testify/require"
tester "github.com/certimate-go/certimate/pkg/core/certmgr/providers-tester"
impl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/huaweicloud-elb"
it "github.com/certimate-go/certimate/pkg/core/certmgr/testing"
)
var (
fp = it.Args("HUAWEICLOUDELB_")
fp = tester.InitArgs("HUAWEICLOUDELB_")
fTestCertPath string
fTestKeyPath string
fAccessKeyId string
@@ -29,7 +31,7 @@ func init() {
/*
Shell command to run this test:
go test -v ./huaweicloud_elb_test.go -args \
go test -tags=tester -v ./huaweicloud_elb_test.go -args \
--HUAWEICLOUDELB_TESTCERTPATH="/path/to/your-test-cert.pem" \
--HUAWEICLOUDELB_TESTKEYPATH="/path/to/your-test-key.pem" \
--HUAWEICLOUDELB_ACCESSKEYID="your-access-key-id" \
@@ -47,6 +49,6 @@ func TestProvider(t *testing.T) {
})
require.NoError(t, err)
it.TestUpload(t, provider, it.TestUploadArgs{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
tester.Upload(t, provider, tester.UploadInput{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
})
}
@@ -1,3 +1,5 @@
//go:build tester
package huaweicloudscm_test
import (
@@ -5,12 +7,12 @@ import (
"github.com/stretchr/testify/require"
tester "github.com/certimate-go/certimate/pkg/core/certmgr/providers-tester"
impl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/huaweicloud-scm"
it "github.com/certimate-go/certimate/pkg/core/certmgr/testing"
)
var (
fp = it.Args("HUAWEICLOUDSCM_")
fp = tester.InitArgs("HUAWEICLOUDSCM_")
fTestCertPath string
fTestKeyPath string
fAccessKeyId string
@@ -29,7 +31,7 @@ func init() {
/*
Shell command to run this test:
go test -v ./huaweicloud_scm_test.go -args \
go test -tags=tester -v ./huaweicloud_scm_test.go -args \
--HUAWEICLOUDSCM_TESTCERTPATH="/path/to/your-test-cert.pem" \
--HUAWEICLOUDSCM_TESTKEYPATH="/path/to/your-test-key.pem" \
--HUAWEICLOUDSCM_ACCESSKEYID="your-access-key-id" \
@@ -47,6 +49,6 @@ func TestProvider(t *testing.T) {
})
require.NoError(t, err)
it.TestUpload(t, provider, it.TestUploadArgs{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
tester.Upload(t, provider, tester.UploadInput{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
})
}
@@ -1,3 +1,5 @@
//go:build tester
package huaweicloudwaf_test
import (
@@ -5,12 +7,12 @@ import (
"github.com/stretchr/testify/require"
tester "github.com/certimate-go/certimate/pkg/core/certmgr/providers-tester"
impl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/huaweicloud-waf"
it "github.com/certimate-go/certimate/pkg/core/certmgr/testing"
)
var (
fp = it.Args("HUAWEICLOUDWAF_")
fp = tester.InitArgs("HUAWEICLOUDWAF_")
fTestCertPath string
fTestKeyPath string
fAccessKeyId string
@@ -29,7 +31,7 @@ func init() {
/*
Shell command to run this test:
go test -v ./huaweicloud_waf_test.go -args \
go test -tags=tester -v ./huaweicloud_waf_test.go -args \
--HUAWEICLOUDWAF_TESTCERTPATH="/path/to/your-test-cert.pem" \
--HUAWEICLOUDWAF_TESTKEYPATH="/path/to/your-test-key.pem" \
--HUAWEICLOUDWAF_ACCESSKEYID="your-access-key-id" \
@@ -47,6 +49,6 @@ func TestProvider(t *testing.T) {
})
require.NoError(t, err)
it.TestUpload(t, provider, it.TestUploadArgs{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
tester.Upload(t, provider, tester.UploadInput{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
})
}
@@ -1,3 +1,5 @@
//go:build tester
package jdcloudssl_test
import (
@@ -5,12 +7,12 @@ import (
"github.com/stretchr/testify/require"
tester "github.com/certimate-go/certimate/pkg/core/certmgr/providers-tester"
impl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/jdcloud-ssl"
it "github.com/certimate-go/certimate/pkg/core/certmgr/testing"
)
var (
fp = it.Args("JDCLOUDSSL_")
fp = tester.InitArgs("JDCLOUDSSL_")
fTestCertPath string
fTestKeyPath string
fAccessKeyId string
@@ -27,7 +29,7 @@ func init() {
/*
Shell command to run this test:
go test -v ./jdcloud_ssl_test.go -args \
go test -tags=tester -v ./jdcloud_ssl_test.go -args \
--JDCLOUDSSL_TESTCERTPATH="/path/to/your-test-cert.pem" \
--JDCLOUDSSL_TESTKEYPATH="/path/to/your-test-key.pem" \
--JDCLOUDSSL_ACCESSKEYID="your-access-key-id" \
@@ -43,6 +45,6 @@ func TestProvider(t *testing.T) {
})
require.NoError(t, err)
it.TestUpload(t, provider, it.TestUploadArgs{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
tester.Upload(t, provider, tester.UploadInput{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
})
}
@@ -1,3 +1,5 @@
//go:build tester
package ksyunkcm_test
import (
@@ -5,12 +7,12 @@ import (
"github.com/stretchr/testify/require"
tester "github.com/certimate-go/certimate/pkg/core/certmgr/providers-tester"
impl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/ksyun-kcm"
it "github.com/certimate-go/certimate/pkg/core/certmgr/testing"
)
var (
fp = it.Args("KSYUNKCM_")
fp = tester.InitArgs("KSYUNKCM_")
fTestCertPath string
fTestKeyPath string
fAccessKeyId string
@@ -27,7 +29,7 @@ func init() {
/*
Shell command to run this test:
go test -v ./ksyun_kcm_test.go -args \
go test -tags=tester -v ./ksyun_kcm_test.go -args \
--KSYUNKCM_TESTCERTPATH="/path/to/your-test-cert.pem" \
--KSYUNKCM_TESTKEYPATH="/path/to/your-test-key.pem" \
--KSYUNKCM_ACCESSKEYID="your-access-key-id" \
@@ -43,6 +45,6 @@ func TestProvider(t *testing.T) {
})
require.NoError(t, err)
it.TestUpload(t, provider, it.TestUploadArgs{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
tester.Upload(t, provider, tester.UploadInput{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
})
}
@@ -1,3 +1,5 @@
//go:build tester
package ksyunslb_test
import (
@@ -5,12 +7,12 @@ import (
"github.com/stretchr/testify/require"
tester "github.com/certimate-go/certimate/pkg/core/certmgr/providers-tester"
impl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/ksyun-slb"
it "github.com/certimate-go/certimate/pkg/core/certmgr/testing"
)
var (
fp = it.Args("KSYUNSLB_")
fp = tester.InitArgs("KSYUNSLB_")
fTestCertPath string
fTestKeyPath string
fAccessKeyId string
@@ -29,7 +31,7 @@ func init() {
/*
Shell command to run this test:
go test -v ./ksyun_slb_test.go -args \
go test -tags=tester -v ./ksyun_slb_test.go -args \
--KSYUNSLB_TESTCERTPATH="/path/to/your-test-cert.pem" \
--KSYUNSLB_TESTKEYPATH="/path/to/your-test-key.pem" \
--KSYUNSLB_ACCESSKEYID="your-access-key-id" \
@@ -47,6 +49,6 @@ func TestProvider(t *testing.T) {
})
require.NoError(t, err)
it.TestUpload(t, provider, it.TestUploadArgs{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
tester.Upload(t, provider, tester.UploadInput{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
})
}
@@ -1,3 +1,5 @@
//go:build tester
package nginxproxymanager_test
import (
@@ -5,12 +7,12 @@ import (
"github.com/stretchr/testify/require"
tester "github.com/certimate-go/certimate/pkg/core/certmgr/providers-tester"
impl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/nginxproxymanager"
it "github.com/certimate-go/certimate/pkg/core/certmgr/testing"
)
var (
fp = it.Args("NGINXPROXYMANAGER_")
fp = tester.InitArgs("NGINXPROXYMANAGER_")
fTestCertPath string
fTestKeyPath string
fServerUrl string
@@ -29,7 +31,7 @@ func init() {
/*
Shell command to run this test:
go test -v ./nginxproxymanager_test.go -args \
go test -tags=tester -v ./nginxproxymanager_test.go -args \
--NGINXPROXYMANAGER_TESTCERTPATH="/path/to/your-test-cert.pem" \
--NGINXPROXYMANAGER_TESTKEYPATH="/path/to/your-test-key.pem" \
--NGINXPROXYMANAGER_SERVERURL="http://127.0.0.1:81" \
@@ -49,6 +51,6 @@ func TestProvider(t *testing.T) {
})
require.NoError(t, err)
it.TestUpload(t, provider, it.TestUploadArgs{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
tester.Upload(t, provider, tester.UploadInput{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
})
}
@@ -1,3 +1,5 @@
//go:build tester
package oraclecloudcertificatesmgmt_test
import (
@@ -5,12 +7,12 @@ import (
"github.com/stretchr/testify/require"
tester "github.com/certimate-go/certimate/pkg/core/certmgr/providers-tester"
impl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/oraclecloud-certificatesmgmt"
it "github.com/certimate-go/certimate/pkg/core/certmgr/testing"
)
var (
fp = it.Args("ORACLECLOUDCERTIFICATESMGMT_")
fp = tester.InitArgs("ORACLECLOUDCERTIFICATESMGMT_")
fTestCertPath string
fTestKeyPath string
fPrivateKey string
@@ -35,7 +37,7 @@ func init() {
/*
Shell command to run this test:
go test -v ./oraclecloud_certificatesmgmt_test.go -args \
go test -tags=tester -v ./oraclecloud_certificatesmgmt_test.go -args \
--ORACLECLOUDCERTIFICATESMGMT_TESTCERTPATH="/path/to/your-test-cert.pem" \
--ORACLECLOUDCERTIFICATESMGMT_TESTKEYPATH="/path/to/your-test-key.pem" \
--ORACLECLOUDCERTIFICATESMGMT_PRIVATEKEY="-----BEGIN RSA PRIVATE KEY-----\n...\n-----END RSA PRIVATE KEY-----" \
@@ -60,6 +62,6 @@ func TestProvider(t *testing.T) {
})
require.NoError(t, err)
it.TestUpload(t, provider, it.TestUploadArgs{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
tester.Upload(t, provider, tester.UploadInput{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
})
}
@@ -1,3 +1,5 @@
//go:build tester
package qingcloudlb_test
import (
@@ -5,12 +7,12 @@ import (
"github.com/stretchr/testify/require"
tester "github.com/certimate-go/certimate/pkg/core/certmgr/providers-tester"
impl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/qingcloud-lb"
it "github.com/certimate-go/certimate/pkg/core/certmgr/testing"
)
var (
fp = it.Args("QINGCLOUDLB_")
fp = tester.InitArgs("QINGCLOUDLB_")
fTestCertPath string
fTestKeyPath string
fAccessKeyId string
@@ -29,7 +31,7 @@ func init() {
/*
Shell command to run this test:
go test -v ./qingcloud_lb_test.go -args \
go test -tags=tester -v ./qingcloud_lb_test.go -args \
--QINGCLOUDLB_TESTCERTPATH="/path/to/your-test-cert.pem" \
--QINGCLOUDLB_TESTKEYPATH="/path/to/your-test-key.pem" \
--QINGCLOUDLB_ACCESSKEYID="your-access-key-id" \
@@ -47,6 +49,6 @@ func TestProvider(t *testing.T) {
})
require.NoError(t, err)
it.TestUpload(t, provider, it.TestUploadArgs{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
tester.Upload(t, provider, tester.UploadInput{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
})
}
@@ -0,0 +1,50 @@
//go:build tester
package qiniusslcert_test
import (
"testing"
"github.com/stretchr/testify/require"
tester "github.com/certimate-go/certimate/pkg/core/certmgr/providers-tester"
impl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/qiniu-sslcert"
)
var (
fp = tester.InitArgs("QINIUSSLCERT_")
fTestCertPath string
fTestKeyPath string
fAccessKey string
fSecretKey string
)
func init() {
fp.DefineString(&fTestCertPath, "TESTCERTPATH")
fp.DefineString(&fTestKeyPath, "TESTKEYPATH")
fp.DefineString(&fAccessKey, "ACCESSKEY")
fp.DefineString(&fSecretKey, "SECRETKEY")
}
/*
Shell command to run this test:
go test -tags=tester -v ./qiniu_sslcert_test.go -args \
--QINIUSSLCERT_TESTCERTPATH="/path/to/your-test-cert.pem" \
--QINIUSSLCERT_TESTKEYPATH="/path/to/your-test-key.pem" \
--QINIUSSLCERT_ACCESSKEY="your-access-key" \
--QINIUSSLCERT_SECRETKEY="your-secret-key"
*/
func TestProvider(t *testing.T) {
fp.Parse()
t.Run("Upload", func(t *testing.T) {
provider, err := impl.NewCertmgr(&impl.CertmgrConfig{
AccessKey: fAccessKey,
SecretKey: fSecretKey,
})
require.NoError(t, err)
tester.Upload(t, provider, tester.UploadInput{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
})
}
@@ -1,3 +1,5 @@
//go:build tester
package rainyunsslcenter_test
import (
@@ -5,12 +7,12 @@ import (
"github.com/stretchr/testify/require"
tester "github.com/certimate-go/certimate/pkg/core/certmgr/providers-tester"
impl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/rainyun-sslcenter"
it "github.com/certimate-go/certimate/pkg/core/certmgr/testing"
)
var (
fp = it.Args("RAINYUNSSLCENTER_")
fp = tester.InitArgs("RAINYUNSSLCENTER_")
fTestCertPath string
fTestKeyPath string
fApiKey string
@@ -25,7 +27,7 @@ func init() {
/*
Shell command to run this test:
go test -v ./rainyun_sslcenter_test.go -args \
go test -tags=tester -v ./rainyun_sslcenter_test.go -args \
--RAINYUNSSLCENTER_TESTCERTPATH="/path/to/your-test-cert.pem" \
--RAINYUNSSLCENTER_TESTKEYPATH="/path/to/your-test-key.pem" \
--RAINYUNSSLCENTER_APIKEY="your-api-key"
@@ -39,6 +41,6 @@ func TestProvider(t *testing.T) {
})
require.NoError(t, err)
it.TestUpload(t, provider, it.TestUploadArgs{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
tester.Upload(t, provider, tester.UploadInput{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
})
}
@@ -1,3 +1,5 @@
//go:build tester
package tencentcloudgaap_test
import (
@@ -5,12 +7,12 @@ import (
"github.com/stretchr/testify/require"
tester "github.com/certimate-go/certimate/pkg/core/certmgr/providers-tester"
impl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/tencentcloud-gaap"
it "github.com/certimate-go/certimate/pkg/core/certmgr/testing"
)
var (
fp = it.Args("TENCENTCLOUDGAAP_")
fp = tester.InitArgs("TENCENTCLOUDGAAP_")
fTestCertPath string
fTestKeyPath string
fSecretId string
@@ -27,7 +29,7 @@ func init() {
/*
Shell command to run this test:
go test -v ./tencentcloud_gaap_test.go -args \
go test -tags=tester -v ./tencentcloud_gaap_test.go -args \
--TENCENTCLOUDGAAP_TESTCERTPATH="/path/to/your-test-cert.pem" \
--TENCENTCLOUDGAAP_TESTKEYPATH="/path/to/your-test-key.pem" \
--TENCENTCLOUDGAAP_SECRETID="your-secret-id" \
@@ -43,6 +45,6 @@ func TestProvider(t *testing.T) {
})
require.NoError(t, err)
it.TestUpload(t, provider, it.TestUploadArgs{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
tester.Upload(t, provider, tester.UploadInput{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
})
}
@@ -1,3 +1,5 @@
//go:build tester
package tencentcloudssl_test
import (
@@ -5,12 +7,12 @@ import (
"github.com/stretchr/testify/require"
tester "github.com/certimate-go/certimate/pkg/core/certmgr/providers-tester"
impl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/tencentcloud-ssl"
it "github.com/certimate-go/certimate/pkg/core/certmgr/testing"
)
var (
fp = it.Args("TENCENTCLOUDSSL_")
fp = tester.InitArgs("TENCENTCLOUDSSL_")
fTestCertPath string
fTestKeyPath string
fSecretId string
@@ -27,7 +29,7 @@ func init() {
/*
Shell command to run this test:
go test -v ./tencentcloud_ssl_test.go -args \
go test -tags=tester -v ./tencentcloud_ssl_test.go -args \
--TENCENTCLOUDSSL_TESTCERTPATH="/path/to/your-test-cert.pem" \
--TENCENTCLOUDSSL_TESTKEYPATH="/path/to/your-test-key.pem" \
--TENCENTCLOUDSSL_SECRETID="your-secret-id" \
@@ -43,6 +45,6 @@ func TestProvider(t *testing.T) {
})
require.NoError(t, err)
it.TestUpload(t, provider, it.TestUploadArgs{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
tester.Upload(t, provider, tester.UploadInput{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
})
}
@@ -1,3 +1,5 @@
//go:build tester
package tencentcloudtse_test
import (
@@ -5,12 +7,12 @@ import (
"github.com/stretchr/testify/require"
tester "github.com/certimate-go/certimate/pkg/core/certmgr/providers-tester"
impl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/tencentcloud-tse"
it "github.com/certimate-go/certimate/pkg/core/certmgr/testing"
)
var (
fp = it.Args("TENCENTCLOUDTSE_")
fp = tester.InitArgs("TENCENTCLOUDTSE_")
fTestCertPath string
fTestKeyPath string
fSecretId string
@@ -33,7 +35,7 @@ func init() {
/*
Shell command to run this test:
go test -v ./tencentcloud_tse_test.go -args \
go test -tags=tester -v ./tencentcloud_tse_test.go -args \
--TENCENTCLOUDTSE_TESTCERTPATH="/path/to/your-test-cert.pem" \
--TENCENTCLOUDTSE_TESTKEYPATH="/path/to/your-test-key.pem" \
--TENCENTCLOUDTSE_SECRETID="your-secret-id" \
@@ -55,6 +57,6 @@ func TestProvider(t *testing.T) {
})
require.NoError(t, err)
it.TestUpload(t, provider, it.TestUploadArgs{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
tester.Upload(t, provider, tester.UploadInput{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
})
}
@@ -1,4 +1,6 @@
package testing
//go:build tester
package tester
import (
"context"
@@ -13,33 +15,33 @@ import (
"github.com/certimate-go/certimate/pkg/core/certmgr"
)
type TestUploadArgs struct {
type UploadInput struct {
CertPath string
KeyPath string
}
func TestUpload(t *testing.T, testProvider certmgr.Provider, testArgs TestUploadArgs) {
if _, err := os.Stat(testArgs.CertPath); os.IsNotExist(err) {
func Upload(t *testing.T, provider certmgr.Provider, input UploadInput) {
if _, err := os.Stat(input.CertPath); os.IsNotExist(err) {
t.Errorf("err: test cert file not exist")
return
}
if _, err := os.Stat(testArgs.KeyPath); os.IsNotExist(err) {
if _, err := os.Stat(input.KeyPath); os.IsNotExist(err) {
t.Errorf("err: test privkey file not exist")
return
}
ctx := context.Background()
certData, _ := os.ReadFile(testArgs.CertPath)
privkeyData, _ := os.ReadFile(testArgs.KeyPath)
certData, _ := os.ReadFile(input.CertPath)
privkeyData, _ := os.ReadFile(input.KeyPath)
assert.NotNil(t, certData)
assert.NotNil(t, privkeyData)
logger := slog.Default()
logger.Enabled(ctx, slog.LevelDebug)
testProvider.SetLogger(logger)
provider.SetLogger(logger)
res, err := testProvider.Upload(ctx, string(certData), string(privkeyData))
res, err := provider.Upload(ctx, string(certData), string(privkeyData))
require.NoError(t, err)
require.NotNil(t, res)
@@ -0,0 +1,11 @@
//go:build tester
package tester
import (
"github.com/certimate-go/certimate/pkg/core/internal/testing"
)
func InitArgs(prefix string) testing.ArgsParser {
return testing.InitArgs(prefix)
}
@@ -1,3 +1,5 @@
//go:build tester
package ucloudulb_test
import (
@@ -5,12 +7,12 @@ import (
"github.com/stretchr/testify/require"
tester "github.com/certimate-go/certimate/pkg/core/certmgr/providers-tester"
impl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/ucloud-ulb"
it "github.com/certimate-go/certimate/pkg/core/certmgr/testing"
)
var (
fp = it.Args("UCLOUDULB_")
fp = tester.InitArgs("UCLOUDULB_")
fTestCertPath string
fTestKeyPath string
fPrivateKey string
@@ -29,7 +31,7 @@ func init() {
/*
Shell command to run this test:
go test -v ./ucloud_ulb_test.go -args \
go test -tags=tester -v ./ucloud_ulb_test.go -args \
--UCLOUDULB_TESTCERTPATH="/path/to/your-test-cert.pem" \
--UCLOUDULB_TESTKEYPATH="/path/to/your-test-key.pem" \
--UCLOUDULB_PRIVATEKEY="your-private-key" \
@@ -47,6 +49,6 @@ func TestProvider(t *testing.T) {
})
require.NoError(t, err)
it.TestUpload(t, provider, it.TestUploadArgs{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
tester.Upload(t, provider, tester.UploadInput{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
})
}
@@ -1,3 +1,5 @@
//go:build tester
package ucloudulb_test
import (
@@ -5,12 +7,12 @@ import (
"github.com/stretchr/testify/require"
tester "github.com/certimate-go/certimate/pkg/core/certmgr/providers-tester"
impl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/ucloud-upathx"
it "github.com/certimate-go/certimate/pkg/core/certmgr/testing"
)
var (
fp = it.Args("UCLOUDUPATHX_")
fp = tester.InitArgs("UCLOUDUPATHX_")
fTestCertPath string
fTestKeyPath string
fPrivateKey string
@@ -27,7 +29,7 @@ func init() {
/*
Shell command to run this test:
go test -v ./ucloud_upathx_test.go -args \
go test -tags=tester -v ./ucloud_upathx_test.go -args \
--UCLOUDUPATHX_TESTCERTPATH="/path/to/your-test-cert.pem" \
--UCLOUDUPATHX_TESTKEYPATH="/path/to/your-test-key.pem" \
--UCLOUDUPATHX_PRIVATEKEY="your-private-key" \
@@ -43,6 +45,6 @@ func TestProvider(t *testing.T) {
})
require.NoError(t, err)
it.TestUpload(t, provider, it.TestUploadArgs{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
tester.Upload(t, provider, tester.UploadInput{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
})
}
@@ -1,3 +1,5 @@
//go:build tester
package ucloudussl_test
import (
@@ -5,12 +7,12 @@ import (
"github.com/stretchr/testify/require"
tester "github.com/certimate-go/certimate/pkg/core/certmgr/providers-tester"
impl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/ucloud-ussl"
it "github.com/certimate-go/certimate/pkg/core/certmgr/testing"
)
var (
fp = it.Args("UCLOUDUSSL_")
fp = tester.InitArgs("UCLOUDUSSL_")
fTestCertPath string
fTestKeyPath string
fPrivateKey string
@@ -27,7 +29,7 @@ func init() {
/*
Shell command to run this test:
go test -v ./ucloud_ussl_test.go -args \
go test -tags=tester -v ./ucloud_ussl_test.go -args \
--UCLOUDUSSL_TESTCERTPATH="/path/to/your-test-cert.pem" \
--UCLOUDUSSL_TESTKEYPATH="/path/to/your-test-key.pem" \
--UCLOUDUSSL_PRIVATEKEY="your-private-key" \
@@ -43,6 +45,6 @@ func TestProvider(t *testing.T) {
})
require.NoError(t, err)
it.TestUpload(t, provider, it.TestUploadArgs{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
tester.Upload(t, provider, tester.UploadInput{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
})
}
@@ -1,3 +1,5 @@
//go:build tester
package upyunssl_test
import (
@@ -5,12 +7,12 @@ import (
"github.com/stretchr/testify/require"
tester "github.com/certimate-go/certimate/pkg/core/certmgr/providers-tester"
impl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/upyun-ssl"
it "github.com/certimate-go/certimate/pkg/core/certmgr/testing"
)
var (
fp = it.Args("UPYUNSSL_")
fp = tester.InitArgs("UPYUNSSL_")
fTestCertPath string
fTestKeyPath string
fUsername string
@@ -27,7 +29,7 @@ func init() {
/*
Shell command to run this test:
go test -v ./upyun_ssl_test.go -args \
go test -tags=tester -v ./upyun_ssl_test.go -args \
--UPYUNSSL_TESTCERTPATH="/path/to/your-test-cert.pem" \
--UPYUNSSL_TESTKEYPATH="/path/to/your-test-key.pem" \
--UPYUNSSL_USERNAME="your-username" \
@@ -43,6 +45,6 @@ func TestProvider(t *testing.T) {
})
require.NoError(t, err)
it.TestUpload(t, provider, it.TestUploadArgs{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
tester.Upload(t, provider, tester.UploadInput{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
})
}
@@ -1,3 +1,5 @@
//go:build tester
package volcenginecdn_test
import (
@@ -5,12 +7,12 @@ import (
"github.com/stretchr/testify/require"
tester "github.com/certimate-go/certimate/pkg/core/certmgr/providers-tester"
impl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/volcengine-cdn"
it "github.com/certimate-go/certimate/pkg/core/certmgr/testing"
)
var (
fp = it.Args("VOLCENGINECDN_")
fp = tester.InitArgs("VOLCENGINECDN_")
fTestCertPath string
fTestKeyPath string
fAccessKeyId string
@@ -27,7 +29,7 @@ func init() {
/*
Shell command to run this test:
go test -v ./volcengine_cdn_test.go -args \
go test -tags=tester -v ./volcengine_cdn_test.go -args \
--VOLCENGINECDN_TESTCERTPATH="/path/to/your-test-cert.pem" \
--VOLCENGINECDN_TESTKEYPATH="/path/to/your-test-key.pem" \
--VOLCENGINECDN_ACCESSKEYID="your-access-key-id" \
@@ -43,6 +45,6 @@ func TestProvider(t *testing.T) {
})
require.NoError(t, err)
it.TestUpload(t, provider, it.TestUploadArgs{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
tester.Upload(t, provider, tester.UploadInput{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
})
}
@@ -1,3 +1,5 @@
//go:build tester
package volcenginecertcenter_test
import (
@@ -5,12 +7,12 @@ import (
"github.com/stretchr/testify/require"
tester "github.com/certimate-go/certimate/pkg/core/certmgr/providers-tester"
impl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/volcengine-certcenter"
it "github.com/certimate-go/certimate/pkg/core/certmgr/testing"
)
var (
fp = it.Args("VOLCENGINECERTCENTER_")
fp = tester.InitArgs("VOLCENGINECERTCENTER_")
fTestCertPath string
fTestKeyPath string
fAccessKeyId string
@@ -27,7 +29,7 @@ func init() {
/*
Shell command to run this test:
go test -v ./volcengine_certcenter_test.go -args \
go test -tags=tester -v ./volcengine_certcenter_test.go -args \
--VOLCENGINECERTCENTER_TESTCERTPATH="/path/to/your-test-cert.pem" \
--VOLCENGINECERTCENTER_TESTKEYPATH="/path/to/your-test-key.pem" \
--VOLCENGINECERTCENTER_ACCESSKEYID="your-access-key-id" \
@@ -43,6 +45,6 @@ func TestProvider(t *testing.T) {
})
require.NoError(t, err)
it.TestUpload(t, provider, it.TestUploadArgs{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
tester.Upload(t, provider, tester.UploadInput{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
})
}
@@ -1,3 +1,5 @@
//go:build tester
package volcenginelive_test
import (
@@ -5,12 +7,12 @@ import (
"github.com/stretchr/testify/require"
tester "github.com/certimate-go/certimate/pkg/core/certmgr/providers-tester"
impl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/volcengine-live"
it "github.com/certimate-go/certimate/pkg/core/certmgr/testing"
)
var (
fp = it.Args("VOLCENGINELIVE_")
fp = tester.InitArgs("VOLCENGINELIVE_")
fTestCertPath string
fTestKeyPath string
fAccessKeyId string
@@ -27,7 +29,7 @@ func init() {
/*
Shell command to run this test:
go test -v ./volcengine_live_test.go -args \
go test -tags=tester -v ./volcengine_live_test.go -args \
--VOLCENGINELIVE_TESTCERTPATH="/path/to/your-test-cert.pem" \
--VOLCENGINELIVE_TESTKEYPATH="/path/to/your-test-key.pem" \
--VOLCENGINELIVE_ACCESSKEYID="your-access-key-id" \
@@ -43,6 +45,6 @@ func TestProvider(t *testing.T) {
})
require.NoError(t, err)
it.TestUpload(t, provider, it.TestUploadArgs{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
tester.Upload(t, provider, tester.UploadInput{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
})
}
@@ -1,3 +1,5 @@
//go:build tester
package wangsucertificate_test
import (
@@ -5,12 +7,12 @@ import (
"github.com/stretchr/testify/require"
tester "github.com/certimate-go/certimate/pkg/core/certmgr/providers-tester"
impl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/wangsu-certificate"
it "github.com/certimate-go/certimate/pkg/core/certmgr/testing"
)
var (
fp = it.Args("WANGSUCERTIFICATE_")
fp = tester.InitArgs("WANGSUCERTIFICATE_")
fTestCertPath string
fTestKeyPath string
fAccessKeyId string
@@ -27,7 +29,7 @@ func init() {
/*
Shell command to run this test:
go test -v ./wangsu_certificate_test.go -args \
go test -tags=tester -v ./wangsu_certificate_test.go -args \
--WANGSUCERTIFICATE_TESTCERTPATH="/path/to/your-test-cert.pem" \
--WANGSUCERTIFICATE_TESTKEYPATH="/path/to/your-test-key.pem" \
--WANGSUCERTIFICATE_ACCESSKEYID="your-access-key-id" \
@@ -43,6 +45,6 @@ func TestProvider(t *testing.T) {
})
require.NoError(t, err)
it.TestUpload(t, provider, it.TestUploadArgs{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
tester.Upload(t, provider, tester.UploadInput{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
})
}
@@ -1,3 +1,5 @@
//go:build tester
package yandexcloudcertificatemanager_test
import (
@@ -6,12 +8,12 @@ import (
"github.com/stretchr/testify/require"
tester "github.com/certimate-go/certimate/pkg/core/certmgr/providers-tester"
impl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/yandexcloud-certificatemanager"
it "github.com/certimate-go/certimate/pkg/core/certmgr/testing"
)
var (
fp = it.Args("YANDEXCLOUDCERTIFICATEMANAGER_")
fp = tester.InitArgs("YANDEXCLOUDCERTIFICATEMANAGER_")
fTestCertPath string
fTestKeyPath string
fFolderId string
@@ -28,7 +30,7 @@ func init() {
/*
Shell command to run this test:
go test -v ./yandexcloud_certificatemanager_test.go -args \
go test -tags=tester -v ./yandexcloud_certificatemanager_test.go -args \
--YANDEXCLOUDCERTIFICATEMANAGER_TESTCERTPATH="/path/to/your-test-cert.pem" \
--YANDEXCLOUDCERTIFICATEMANAGER_TESTKEYPATH="/path/to/your-test-key.pem" \
--YANDEXCLOUDCERTIFICATEMANAGER_FOLDERID="your-folder-id" \
@@ -49,6 +51,6 @@ func TestProvider(t *testing.T) {
})
require.NoError(t, err)
it.TestUpload(t, provider, it.TestUploadArgs{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
tester.Upload(t, provider, tester.UploadInput{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
})
}
@@ -1,3 +1,5 @@
//go:build tester
package zenlayercdn_test
import (
@@ -5,12 +7,12 @@ import (
"github.com/stretchr/testify/require"
tester "github.com/certimate-go/certimate/pkg/core/certmgr/providers-tester"
impl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/zenlayer-cdn"
it "github.com/certimate-go/certimate/pkg/core/certmgr/testing"
)
var (
fp = it.Args("ZENLAYERCDN_")
fp = tester.InitArgs("ZENLAYERCDN_")
fTestCertPath string
fTestKeyPath string
fAccessKeyId string
@@ -27,7 +29,7 @@ func init() {
/*
Shell command to run this test:
go test -v ./zenlayer_cdn_test.go -args \
go test -tags=tester -v ./zenlayer_cdn_test.go -args \
--ZENLAYERCDN_TESTCERTPATH="/path/to/your-test-cert.pem" \
--ZENLAYERCDN_TESTKEYPATH="/path/to/your-test-key.pem" \
--ZENLAYERCDN_ACCESSKEYID="your-access-key-id" \
@@ -43,6 +45,6 @@ func TestProvider(t *testing.T) {
})
require.NoError(t, err)
it.TestUpload(t, provider, it.TestUploadArgs{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
tester.Upload(t, provider, tester.UploadInput{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
})
}
@@ -1,3 +1,5 @@
//go:build tester
package zenlayerga_test
import (
@@ -5,12 +7,12 @@ import (
"github.com/stretchr/testify/require"
tester "github.com/certimate-go/certimate/pkg/core/certmgr/providers-tester"
impl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/zenlayer-ga"
it "github.com/certimate-go/certimate/pkg/core/certmgr/testing"
)
var (
fp = it.Args("ZENLAYERGA_")
fp = tester.InitArgs("ZENLAYERGA_")
fTestCertPath string
fTestKeyPath string
fAccessKeyId string
@@ -27,7 +29,7 @@ func init() {
/*
Shell command to run this test:
go test -v ./zenlayer_ga_test.go -args \
go test -tags=tester -v ./zenlayer_ga_test.go -args \
--ZENLAYERGA_TESTCERTPATH="/path/to/your-test-cert.pem" \
--ZENLAYERGA_TESTKEYPATH="/path/to/your-test-key.pem" \
--ZENLAYERGA_ACCESSKEYID="your-access-key-id" \
@@ -43,6 +45,6 @@ func TestProvider(t *testing.T) {
})
require.NoError(t, err)
it.TestUpload(t, provider, it.TestUploadArgs{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
tester.Upload(t, provider, tester.UploadInput{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
})
}

Some files were not shown because too many files have changed in this diff Show More