You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by ma...@apache.org on 2021/05/06 14:53:48 UTC
[trafficcontrol] branch master updated: Adding TO Client API tests
for LetsEncrypt (#5786)
This is an automated email from the ASF dual-hosted git repository.
mattjackson pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
The following commit(s) were added to refs/heads/master by this push:
new 80a902b Adding TO Client API tests for LetsEncrypt (#5786)
80a902b is described below
commit 80a902bbaf5e29679b717ee50277ece56506f5a8
Author: dmohan001c <de...@comcast.com>
AuthorDate: Thu May 6 20:23:31 2021 +0530
Adding TO Client API tests for LetsEncrypt (#5786)
* added test case for CacheGroup Pagination functionalites
* added test for letsencrypt
* formatted the code using go fmt
* added return value alert in the function call
* formatted using go fmt, fixed return type missing error
* rename file from letencrypt to acme
---
traffic_ops/testing/api/v4/acme_test.go | 35 +++++++++++++++++++++++++++++++++
traffic_ops/v4-client/acme.go | 33 +++++++++++++++++++++++++++++++
2 files changed, 68 insertions(+)
diff --git a/traffic_ops/testing/api/v4/acme_test.go b/traffic_ops/testing/api/v4/acme_test.go
new file mode 100644
index 0000000..0db7ced
--- /dev/null
+++ b/traffic_ops/testing/api/v4/acme_test.go
@@ -0,0 +1,35 @@
+package v4
+
+/*
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+import (
+ "net/http"
+ "testing"
+)
+
+func TestAcmeAutoRenew(t *testing.T) {
+ PostTestAutoRenew(t)
+}
+
+func PostTestAutoRenew(t *testing.T) {
+ _, reqInf, err := TOSession.AutoRenew()
+ if err != nil {
+ t.Fatalf("Expected no error, but got %v", err)
+ }
+ if reqInf.StatusCode != http.StatusAccepted {
+ t.Fatalf("Expected 202 status code, got %v", reqInf.StatusCode)
+ }
+}
diff --git a/traffic_ops/v4-client/acme.go b/traffic_ops/v4-client/acme.go
new file mode 100644
index 0000000..048ed10
--- /dev/null
+++ b/traffic_ops/v4-client/acme.go
@@ -0,0 +1,33 @@
+/*
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+package client
+
+import (
+ "github.com/apache/trafficcontrol/lib/go-tc"
+ "github.com/apache/trafficcontrol/traffic_ops/toclientlib"
+)
+
+const (
+ // APIAcmeAutorenew is the API version-relative path for the /acme_autorenew API endpoint.
+ APIAcmeAutorenew = "/acme_autorenew"
+)
+
+// AcmeAutorenew renews the certificates.
+func (to *Session) AutoRenew() (*tc.Alerts, toclientlib.ReqInf, error) {
+ var alerts tc.Alerts
+ reqInf, err := to.post(APIAcmeAutorenew, nil, nil, &alerts)
+ return &alerts, reqInf, err
+}