Skip to content

Commit 47f2c42

Browse files
committed
MEDIUM: Add acme section support
1 parent 3f8371e commit 47f2c42

31 files changed

+4584
-3
lines changed

configure_data_plane.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -883,6 +883,13 @@ func configureAPI(api *operations.DataPlaneAPI) http.Handler { //nolint:cyclop,m
883883
api.SslRuntimeAddCrtListEntryHandler = &handlers.AddCrtListEntryHandlerImpl{Client: client}
884884
api.SslRuntimeDeleteCrtListEntryHandler = &handlers.DeleteCrtListEntryHandlerImpl{Client: client}
885885

886+
// ACME providers
887+
api.AcmeGetAcmeProvidersHandler = &handlers.GetAcmeProvidersHandlerImpl{Client: client}
888+
api.AcmeGetAcmeProviderHandler = &handlers.GetAcmeProviderHandlerImpl{Client: client}
889+
api.AcmeCreateAcmeProviderHandler = &handlers.CreateAcmeProviderHandlerImpl{Client: client, ReloadAgent: ra}
890+
api.AcmeEditAcmeProviderHandler = &handlers.EditAcmeProviderHandler{Client: client, ReloadAgent: ra}
891+
api.AcmeDeleteAcmeProviderHandler = &handlers.DeleteAcmeProviderHandlerImpl{Client: client, ReloadAgent: ra}
892+
886893
// setup info handler
887894
api.InformationGetInfoHandler = &handlers.GetInfoHandlerImpl{SystemInfo: haproxyOptions.ShowSystemInfo, BuildTime: BuildTime, Version: Version}
888895

e2e/tests/acme/data/edit_acme.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "letsencrypt",
3+
"contact": "[email protected]",
4+
"directory": "https://acme-v02.api.letsencrypt.org/directory",
5+
"keytype": "RSA",
6+
"bits": 4096
7+
}

e2e/tests/acme/data/haproxy.cfg

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# _version=42
2+
3+
global
4+
log 127.0.0.1 local2
5+
chroot /var/lib/haproxy
6+
pidfile /var/run/haproxy.pid
7+
maxconn 4000
8+
user haproxy
9+
group haproxy
10+
stats socket /var/lib/haproxy/stats level admin
11+
expose-experimental-directives
12+
13+
defaults mydefaults
14+
mode http
15+
log global
16+
option httplog
17+
option dontlognull
18+
option http-server-close
19+
option forwardfor except 127.0.0.0/8
20+
option redispatch
21+
retries 3
22+
timeout http-request 10s
23+
timeout queue 1m
24+
timeout connect 10s
25+
timeout client 1m
26+
timeout server 1m
27+
timeout http-keep-alive 10s
28+
timeout check 10s
29+
maxconn 3000

e2e/tests/acme/data/new_acme.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "letsencrypt",
3+
"contact": "[email protected]",
4+
"directory": "https://acme-staging-v02.api.letsencrypt.org/directory"
5+
}

e2e/tests/acme/tests.bats

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/usr/bin/env bats
2+
#
3+
# Copyright 2025 HAProxy Technologies
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http:#www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
load '../../libs/dataplaneapi'
19+
load '../../libs/debug'
20+
load '../../libs/get_json_path'
21+
load '../../libs/haproxy_config_setup'
22+
load '../../libs/haproxy_version'
23+
load '../../libs/resource_client'
24+
load '../../libs/version'
25+
26+
_ACME_PATH="/services/haproxy/configuration/acme"
27+
_ACME_NAME="letsencrypt"
28+
29+
@test "acme: all tests (>=3.2)" {
30+
haproxy_version_ge "3.2" || skip
31+
32+
resource_post "$_ACME_PATH" "data/new_acme.json" "force_reload=true"
33+
assert_equal "$SC" "201"
34+
35+
resource_get "$_ACME_PATH/$_ACME_NAME"
36+
assert_equal "$SC" "200"
37+
assert_equal "$(get_json_path "$BODY" .name)" "$_ACME_NAME"
38+
assert_equal "$(get_json_path "$BODY" .contact)" "[email protected]"
39+
assert_equal "$(get_json_path "$BODY" .directory)" "https://acme-staging-v02.api.letsencrypt.org/directory"
40+
41+
resource_put "$_ACME_PATH/$_ACME_NAME" "data/edit_acme.json" "force_reload=true"
42+
assert_equal "$SC" "200"
43+
resource_get "$_ACME_PATH/$_ACME_NAME"
44+
assert_equal "$(get_json_path "$BODY" .directory)" "https://acme-v02.api.letsencrypt.org/directory"
45+
assert_equal "$(get_json_path "$BODY" .keytype)" "RSA"
46+
assert_equal "$(get_json_path "$BODY" .bits)" 4096
47+
48+
resource_get "$_ACME_PATH"
49+
assert_equal "$SC" "200"
50+
assert_equal "$(get_json_path "$BODY" '.|length')" 1
51+
assert_equal "$(get_json_path "$BODY" .[0].name)" "$_ACME_NAME"
52+
53+
# back to the original
54+
resource_put "$_ACME_PATH/$_ACME_NAME" "data/new_acme.json" "force_reload=true"
55+
assert_equal "$SC" "200"
56+
resource_get "$_ACME_PATH/$_ACME_NAME"
57+
assert_equal "$(get_json_path "$BODY" .directory)" "https://acme-staging-v02.api.letsencrypt.org/directory"
58+
assert_equal "$(get_json_path "$BODY" .keytype)" null
59+
assert_equal "$(get_json_path "$BODY" .bits)" null
60+
61+
resource_delete "$_ACME_PATH/$_ACME_NAME" "force_reload=true"
62+
assert_equal "$SC" "204"
63+
resource_get "$_ACME_PATH/$_ACME_NAME"
64+
assert_equal "$SC" "404"
65+
}

0 commit comments

Comments
 (0)