Skip to content

Commit 08a66e8

Browse files
committed
chore: add test on preprod
1 parent 93da4f6 commit 08a66e8

File tree

3 files changed

+76
-8
lines changed

3 files changed

+76
-8
lines changed

.github/workflows/test.yaml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,57 @@ jobs:
5858
./tests/out/coverage.txt
5959
./tests/out/coverage.html
6060
retention-days: 5
61+
62+
test-preprod:
63+
runs-on: ubuntu-latest
64+
steps:
65+
- uses: actions/checkout@v4
66+
- uses: ./.github/actions/setup-build-env
67+
- name: Build CLI
68+
run: go build -cover ./cmd/okms
69+
- name: Setup Venom
70+
run: |
71+
wget https://github.com/ovh/venom/releases/download/v1.2.0/venom.linux-amd64
72+
mv venom.linux-amd64 venom
73+
chmod +x venom
74+
- name: Setup okms config file
75+
run: |
76+
echo "${{secrets.KMS_PREPROD_CERTIFICATE}}" > tls.crt
77+
echo "${{secrets.KMS_PREPROD_PRIVATEKEY}}" > tls.key
78+
cat > okms.yaml <<-EOF
79+
version: 1
80+
profile: default
81+
profiles:
82+
default: # default profile
83+
http:
84+
endpoint: ${{secrets.KMS_PREPROD_ENDPOINT}}
85+
auth:
86+
type: mtls
87+
cert: $(pwd)/tls.crt
88+
key: $(pwd)/tls.key
89+
kmip:
90+
endpoint: ${{secrets.KMS_PREPROD_KMIP_ENDPOINT}}
91+
auth:
92+
type: mtls
93+
cert: $(pwd)/tls.crt
94+
key: $(pwd)/tls.key
95+
EOF
96+
- name: Test connectivity to KMS dmain
97+
run: ./okms keys ls -d -c okms.yaml
98+
- name: Execute tests
99+
run: make -C tests
100+
- uses: actions/upload-artifact@v4
101+
with:
102+
name: test_results
103+
path: |
104+
./tests/out/test_results.html
105+
./tests/out/venom.log
106+
retention-days: 5
107+
if: always()
108+
- uses: actions/upload-artifact@v4
109+
with:
110+
name: coverage
111+
path: |
112+
./tests/out/coverage.txt
113+
./tests/out/coverage.html
114+
retention-days: 5

cmd/okms/secretsV2/config.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,24 +51,24 @@ func secretGetConfigCommand() *cobra.Command {
5151

5252
func secretUpdateConfigCommand() *cobra.Command {
5353
var (
54-
casRequired bool
55-
maxVersions uint32
56-
deleteVersionAfter string
54+
casRequired bool
55+
maxVersions uint32
56+
deactivateVersionAfter string
5757
)
5858

5959
cmd := &cobra.Command{
6060
Use: "update",
6161
Short: "Update secrets configuration",
62-
Args: cobra.MinimumNArgs(1),
62+
Args: cobra.MinimumNArgs(0),
6363
Run: func(cmd *cobra.Command, args []string) {
6464
var c *bool
6565
if cmd.Flag("cas-required").Changed {
6666
c = &casRequired
6767
}
6868

6969
var d *string
70-
if cmd.Flag("delete-after").Changed {
71-
d = &deleteVersionAfter
70+
if cmd.Flag("deactivate-after").Changed {
71+
d = &deactivateVersionAfter
7272
}
7373

7474
var m *uint32
@@ -88,6 +88,6 @@ func secretUpdateConfigCommand() *cobra.Command {
8888

8989
cmd.Flags().BoolVar(&casRequired, "cas-required", false, "If true all keys will require the cas parameter to be set on all write requests.")
9090
cmd.Flags().Uint32Var(&maxVersions, "max-versions", 0, "The number of versions to keep per key. This value applies to all keys, but a key's metadata setting can overwrite this value. Once a key has more than the configured allowed versions, the oldest version will be permanently deleted. ")
91-
cmd.Flags().StringVar(&deleteVersionAfter, "delete-after", "0s", "If set, specifies the length of time before a version is deleted.\nDate format, see: https://developer.hashicorp.com/vault/docs/concepts/duration-format")
91+
cmd.Flags().StringVar(&deactivateVersionAfter, "deactivate-after", "0s", "If set, specifies the length of time before a version is deleted.\nDate format, see: https://developer.hashicorp.com/vault/docs/concepts/duration-format")
9292
return cmd
9393
}

tests/secrets.yaml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,4 +257,18 @@ testcases:
257257
assertions:
258258
- result.code ShouldEqual 0
259259

260-
260+
- name: Secret config
261+
steps:
262+
- name: Update config
263+
type: okms-cmd
264+
args: secret config update --deactivate-after="1d" --max-versions=24
265+
assertions:
266+
- result.code ShouldEqual 0
267+
- name: Read config
268+
type: okms-cmd
269+
args: secret config get
270+
assertions:
271+
- result.code ShouldEqual 0
272+
- result.systemoutjson.deactivate-version-after ShouldEqual "1d"
273+
- result.systemoutjson.max-version ShouldEqual "24"
274+

0 commit comments

Comments
 (0)