From 2ad41f522127680c37fbaea93d0360fa989e4c40 Mon Sep 17 00:00:00 2001 From: Alexandre Garand Date: Thu, 27 Jun 2019 12:00:53 +0200 Subject: update vendor/github.com/DreamItGetIT/statuscake/ to manage ssl tests --- .../github.com/DreamItGetIT/statuscake/Gopkg.lock | 13 +- .../github.com/DreamItGetIT/statuscake/Gopkg.toml | 4 + .../DreamItGetIT/statuscake/client_test.go | 236 ++++++++++++ .../DreamItGetIT/statuscake/cmd/statuscake/main.go | 246 ++++++++++++ .../statuscake/fixtures/auth_error.json | 4 + .../statuscake/fixtures/sslCreateOk.json | 14 + .../statuscake/fixtures/sslDeleteOk.json | 4 + .../statuscake/fixtures/sslListAllOk.json | 100 +++++ .../statuscake/fixtures/sslUpdateOk.json | 4 + .../statuscake/fixtures/ssls_all_ok.json | 70 ++++ .../statuscake/fixtures/ssls_create_ok.json | 13 + .../statuscake/fixtures/ssls_update_error.json | 13 + .../statuscake/fixtures/ssls_update_ok.json | 4 + .../statuscake/fixtures/tests_all_ok.json | 23 ++ .../statuscake/fixtures/tests_delete_error.json | 5 + .../statuscake/fixtures/tests_delete_ok.json | 6 + .../statuscake/fixtures/tests_detail_ok.json | 39 ++ .../statuscake/fixtures/tests_update_error.json | 9 + .../tests_update_error_slice_of_issues.json | 5 + .../statuscake/fixtures/tests_update_ok.json | 6 + vendor/github.com/DreamItGetIT/statuscake/ssl.go | 273 +++++++++++++ .../github.com/DreamItGetIT/statuscake/ssl_test.go | 343 +++++++++++++++++ .../DreamItGetIT/statuscake/tests_test.go | 422 +++++++++++++++++++++ 23 files changed, 1854 insertions(+), 2 deletions(-) create mode 100644 vendor/github.com/DreamItGetIT/statuscake/client_test.go create mode 100644 vendor/github.com/DreamItGetIT/statuscake/cmd/statuscake/main.go create mode 100644 vendor/github.com/DreamItGetIT/statuscake/fixtures/auth_error.json create mode 100644 vendor/github.com/DreamItGetIT/statuscake/fixtures/sslCreateOk.json create mode 100644 vendor/github.com/DreamItGetIT/statuscake/fixtures/sslDeleteOk.json create mode 100644 vendor/github.com/DreamItGetIT/statuscake/fixtures/sslListAllOk.json create mode 100644 vendor/github.com/DreamItGetIT/statuscake/fixtures/sslUpdateOk.json create mode 100644 vendor/github.com/DreamItGetIT/statuscake/fixtures/ssls_all_ok.json create mode 100644 vendor/github.com/DreamItGetIT/statuscake/fixtures/ssls_create_ok.json create mode 100644 vendor/github.com/DreamItGetIT/statuscake/fixtures/ssls_update_error.json create mode 100644 vendor/github.com/DreamItGetIT/statuscake/fixtures/ssls_update_ok.json create mode 100644 vendor/github.com/DreamItGetIT/statuscake/fixtures/tests_all_ok.json create mode 100644 vendor/github.com/DreamItGetIT/statuscake/fixtures/tests_delete_error.json create mode 100644 vendor/github.com/DreamItGetIT/statuscake/fixtures/tests_delete_ok.json create mode 100644 vendor/github.com/DreamItGetIT/statuscake/fixtures/tests_detail_ok.json create mode 100644 vendor/github.com/DreamItGetIT/statuscake/fixtures/tests_update_error.json create mode 100644 vendor/github.com/DreamItGetIT/statuscake/fixtures/tests_update_error_slice_of_issues.json create mode 100644 vendor/github.com/DreamItGetIT/statuscake/fixtures/tests_update_ok.json create mode 100644 vendor/github.com/DreamItGetIT/statuscake/ssl.go create mode 100644 vendor/github.com/DreamItGetIT/statuscake/ssl_test.go create mode 100644 vendor/github.com/DreamItGetIT/statuscake/tests_test.go diff --git a/vendor/github.com/DreamItGetIT/statuscake/Gopkg.lock b/vendor/github.com/DreamItGetIT/statuscake/Gopkg.lock index c5b189e..b433daf 100644 --- a/vendor/github.com/DreamItGetIT/statuscake/Gopkg.lock +++ b/vendor/github.com/DreamItGetIT/statuscake/Gopkg.lock @@ -17,6 +17,14 @@ revision = "8991bc29aa16c548c550c7ff78260e27b9ab7c73" version = "v1.1.1" +[[projects]] + digest = "1:a63cff6b5d8b95638bfe300385d93b2a6d9d687734b863da8e09dc834510a690" + name = "github.com/google/go-querystring" + packages = ["query"] + pruneopts = "UT" + revision = "44c6ddd0a2342c386950e880b658017258da92fc" + version = "v1.0.0" + [[projects]] digest = "1:0028cb19b2e4c3112225cd871870f2d9cf49b9b4276531f03438a88e94be86fe" name = "github.com/pmezard/go-difflib" @@ -30,7 +38,7 @@ name = "github.com/stretchr/testify" packages = [ "assert", - "require", + "require" ] pruneopts = "UT" revision = "f35b8ab0b5a2cef36673838d662e249dd9c94686" @@ -41,8 +49,9 @@ analyzer-version = 1 input-imports = [ "github.com/DreamItGetIT/statuscake", + "github.com/google/go-querystring/query", "github.com/stretchr/testify/assert", - "github.com/stretchr/testify/require", + "github.com/stretchr/testify/require" ] solver-name = "gps-cdcl" solver-version = 1 diff --git a/vendor/github.com/DreamItGetIT/statuscake/Gopkg.toml b/vendor/github.com/DreamItGetIT/statuscake/Gopkg.toml index b0c1687..e02ee65 100644 --- a/vendor/github.com/DreamItGetIT/statuscake/Gopkg.toml +++ b/vendor/github.com/DreamItGetIT/statuscake/Gopkg.toml @@ -36,3 +36,7 @@ [prune] go-tests = true unused-packages = true + +[[constraint]] + name = "github.com/google/go-querystring" + version = "1.0.0" diff --git a/vendor/github.com/DreamItGetIT/statuscake/client_test.go b/vendor/github.com/DreamItGetIT/statuscake/client_test.go new file mode 100644 index 0000000..7c40c81 --- /dev/null +++ b/vendor/github.com/DreamItGetIT/statuscake/client_test.go @@ -0,0 +1,236 @@ +package statuscake + +import ( + "bytes" + "io" + "io/ioutil" + "log" + "net/http" + "net/url" + "os" + "path/filepath" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestAuth_validate(t *testing.T) { + assert := assert.New(t) + require := require.New(t) + + auth := &Auth{} + err := auth.validate() + + require.NotNil(err) + assert.Contains(err.Error(), "Username is required") + assert.Contains(err.Error(), "Apikey is required") + + auth.Username = "foo" + err = auth.validate() + + require.NotNil(err) + assert.Equal("Apikey is required", err.Error()) + + auth.Apikey = "bar" + err = auth.validate() + assert.Nil(err) +} + +func TestClient(t *testing.T) { + require := require.New(t) + assert := assert.New(t) + + c, err := New(Auth{Username: "random-user", Apikey: "my-pass"}) + require.Nil(err) + + assert.Equal("random-user", c.username) + assert.Equal("my-pass", c.apiKey) +} + +func TestClient_newRequest(t *testing.T) { + assert := assert.New(t) + require := require.New(t) + + c, err := New(Auth{Username: "random-user", Apikey: "my-pass"}) + require.Nil(err) + + r, err := c.newRequest("GET", "/hello", nil, nil) + + require.Nil(err) + assert.Equal("GET", r.Method) + assert.Equal("https://app.statuscake.com/API/hello", r.URL.String()) + assert.Equal("random-user", r.Header.Get("Username")) + assert.Equal("my-pass", r.Header.Get("API")) +} + +func TestClient_doRequest(t *testing.T) { + assert := assert.New(t) + require := require.New(t) + + c, err := New(Auth{Username: "random-user", Apikey: "my-pass"}) + require.Nil(err) + + hc := &fakeHTTPClient{StatusCode: 200} + c.c = hc + + req, err := http.NewRequest("GET", "http://example.com/test", nil) + require.Nil(err) + + _, err = c.doRequest(req) + require.Nil(err) + + assert.Len(hc.requests, 1) + assert.Equal("http://example.com/test", hc.requests[0].URL.String()) +} + +func TestClient_doRequest_WithHTTPErrors(t *testing.T) { + assert := assert.New(t) + require := require.New(t) + + c, err := New(Auth{Username: "random-user", Apikey: "my-pass"}) + require.Nil(err) + + hc := &fakeHTTPClient{ + StatusCode: 500, + } + c.c = hc + + req, err := http.NewRequest("GET", "http://example.com/test", nil) + require.Nil(err) + + _, err = c.doRequest(req) + require.NotNil(err) + assert.IsType(&httpError{}, err) +} + +func TestClient_doRequest_HttpAuthenticationErrors(t *testing.T) { + assert := assert.New(t) + require := require.New(t) + + c, err := New(Auth{Username: "random-user", Apikey: "my-pass"}) + require.Nil(err) + + hc := &fakeHTTPClient{ + StatusCode: 200, + Fixture: "auth_error.json", + } + c.c = hc + + req, err := http.NewRequest("GET", "http://example.com/test", nil) + require.Nil(err) + + _, err = c.doRequest(req) + require.NotNil(err) + assert.IsType(&AuthenticationError{}, err) +} + +func TestClient_get(t *testing.T) { + require := require.New(t) + assert := assert.New(t) + + c, err := New(Auth{Username: "random-user", Apikey: "my-pass"}) + require.Nil(err) + + hc := &fakeHTTPClient{} + c.c = hc + + c.get("/hello", nil) + assert.Len(hc.requests, 1) + assert.Equal("GET", hc.requests[0].Method) + assert.Equal("https://app.statuscake.com/API/hello", hc.requests[0].URL.String()) +} + +func TestClient_put(t *testing.T) { + require := require.New(t) + assert := assert.New(t) + + c, err := New(Auth{Username: "random-user", Apikey: "my-pass"}) + require.Nil(err) + + hc := &fakeHTTPClient{} + c.c = hc + + v := url.Values{"foo": {"bar"}} + c.put("/hello", v) + assert.Len(hc.requests, 1) + assert.Equal("PUT", hc.requests[0].Method) + assert.Equal("https://app.statuscake.com/API/hello", hc.requests[0].URL.String()) + + b, err := ioutil.ReadAll(hc.requests[0].Body) + require.Nil(err) + assert.Equal("foo=bar", string(b)) +} + +func TestClient_delete(t *testing.T) { + require := require.New(t) + assert := assert.New(t) + + c, err := New(Auth{Username: "random-user", Apikey: "my-pass"}) + require.Nil(err) + + hc := &fakeHTTPClient{} + c.c = hc + + v := url.Values{"foo": {"bar"}} + c.delete("/hello", v) + assert.Len(hc.requests, 1) + assert.Equal("DELETE", hc.requests[0].Method) + assert.Equal("https://app.statuscake.com/API/hello?foo=bar", hc.requests[0].URL.String()) +} + +func TestClient_Tests(t *testing.T) { + require := require.New(t) + assert := assert.New(t) + + c, err := New(Auth{Username: "random-user", Apikey: "my-pass"}) + require.Nil(err) + + expected := &tests{ + client: c, + } + + assert.Equal(expected, c.Tests()) +} + +type fakeBody struct { + io.Reader +} + +func (f *fakeBody) Close() error { + return nil +} + +type fakeHTTPClient struct { + StatusCode int + Fixture string + requests []*http.Request +} + +func (c *fakeHTTPClient) Do(r *http.Request) (*http.Response, error) { + c.requests = append(c.requests, r) + var body []byte + + if c.Fixture != "" { + p := filepath.Join("fixtures", c.Fixture) + f, err := os.Open(p) + if err != nil { + log.Fatal(err) + } + defer f.Close() + + b, err := ioutil.ReadAll(f) + if err != nil { + log.Fatal(err) + } + + body = b + } + + resp := &http.Response{ + StatusCode: c.StatusCode, + Body: &fakeBody{Reader: bytes.NewReader(body)}, + } + + return resp, nil +} diff --git a/vendor/github.com/DreamItGetIT/statuscake/cmd/statuscake/main.go b/vendor/github.com/DreamItGetIT/statuscake/cmd/statuscake/main.go new file mode 100644 index 0000000..59f41a9 --- /dev/null +++ b/vendor/github.com/DreamItGetIT/statuscake/cmd/statuscake/main.go @@ -0,0 +1,246 @@ +package main + +import ( + "fmt" + logpkg "log" + "os" + "strconv" + + "github.com/DreamItGetIT/statuscake" + "strings" +) + +var log *logpkg.Logger + +type command func(*statuscake.Client, ...string) error + +var commands map[string]command + +func init() { + log = logpkg.New(os.Stderr, "", 0) + commands = map[string]command{ + "list": cmdList, + "detail": cmdDetail, + "delete": cmdDelete, + "create": cmdCreate, + "update": cmdUpdate, + } +} + +func colouredStatus(s string) string { + switch s { + case "Up": + return fmt.Sprintf("\033[0;32m%s\033[0m", s) + case "Down": + return fmt.Sprintf("\033[0;31m%s\033[0m", s) + default: + return s + } +} + +func getEnv(name string) string { + v := os.Getenv(name) + if v == "" { + log.Fatalf("`%s` env variable is required", name) + } + + return v +} + +func cmdList(c *statuscake.Client, args ...string) error { + tt := c.Tests() + tests, err := tt.All() + if err != nil { + return err + } + + for _, t := range tests { + var paused string + if t.Paused { + paused = "yes" + } else { + paused = "no" + } + + fmt.Printf("* %d: %s\n", t.TestID, colouredStatus(t.Status)) + fmt.Printf(" WebsiteName: %s\n", t.WebsiteName) + fmt.Printf(" TestType: %s\n", t.TestType) + fmt.Printf(" Paused: %s\n", paused) + fmt.Printf(" ContactGroup: %s\n", fmt.Sprint(t.ContactGroup)) + fmt.Printf(" Uptime: %f\n", t.Uptime) + } + + return nil +} + +func cmdDetail(c *statuscake.Client, args ...string) error { + if len(args) != 1 { + return fmt.Errorf("command `detail` requires a single argument `TestID`") + } + + id, err := strconv.Atoi(args[0]) + if err != nil { + return err + } + + tt := c.Tests() + t, err := tt.Detail(id) + if err != nil { + return err + } + + var paused string + if t.Paused { + paused = "yes" + } else { + paused = "no" + } + + fmt.Printf("* %d: %s\n", t.TestID, colouredStatus(t.Status)) + fmt.Printf(" WebsiteName: %s\n", t.WebsiteName) + fmt.Printf(" WebsiteURL: %s\n", t.WebsiteURL) + fmt.Printf(" PingURL: %s\n", t.PingURL) + fmt.Printf(" TestType: %s\n", t.TestType) + fmt.Printf(" Paused: %s\n", paused) + fmt.Printf(" ContactGroup: %s\n", fmt.Sprint(t.ContactGroup)) + fmt.Printf(" Uptime: %f\n", t.Uptime) + fmt.Printf(" NodeLocations: %s\n", fmt.Sprint(t.NodeLocations)) + + return nil +} + +func cmdDelete(c *statuscake.Client, args ...string) error { + if len(args) != 1 { + return fmt.Errorf("command `delete` requires a single argument `TestID`") + } + + id, err := strconv.Atoi(args[0]) + if err != nil { + return err + } + + return c.Tests().Delete(id) +} + +func askString(name string) string { + var v string + + fmt.Printf("%s: ", name) + _, err := fmt.Scanln(&v) + if err != nil { + log.Fatal(err) + } + + return v +} + +func askInt(name string) int { + v := askString(name) + i, err := strconv.Atoi(v) + if err != nil { + log.Fatalf("Invalid number `%s`", v) + } + + return i +} + +func cmdCreate(c *statuscake.Client, args ...string) error { + websiteName := askString("WebsiteName") + websiteURL := askString("WebsiteURL") + testType := askString("TestType") + checkRate := askInt("CheckRate") + contactGroupString := askString("ContactGroup (comma separated list)") + contactGroup := strings.Split(contactGroupString, ",") + nodeLocationsString := askString("NodeLocations (comma separated list)") + nodeLocations := strings.Split(nodeLocationsString, ",") + + t := &statuscake.Test{ + WebsiteName: websiteName, + WebsiteURL: websiteURL, + TestType: testType, + CheckRate: checkRate, + NodeLocations: nodeLocations, + ContactGroup: contactGroup, + } + + t2, err := c.Tests().Update(t) + if err != nil { + return err + } + + fmt.Printf("CREATED: \n%+v\n", t2) + + return nil +} + +func cmdUpdate(c *statuscake.Client, args ...string) error { + if len(args) != 1 { + return fmt.Errorf("command `update` requires a single argument `TestID`") + } + + id, err := strconv.Atoi(args[0]) + if err != nil { + return err + } + + tt := c.Tests() + t, err := tt.Detail(id) + if err != nil { + return err + } + + t.TestID = id + t.WebsiteName = askString(fmt.Sprintf("WebsiteName [%s]", t.WebsiteName)) + t.WebsiteURL = askString(fmt.Sprintf("WebsiteURL [%s]", t.WebsiteURL)) + t.TestType = askString(fmt.Sprintf("TestType [%s]", t.TestType)) + t.CheckRate = askInt(fmt.Sprintf("CheckRate [%d]", t.CheckRate)) + contactGroupString := askString("ContactGroup (comma separated list)") + t.ContactGroup = strings.Split(contactGroupString, ",") + nodeLocationsString := askString("NodeLocations (comma separated list)") + t.NodeLocations = strings.Split(nodeLocationsString, ",") + + t2, err := c.Tests().Update(t) + if err != nil { + return err + } + + fmt.Printf("UPDATED: \n%+v\n", t2) + + return nil +} + +func usage() { + fmt.Printf("Usage:\n") + fmt.Printf(" %s COMMAND\n", os.Args[0]) + fmt.Printf("Available commands:\n") + for k := range commands { + fmt.Printf(" %+v\n", k) + } +} + +func main() { + username := getEnv("STATUSCAKE_USERNAME") + apikey := getEnv("STATUSCAKE_APIKEY") + + if len(os.Args) < 2 { + usage() + os.Exit(1) + } + + var err error + + c, err := statuscake.New(statuscake.Auth{Username: username, Apikey: apikey}) + if err != nil { + log.Fatal(err) + } + + if cmd, ok := commands[os.Args[1]]; ok { + err = cmd(c, os.Args[2:]...) + } else { + err = fmt.Errorf("Unknown command `%s`", os.Args[1]) + } + + if err != nil { + log.Fatalf("Error running command `%s`: %s", os.Args[1], err.Error()) + } +} diff --git a/vendor/github.com/DreamItGetIT/statuscake/fixtures/auth_error.json b/vendor/github.com/DreamItGetIT/statuscake/fixtures/auth_error.json new file mode 100644 index 0000000..4f14be5 --- /dev/null +++ b/vendor/github.com/DreamItGetIT/statuscake/fixtures/auth_error.json @@ -0,0 +1,4 @@ +{ + "ErrNo": 0, + "Error": "Can not access account. Was both Username and API Key provided?" +} diff --git a/vendor/github.com/DreamItGetIT/statuscake/fixtures/sslCreateOk.json b/vendor/github.com/DreamItGetIT/statuscake/fixtures/sslCreateOk.json new file mode 100644 index 0000000..615e2db --- /dev/null +++ b/vendor/github.com/DreamItGetIT/statuscake/fixtures/sslCreateOk.json @@ -0,0 +1,14 @@ +{ + "Success": true, + "Message": 143616, + "Input": { + "domain": "https://www.exemple.com", + "checkrate": "2073600", + "contact_groups": "", + "alert_reminder": true, + "alert_expiry": true, + "alert_broken": true, + "alert_mixed": true, + "alert_at": "7,18,2019" + } +} diff --git a/vendor/github.com/DreamItGetIT/statuscake/fixtures/sslDeleteOk.json b/vendor/github.com/DreamItGetIT/statuscake/fixtures/sslDeleteOk.json new file mode 100644 index 0000000..a394239 --- /dev/null +++ b/vendor/github.com/DreamItGetIT/statuscake/fixtures/sslDeleteOk.json @@ -0,0 +1,4 @@ +{ + "Success": true, + "Message": "Deletion successful" +} diff --git a/vendor/github.com/DreamItGetIT/statuscake/fixtures/sslListAllOk.json b/vendor/github.com/DreamItGetIT/statuscake/fixtures/sslListAllOk.json new file mode 100644 index 0000000..15c428f --- /dev/null +++ b/vendor/github.com/DreamItGetIT/statuscake/fixtures/sslListAllOk.json @@ -0,0 +1,100 @@ +[ + { + "id": "143615", + "checkrate": 2073600, + "paused": false, + "domain": "https://www.exemple.com", + "issuer_cn": "Let's Encrypt Authority X3", + "cert_score": "95", + "cipher_score": "100", + "cert_status": "CERT_OK", + "cipher": "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", + "valid_from_utc": "2019-05-28 01:22:00", + "valid_until_utc": "2019-08-26 01:22:00", + "mixed_content": [], + "flags": { + "is_extended": false, + "has_pfs": true, + "is_broken": false, + "is_expired": false, + "is_missing": false, + "is_revoked": false, + "has_mixed": false + }, + "contact_groups": [], + "alert_at": "7,18,2019", + "last_reminder": 2019, + "alert_reminder": true, + "alert_expiry": true, + "alert_broken": true, + "alert_mixed": true, + "last_updated_utc": "2019-06-20 10:11:03" + }, + { + "id": "143616", + "checkrate": 2073600, + "paused": false, + "domain": "https://www.exemple.com", + "issuer_cn": "Let's Encrypt Authority X3", + "cert_score": "95", + "cipher_score": "100", + "cert_status": "CERT_OK", + "cipher": "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", + "valid_from_utc": "2019-05-28 01:22:00", + "valid_until_utc": "2019-08-26 01:22:00", + "mixed_content": [ + { + "type": "img", + "src": "http://example.com/image.gif" + } + ], + "flags": { + "is_extended": false, + "has_pfs": true, + "is_broken": false, + "is_expired": false, + "is_missing": false, + "is_revoked": false, + "has_mixed": false + }, + "contact_groups": ["12","13","34"], + "alert_at": "7,18,2019", + "last_reminder": 2019, + "alert_reminder": true, + "alert_expiry": true, + "alert_broken": true, + "alert_mixed": true, + "last_updated_utc": "2019-06-20 10:23:14" + }, + { + "id": "143617", + "checkrate": 2073600, + "paused": false, + "domain": "https://www.exemple.com", + "issuer_cn": "Let's Encrypt Authority X3", + "cert_score": "95", + "cipher_score": "100", + "cert_status": "CERT_OK", + "cipher": "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", + "valid_from_utc": "2019-05-28 01:22:00", + "valid_until_utc": "2019-08-26 01:22:00", + "mixed_content": [], + "flags": { + "is_extended": false, + "has_pfs": true, + "is_broken": false, + "is_expired": false, + "is_missing": false, + "is_revoked": false, + "has_mixed": false + }, + "contact_groups": [], + "alert_at": "7,18,2019", + "last_reminder": 2019, + "alert_reminder": true, + "alert_expiry": true, + "alert_broken": true, + "alert_mixed": true, + "last_updated_utc": "2019-06-20 10:23:20" + } +] diff --git a/vendor/github.com/DreamItGetIT/statuscake/fixtures/sslUpdateOk.json b/vendor/github.com/DreamItGetIT/statuscake/fixtures/sslUpdateOk.json new file mode 100644 index 0000000..23b5932 --- /dev/null +++ b/vendor/github.com/DreamItGetIT/statuscake/fixtures/sslUpdateOk.json @@ -0,0 +1,4 @@ +{ + "Success": true, + "Message": "SSL test has been updated successfully" +} diff --git a/vendor/github.com/DreamItGetIT/statuscake/fixtures/ssls_all_ok.json b/vendor/github.com/DreamItGetIT/statuscake/fixtures/ssls_all_ok.json new file mode 100644 index 0000000..4dd6b51 --- /dev/null +++ b/vendor/github.com/DreamItGetIT/statuscake/fixtures/ssls_all_ok.json @@ -0,0 +1,70 @@ +[ + { + "id": "12345", + "paused": false, + "domain": "https://google.com", + "cert_score": "95", + "cipher_score": "100", + "cert_status": "CERT_OK", + "cipher": "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", + "valid_from_utc": "2017-10-10 14:06:00", + "valid_until_utc": "2017-12-29 00:00:00", + "mixed_content": [ + { + "type": "img", + "src": "http://example.com/image.gif" + } + ], + "flags": { + "is_extended": false, + "has_pfs": true, + "is_broken": false, + "is_expired": false, + "is_missing": false, + "is_revoked": false, + "is_mixed": false + }, + "contact_groups": [12, 13, 14], + "alert_at": "1,7,30", + "last_reminder": 0, + "alert_reminder": false, + "alert_expiry": false, + "alert_broken": false, + "alert_mixed": false, + "last_updated_utc": "2017-10-24 09:02:25" + }, + { + "id": "12346", + "paused": false, + "domain": "https://google2.com", + "cert_score": "95", + "cipher_score": "100", + "cert_status": "CERT_OK", + "cipher": "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", + "valid_from_utc": "2017-10-10 14:06:00", + "valid_until_utc": "2017-12-29 00:00:00", + "mixed_content": [ + { + "type": "img", + "src": "http://example.com/image.gif" + } + ], + "flags": { + "is_extended": false, + "has_pfs": true, + "is_broken": false, + "is_expired": false, + "is_missing": false, + "is_revoked": false, + "is_mixed": false + }, + "contact_groups": [12, 13, 14], + "alert_at": "1,7,30", + "last_reminder": 0, + "alert_reminder": false, + "alert_expiry": false, + "alert_broken": false, + "alert_mixed": false, + "last_updated_utc": "2017-10-24 09:02:25" + } +] diff --git a/vendor/github.com/DreamItGetIT/statuscake/fixtures/ssls_create_ok.json b/vendor/github.com/DreamItGetIT/statuscake/fixtures/ssls_create_ok.json new file mode 100644 index 0000000..c7734e0 --- /dev/null +++ b/vendor/github.com/DreamItGetIT/statuscake/fixtures/ssls_create_ok.json @@ -0,0 +1,13 @@ +{ + "Success": true, + "Message": 12345, + "Input": { + "domain": "https://example.com", + "checkrate": 86400, + "contact_groups": "1000,2000", + "alert_reminder": false, + "alert_expiry": false, + "alert_broken": false, + "alert_at": "59,60,61" + } +} diff --git a/vendor/github.com/DreamItGetIT/statuscake/fixtures/ssls_update_error.json b/vendor/github.com/DreamItGetIT/statuscake/fixtures/ssls_update_error.json new file mode 100644 index 0000000..5f0f4d5 --- /dev/null +++ b/vendor/github.com/DreamItGetIT/statuscake/fixtures/ssls_update_error.json @@ -0,0 +1,13 @@ +{ + "Success": false, + "Message": "Error creating test", + "Input": { + "domain": "https://example.com", + "checkrate": 86400, + "contact_groups": "1000,2000", + "alert_reminder": false, + "alert_expiry": false, + "alert_broken": false, + "alert_at": "59,60,61" + } +} diff --git a/vendor/github.com/DreamItGetIT/statuscake/fixtures/ssls_update_ok.json b/vendor/github.com/DreamItGetIT/statuscake/fixtures/ssls_update_ok.json new file mode 100644 index 0000000..f77f4f3 --- /dev/null +++ b/vendor/github.com/DreamItGetIT/statuscake/fixtures/ssls_update_ok.json @@ -0,0 +1,4 @@ +{ + "Success": true, + "Message": "SSL test has been updated successfully" +} diff --git a/vendor/github.com/DreamItGetIT/statuscake/fixtures/tests_all_ok.json b/vendor/github.com/DreamItGetIT/statuscake/fixtures/tests_all_ok.json new file mode 100644 index 0000000..dee80d4 --- /dev/null +++ b/vendor/github.com/DreamItGetIT/statuscake/fixtures/tests_all_ok.json @@ -0,0 +1,23 @@ +[ + { + "TestID": 100, + "Paused": false, + "TestType": "HTTP", + "WebsiteName": "www 1", + "ContactGroup": ["1"], + "Status": "Up", + "Uptime": 100, + "NodeLocations": ["foo", "bar"] + }, + { + "TestID": 101, + "Paused": true, + "TestType": "HTTP", + "WebsiteName": "www 2", + "ContactGroup": ["2"], + "Status": "Down", + "Uptime": 0, + "NodeLocations": ["foo"], + "TestTags": ["test1", "test2"] + } +] diff --git a/vendor/github.com/DreamItGetIT/statuscake/fixtures/tests_delete_error.json b/vendor/github.com/DreamItGetIT/statuscake/fixtures/tests_delete_error.json new file mode 100644 index 0000000..6fad58e --- /dev/null +++ b/vendor/github.com/DreamItGetIT/statuscake/fixtures/tests_delete_error.json @@ -0,0 +1,5 @@ +{ + "Success": false, + "Error": "this is an error" +} + diff --git a/vendor/github.com/DreamItGetIT/statuscake/fixtures/tests_delete_ok.json b/vendor/github.com/DreamItGetIT/statuscake/fixtures/tests_delete_ok.json new file mode 100644 index 0000000..0dd279b --- /dev/null +++ b/vendor/github.com/DreamItGetIT/statuscake/fixtures/tests_delete_ok.json @@ -0,0 +1,6 @@ +{ + "TestID": 6735, + "Affected": 1, + "Success": true, + "Message": "This Check Has Been Deleted. It can not be recovered." +} diff --git a/vendor/github.com/DreamItGetIT/statuscake/fixtures/tests_detail_ok.json b/vendor/github.com/DreamItGetIT/statuscake/fixtures/tests_detail_ok.json new file mode 100644 index 0000000..a64989b --- /dev/null +++ b/vendor/github.com/DreamItGetIT/statuscake/fixtures/tests_detail_ok.json @@ -0,0 +1,39 @@ +{ + "TestID": 6735, + "TestType": "HTTP", + "Paused": false, + "WebsiteName": "NL", + "CustomHeader": "{\"some\":{\"json\": [\"value\"]}}", + "UserAgent": "product/version (comment)", + "ContactGroups": [ + { + "ID": 536, + "Name": "Dummy ContactGroup", + "Email": "github-dreamitgetit-statuscake@maildrop.cc" + } + ], + "ContactID": 536, + "Status": "Up", + "Uptime": 0, + "CheckRate": 60, + "Timeout": 40, + "LogoImage": "", + "WebsiteHost": "Various", + "NodeLocations": [ + "foo", + "bar" + ], + "FindString": "", + "DoNotFind": false, + "LastTested": "2013-01-20 14:38:18", + "NextLocation": "USNY", + "Processing": false, + "ProcessingState": "Pretest", + "ProcessingOn": "dalas.localdomain", + "DownTimes": "0", + "UseJar": 0, + "PostRaw": "", + "FinalEndpoint": "", + "EnableSSLWarning": false, + "FollowRedirect": false +} diff --git a/vendor/github.com/DreamItGetIT/statuscake/fixtures/tests_update_error.json b/vendor/github.com/DreamItGetIT/statuscake/fixtures/tests_update_error.json new file mode 100644 index 0000000..a76c5eb --- /dev/null +++ b/vendor/github.com/DreamItGetIT/statuscake/fixtures/tests_update_error.json @@ -0,0 +1,9 @@ +{ + "Issues": { + "WebsiteName": "issue a", + "WebsiteURL": "issue b", + "CheckRate": "issue c" + }, + "Success": false, + "Message": "Required Data is Missing." +} diff --git a/vendor/github.com/DreamItGetIT/statuscake/fixtures/tests_update_error_slice_of_issues.json b/vendor/github.com/DreamItGetIT/statuscake/fixtures/tests_update_error_slice_of_issues.json new file mode 100644 index 0000000..02e98eb --- /dev/null +++ b/vendor/github.com/DreamItGetIT/statuscake/fixtures/tests_update_error_slice_of_issues.json @@ -0,0 +1,5 @@ +{ + "Issues": ["hello", "world"], + "Success": false, + "Message": "Required Data is Missing." +} diff --git a/vendor/github.com/DreamItGetIT/statuscake/fixtures/tests_update_ok.json b/vendor/github.com/DreamItGetIT/statuscake/fixtures/tests_update_ok.json new file mode 100644 index 0000000..7c2dee2 --- /dev/null +++ b/vendor/github.com/DreamItGetIT/statuscake/fixtures/tests_update_ok.json @@ -0,0 +1,6 @@ +{ + "Issues": {}, + "Success": true, + "Message": "", + "InsertID": 1234 +} diff --git a/vendor/github.com/DreamItGetIT/statuscake/ssl.go b/vendor/github.com/DreamItGetIT/statuscake/ssl.go new file mode 100644 index 0000000..3f73d8d --- /dev/null +++ b/vendor/github.com/DreamItGetIT/statuscake/ssl.go @@ -0,0 +1,273 @@ +package statuscake + +import ( + "encoding/json" + "fmt" + "net/url" + "strings" + "strconv" + + "github.com/google/go-querystring/query" +) + +//Ssl represent the data received by the API with GET +type Ssl struct { + ID string `json:"id" url:"id,omitempty"` + Domain string `json:"domain" url:"domain,omitempty"` + Checkrate int `json:"checkrate" url:"checkrate,omitempty"` + ContactGroupsC string ` url:"contact_groups,omitempty"` + AlertAt string `json:"alert_at" url:"alert_at,omitempty"` + AlertReminder bool `json:"alert_reminder" url:"alert_expiry,omitempty"` + AlertExpiry bool `json:"alert_expiry" url:"alert_reminder,omitempty"` + AlertBroken bool `json:"alert_broken" url:"alert_broken,omitempty"` + AlertMixed bool `json:"alert_mixed" url:"alert_mixed,omitempty"` + Paused bool `json:"paused"` + IssuerCn string `json:"issuer_cn"` + CertScore string `json:"cert_score"` + CipherScore string `json:"cipher_score"` + CertStatus string `json:"cert_status"` + Cipher string `json:"cipher"` + ValidFromUtc string `json:"valid_from_utc"` + ValidUntilUtc string `json:"valid_until_utc"` + MixedContent []map[string]string `json:"mixed_content"` + Flags map[string]bool `json:"flags"` + ContactGroups []string `json:"contact_groups"` + LastReminder int `json:"last_reminder"` + LastUpdatedUtc string `json:"last_updated_utc"` +} + +//PartialSsl represent a ssl test creation or modification +type PartialSsl struct { + ID int + Domain string + Checkrate string + ContactGroupsC string + AlertAt string + AlertExpiry bool + AlertReminder bool + AlertBroken bool + AlertMixed bool +} + +type createSsl struct { + ID int `url:"id,omitempty"` + Domain string `url:"domain" json:"domain"` + Checkrate string `url:"checkrate" json:"checkrate"` + ContactGroupsC string `url:"contact_groups" json:"contact_groups"` + AlertAt string `url:"alert_at" json:"alert_at"` + AlertExpiry bool `url:"alert_expiry" json:"alert_expiry"` + AlertReminder bool `url:"alert_reminder" json:"alert_reminder"` + AlertBroken bool `url:"alert_broken" json:"alert_broken"` + AlertMixed bool `url:"alert_mixed" json:"alert_mixed"` +} + +type updateSsl struct { + ID int `url:"id"` + Domain string `url:"domain" json:"domain"` + Checkrate string `url:"checkrate" json:"checkrate"` + ContactGroupsC string `url:"contact_groups" json:"contact_groups"` + AlertAt string `url:"alert_at" json:"alert_at"` + AlertExpiry bool `url:"alert_expiry" json:"alert_expiry"` + AlertReminder bool `url:"alert_reminder" json:"alert_reminder"` + AlertBroken bool `url:"alert_broken" json:"alert_broken"` + AlertMixed bool `url:"alert_mixed" json:"alert_mixed"` +} + + +type sslUpdateResponse struct { + Success bool `json:"Success"` + Message interface{} `json:"Message"` +} + +type sslCreateResponse struct { + Success bool `json:"Success"` + Message interface{} `json:"Message"` + Input createSsl `json:"Input"` +} + +//Ssls represent the actions done wit the API +type Ssls interface { + All() ([]*Ssl, error) + completeSsl(*PartialSsl) (*Ssl, error) + Detail(string) (*Ssl, error) + Update(*PartialSsl) (*Ssl, error) + UpdatePartial(*PartialSsl) (*PartialSsl, error) + Delete(ID string) error + CreatePartial(*PartialSsl) (*PartialSsl, error) + Create(*PartialSsl) (*Ssl, error) +} + +func consolidateSsl(s *Ssl) { + (*s).ContactGroupsC = strings.Trim(strings.Join(strings.Fields(fmt.Sprint((*s).ContactGroups)), ","), "[]") +} + +func findSsl(responses []*Ssl, id string) (*Ssl, error) { + var response *Ssl + for _, elem := range responses { + if (*elem).ID == id { + return elem, nil + } + } + return response, fmt.Errorf("%s Not found", id) +} + +func (tt *ssls) completeSsl(s *PartialSsl) (*Ssl, error) { + full, err := tt.Detail(strconv.Itoa((*s).ID)) + if err != nil { + return nil, err + } + (*full).ContactGroups = strings.Split((*s).ContactGroupsC,",") + return full, nil +} + +//Partial return a PartialSsl corresponding to the Ssl +func Partial(s *Ssl) (*PartialSsl,error) { + if s==nil { + return nil,fmt.Errorf("s is nil") + } + id,err:=strconv.Atoi(s.ID) + if(err!=nil){ + return nil,err + } + return &PartialSsl{ + ID: id, + Domain: s.Domain, + Checkrate: strconv.Itoa(s.Checkrate), + ContactGroupsC: s.ContactGroupsC, + AlertReminder: s.AlertReminder, + AlertExpiry: s.AlertExpiry, + AlertBroken: s.AlertBroken, + AlertMixed: s.AlertMixed, + AlertAt: s.AlertAt, + },nil + +} + +type ssls struct { + client apiClient +} + +//NewSsls return a new ssls +func NewSsls(c apiClient) Ssls { + return &ssls{ + client: c, + } +} + +//All return a list of all the ssl from the API +func (tt *ssls) All() ([]*Ssl, error) { + rawResponse, err := tt.client.get("/SSL", nil) + if err != nil { + return nil, fmt.Errorf("Error getting StatusCake Ssl: %s", err.Error()) + } + var getResponse []*Ssl + err = json.NewDecoder(rawResponse.Body).Decode(&getResponse) + if err != nil { + return nil, err + } + + for ssl := range getResponse { + consolidateSsl(getResponse[ssl]) + } + + return getResponse, err +} + +//Detail return the ssl corresponding to the id +func (tt *ssls) Detail(id string) (*Ssl, error) { + responses, err := tt.All() + if err != nil { + return nil, err + } + mySsl, errF := findSsl(responses, id) + if errF != nil { + return nil, errF + } + return mySsl, nil +} + +//Update update the API with s and create one if s.ID=0 then return the corresponding Ssl +func (tt *ssls) Update(s *PartialSsl) (*Ssl, error) { + var err error + s, err = tt.UpdatePartial(s) + if err!= nil { + return nil, err + } + return tt.completeSsl(s) +} + +//UpdatePartial update the API with s and create one if s.ID=0 then return the corresponding PartialSsl +func (tt *ssls) UpdatePartial(s *PartialSsl) (*PartialSsl, error) { + + if((*s).ID == 0){ + return tt.CreatePartial(s) + } + var v url.Values + + v, _ = query.Values(updateSsl(*s)) + + rawResponse, err := tt.client.put("/SSL/Update", v) + if err != nil { + return nil, fmt.Errorf("Error creating StatusCake Ssl: %s", err.Error()) + } + + var updateResponse sslUpdateResponse + err = json.NewDecoder(rawResponse.Body).Decode(&updateResponse) + if err != nil { + return nil, err + } + + if !updateResponse.Success { + return nil, fmt.Errorf("%s", updateResponse.Message.(string)) + } + + + return s, nil +} + +//Delete delete the ssl which ID is id +func (tt *ssls) Delete(id string) error { + _, err := tt.client.delete("/SSL/Update", url.Values{"id": {fmt.Sprint(id)}}) + if err != nil { + return err + } + + return nil +} + +//Create create the ssl whith the data in s and return the Ssl created +func (tt *ssls) Create(s *PartialSsl) (*Ssl, error) { + var err error + s, err = tt.CreatePartial(s) + if err!= nil { + return nil, err + } + return tt.completeSsl(s) +} + +//CreatePartial create the ssl whith the data in s and return the PartialSsl created +func (tt *ssls) CreatePartial(s *PartialSsl) (*PartialSsl, error) { + (*s).ID=0 + var v url.Values + v, _ = query.Values(createSsl(*s)) + + rawResponse, err := tt.client.put("/SSL/Update", v) + if err != nil { + return nil, fmt.Errorf("Error creating StatusCake Ssl: %s", err.Error()) + } + + var createResponse sslCreateResponse + err = json.NewDecoder(rawResponse.Body).Decode(&createResponse) + if err != nil { + return nil, err + } + + if !createResponse.Success { + return nil, fmt.Errorf("%s", createResponse.Message.(string)) + } + *s = PartialSsl(createResponse.Input) + (*s).ID = int(createResponse.Message.(float64)) + + return s,nil +} + diff --git a/vendor/github.com/DreamItGetIT/statuscake/ssl_test.go b/vendor/github.com/DreamItGetIT/statuscake/ssl_test.go new file mode 100644 index 0000000..48a961c --- /dev/null +++ b/vendor/github.com/DreamItGetIT/statuscake/ssl_test.go @@ -0,0 +1,343 @@ +package statuscake + +import ( + "testing" + //"fmt" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "net/url" +) + +func TestSsl_All(t *testing.T) { + assert := assert.New(t) + require := require.New(t) + + c := &fakeAPIClient{ + fixture: "sslListAllOk.json", + } + tt := NewSsls(c) + ssls, err := tt.All() + require.Nil(err) + + assert.Equal("/SSL", c.sentRequestPath) + assert.Equal("GET", c.sentRequestMethod) + assert.Nil(c.sentRequestValues) + assert.Len(ssls, 3) + mixed := make(map[string]string) + flags := make(map[string]bool) + flags["is_extended"] = false + flags["has_pfs"] = true + flags["is_broken"] = false + flags["is_expired"] = false + flags["is_missing"] = false + flags["is_revoked"] = false + flags["has_mixed"] = false + expectedTest := &Ssl{ + ID: "143615", + Checkrate: 2073600, + Paused: false, + Domain: "https://www.exemple.com", + IssuerCn: "Let's Encrypt Authority X3", + CertScore: "95", + CipherScore: "100", + CertStatus: "CERT_OK", + Cipher: "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", + ValidFromUtc: "2019-05-28 01:22:00", + ValidUntilUtc: "2019-08-26 01:22:00", + MixedContent: []map[string]string{}, + Flags: flags, + ContactGroups: []string{}, + ContactGroupsC: "", + AlertAt: "7,18,2019", + LastReminder: 2019, + AlertReminder: true, + AlertExpiry: true, + AlertBroken: true, + AlertMixed: true, + LastUpdatedUtc: "2019-06-20 10:11:03", + } + assert.Equal(expectedTest, ssls[0]) + + expectedTest.ID="143617" + expectedTest.LastUpdatedUtc="2019-06-20 10:23:20" + assert.Equal(expectedTest, ssls[2]) + + expectedTest.ID="143616" + expectedTest.LastUpdatedUtc="2019-06-20 10:23:14" + mixed["type"]="img" + mixed["src"]="http://example.com/image.gif" + expectedTest.MixedContent=[]map[string]string{mixed} + expectedTest.ContactGroupsC="12,13,34" + expectedTest.ContactGroups=[]string{"12","13","34"} + assert.Equal(expectedTest, ssls[1]) +} + +func TestSsls_Detail_OK(t *testing.T) { + assert := assert.New(t) + require := require.New(t) + + c := &fakeAPIClient{ + fixture: "sslListAllOk.json", + } + tt := NewSsls(c) + + ssl, err := tt.Detail("143616") + require.Nil(err) + assert.Equal("/SSL", c.sentRequestPath) + assert.Equal("GET", c.sentRequestMethod) + assert.Nil(c.sentRequestValues) + + mixed := make(map[string]string) + flags := make(map[string]bool) + + mixed["type"]="img" + mixed["src"]="http://example.com/image.gif" + + flags["is_extended"] = false + flags["has_pfs"] = true + flags["is_broken"] = false + flags["is_expired"] = false + flags["is_missing"] = false + flags["is_revoked"] = false + flags["has_mixed"] = false + expectedTest := &Ssl{ + ID: "143616", + Checkrate: 2073600, + Paused: false, + Domain: "https://www.exemple.com", + IssuerCn: "Let's Encrypt Authority X3", + CertScore: "95", + CipherScore: "100", + CertStatus: "CERT_OK", + Cipher: "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", + ValidFromUtc: "2019-05-28 01:22:00", + ValidUntilUtc: "2019-08-26 01:22:00", + MixedContent: []map[string]string{mixed}, + Flags: flags, + ContactGroups: []string{"12","13","34"}, + ContactGroupsC: "12,13,34", + AlertAt: "7,18,2019", + LastReminder: 2019, + AlertReminder: true, + AlertExpiry: true, + AlertBroken: true, + AlertMixed: true, + LastUpdatedUtc: "2019-06-20 10:23:14", + } + + assert.Equal(expectedTest, ssl) +} + +func TestSsls_CreatePartial_OK(t *testing.T) { + assert := assert.New(t) + require := require.New(t) + + c := &fakeAPIClient{ + fixture: "sslCreateOk.json", + } + tt := NewSsls(c) + partial := &PartialSsl{ + Domain: "https://www.exemple.com", + Checkrate: "2073600", + ContactGroupsC: "", + AlertReminder: true, + AlertExpiry: true, + AlertBroken: true, + AlertMixed: true, + AlertAt: "7,18,2019", + } + expectedRes := &PartialSsl { + ID: 143616, + Domain: "https://www.exemple.com", + Checkrate: "2073600", + ContactGroupsC: "", + AlertReminder: true, + AlertExpiry: true, + AlertBroken: true, + AlertMixed: true, + AlertAt: "7,18,2019", + } + res, err := tt.CreatePartial(partial) + require.Nil(err) + assert.Equal("/SSL/Update", c.sentRequestPath) + assert.Equal("PUT", c.sentRequestMethod) + assert.Equal(c.sentRequestValues,url.Values(url.Values{"domain":[]string{"https://www.exemple.com"}, "checkrate":[]string{"2073600"}, "contact_groups":[]string{""}, "alert_at":[]string{"7,18,2019"}, "alert_expiry":[]string{"true"}, "alert_reminder":[]string{"true"}, "alert_broken":[]string{"true"}, "alert_mixed":[]string{"true"}})) + + assert.Equal(expectedRes, res) +} + +func TestSsls_UpdatePartial_OK(t *testing.T) { + assert := assert.New(t) + require := require.New(t) + + c := &fakeAPIClient{ + fixture: "sslUpdateOk.json", + } + tt := NewSsls(c) + partial := &PartialSsl{ + ID: 143616, + Domain: "https://www.exemple.com", + Checkrate: "2073600", + ContactGroupsC: "", + AlertReminder: false, + AlertExpiry: true, + AlertBroken: true, + AlertMixed: true, + AlertAt: "7,18,2019", + } + expectedRes := &PartialSsl { + ID: 143616, + Domain: "https://www.exemple.com", + Checkrate: "2073600", + ContactGroupsC: "", + AlertReminder: false, + AlertExpiry: true, + AlertBroken: true, + AlertMixed: true, + AlertAt: "7,18,2019", + } + res, err := tt.UpdatePartial(partial) + require.Nil(err) + assert.Equal(expectedRes, res) + assert.Equal("/SSL/Update", c.sentRequestPath) + assert.Equal("PUT", c.sentRequestMethod) + assert.Equal(c.sentRequestValues,url.Values(url.Values{"id":[]string{"143616"},"domain":[]string{"https://www.exemple.com"}, "checkrate":[]string{"2073600"}, "contact_groups":[]string{""}, "alert_at":[]string{"7,18,2019"}, "alert_expiry":[]string{"true"}, "alert_reminder":[]string{"false"}, "alert_broken":[]string{"true"}, "alert_mixed":[]string{"true"}})) +} + +func TestSsl_complete_OK(t *testing.T) { + assert := assert.New(t) + require := require.New(t) + + c := &fakeAPIClient{ + fixture: "sslListAllOk.json", + } + tt := NewSsls(c) + + partial := &PartialSsl { + ID: 143616, + Domain: "https://www.exemple.com", + Checkrate: "2073600", + ContactGroupsC: "12,13,34", + AlertReminder: true, + AlertExpiry: true, + AlertBroken: true, + AlertMixed: true, + AlertAt: "7,18,2019", + } + full, err := tt.completeSsl(partial) + require.Nil(err) + mixed := make(map[string]string) + flags := make(map[string]bool) + + mixed["type"]="img" + mixed["src"]="http://example.com/image.gif" + + flags["is_extended"] = false + flags["has_pfs"] = true + flags["is_broken"] = false + flags["is_expired"] = false + flags["is_missing"] = false + flags["is_revoked"] = false + flags["has_mixed"] = false + expectedTest := &Ssl{ + ID: "143616", + Checkrate: 2073600, + Paused: false, + Domain: "https://www.exemple.com", + IssuerCn: "Let's Encrypt Authority X3", + CertScore: "95", + CipherScore: "100", + CertStatus: "CERT_OK", + Cipher: "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", + ValidFromUtc: "2019-05-28 01:22:00", + ValidUntilUtc: "2019-08-26 01:22:00", + MixedContent: []map[string]string{mixed}, + Flags: flags, + ContactGroups: []string{"12","13","34"}, + ContactGroupsC: "12,13,34", + AlertAt: "7,18,2019", + LastReminder: 2019, + AlertReminder: true, + AlertExpiry: true, + AlertBroken: true, + AlertMixed: true, + LastUpdatedUtc: "2019-06-20 10:23:14", + } + + assert.Equal(expectedTest, full) + +} + +func TestSsl_partial_OK(t *testing.T) { + assert := assert.New(t) + require := require.New(t) + + mixed := make(map[string]string) + flags := make(map[string]bool) + + mixed["type"]="img" + mixed["src"]="http://example.com/image.gif" + + flags["is_extended"] = false + flags["has_pfs"] = true + flags["is_broken"] = false + flags["is_expired"] = false + flags["is_missing"] = false + flags["is_revoked"] = false + flags["has_mixed"] = false + full := &Ssl{ + ID: "143616", + Checkrate: 2073600, + Paused: false, + Domain: "https://www.exemple.com", + IssuerCn: "Let's Encrypt Authority X3", + CertScore: "95", + CipherScore: "100", + CertStatus: "CERT_OK", + Cipher: "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", + ValidFromUtc: "2019-05-28 01:22:00", + ValidUntilUtc: "2019-08-26 01:22:00", + MixedContent: []map[string]string{mixed}, + Flags: flags, + ContactGroups: []string{"12","13","34"}, + ContactGroupsC: "12,13,34", + AlertAt: "7,18,2019", + LastReminder: 2019, + AlertReminder: true, + AlertExpiry: true, + AlertBroken: true, + AlertMixed: true, + LastUpdatedUtc: "2019-06-20 10:23:14", + } + expectedTest:=&PartialSsl { + ID: 143616, + Domain: "https://www.exemple.com", + Checkrate: "2073600", + ContactGroupsC: "12,13,34", + AlertReminder: true, + AlertExpiry: true, + AlertBroken: true, + AlertMixed: true, + AlertAt: "7,18,2019", + } + partial,err:=Partial(full) + require.Nil(err) + assert.Equal(expectedTest, partial) + +} + +func TestSsls_Delete_OK(t *testing.T) { + assert := assert.New(t) + require := require.New(t) + + c := &fakeAPIClient{ + fixture: "sslDeleteOk.json", + } + tt := NewSsls(c) + + err := tt.Delete("143616") + require.Nil(err) + assert.Equal("/SSL/Update", c.sentRequestPath) + assert.Equal("DELETE", c.sentRequestMethod) + assert.Equal(c.sentRequestValues,url.Values(url.Values{"id":[]string{"143616"},},)) +} diff --git a/vendor/github.com/DreamItGetIT/statuscake/tests_test.go b/vendor/github.com/DreamItGetIT/statuscake/tests_test.go new file mode 100644 index 0000000..efeb720 --- /dev/null +++ b/vendor/github.com/DreamItGetIT/statuscake/tests_test.go @@ -0,0 +1,422 @@ +package statuscake + +import ( + "bytes" + "encoding/json" + "io/ioutil" + "log" + "net/http" + "net/url" + "os" + "path/filepath" + "strings" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestTest_Validate(t *testing.T) { + assert := assert.New(t) + require := require.New(t) + + test := &Test{ + Timeout: 200, + Confirmation: 100, + Public: 200, + Virus: 200, + TestType: "FTP", + RealBrowser: 100, + TriggerRate: 100, + CheckRate: 100000, + CustomHeader: "here be dragons", + WebsiteName: "", + WebsiteURL: "", + } + + err := test.Validate() + require.NotNil(err) + + message := err.Error() + assert.Contains(message, "WebsiteName is required") + assert.Contains(message, "WebsiteURL is required") + assert.Contains(message, "Timeout must be 0 or between 6 and 99") + assert.Contains(message, "Confirmation must be between 0 and 9") + assert.Contains(message, "CheckRate must be between 0 and 23999") + assert.Contains(message, "Public must be 0 or 1") + assert.Contains(message, "Virus must be 0 or 1") + assert.Contains(message, "TestType must be HTTP, TCP, or PING") + assert.Contains(message, "RealBrowser must be 0 or 1") + assert.Contains(message, "TriggerRate must be between 0 and 59") + assert.Contains(message, "CustomHeader must be provided as json string") + + test.Timeout = 10 + test.Confirmation = 2 + test.Public = 1 + test.Virus = 1 + test.TestType = "HTTP" + test.RealBrowser = 1 + test.TriggerRate = 50 + test.CheckRate = 10 + test.WebsiteName = "Foo" + test.WebsiteURL = "http://example.com" + test.CustomHeader = `{"test": 15}` + test.NodeLocations = []string{"foo", "bar"} + + err = test.Validate() + assert.Nil(err) +} + +func TestTest_ToURLValues(t *testing.T) { + assert := assert.New(t) + + test := &Test{ + TestID: 123, + Paused: true, + WebsiteName: "Foo Bar", + CustomHeader: `{"some":{"json": ["value"]}}`, + WebsiteURL: "http://example.com", + Port: 3000, + NodeLocations: []string{"foo", "bar"}, + Timeout: 11, + PingURL: "http://example.com/ping", + Confirmation: 1, + CheckRate: 500, + BasicUser: "myuser", + BasicPass: "mypass", + Public: 1, + LogoImage: "http://example.com/logo.jpg", + Branding: 1, + WebsiteHost: "hoster", + Virus: 1, + FindString: "hello", + DoNotFind: true, + TestType: "HTTP", + RealBrowser: 1, + TriggerRate: 50, + TestTags: []string{"tag1", "tag2"}, + StatusCodes: "500", + EnableSSLAlert: false, + FollowRedirect: false, + } + + expected := url.Values{ + "TestID": {"123"}, + "Paused": {"1"}, + "WebsiteName": {"Foo Bar"}, + "WebsiteURL": {"http://example.com"}, + "CustomHeader": {`{"some":{"json": ["value"]}}`}, + "Port": {"3000"}, + "NodeLocations": {"foo,bar"}, + "Timeout": {"11"}, + "PingURL": {"http://example.com/ping"}, + "ContactGroup": {""}, + "Confirmation": {"1"}, + "CheckRate": {"500"}, + "BasicUser": {"myuser"}, + "BasicPass": {"mypass"}, + "Public": {"1"}, + "LogoImage": {"http://example.com/logo.jpg"}, + "Branding": {"1"}, + "WebsiteHost": {"hoster"}, + "Virus": {"1"}, + "FindString": {"hello"}, + "DoNotFind": {"1"}, + "TestType": {"HTTP"}, + "RealBrowser": {"1"}, + "TriggerRate": {"50"}, + "TestTags": {"tag1,tag2"}, + "StatusCodes": {"500"}, + "UseJar": {"0"}, + "PostRaw": {""}, + "FinalEndpoint": {""}, + "EnableSSLAlert": {"0"}, + "FollowRedirect": {"0"}, + } + + assert.Equal(expected, test.ToURLValues()) + + test.TestID = 0 + delete(expected, "TestID") + + assert.Equal(expected.Encode(), test.ToURLValues().Encode()) +} + +func TestTests_All(t *testing.T) { + assert := assert.New(t) + require := require.New(t) + + c := &fakeAPIClient{ + fixture: "tests_all_ok.json", + } + tt := newTests(c) + tests, err := tt.All() + require.Nil(err) + + assert.Equal("/Tests", c.sentRequestPath) + assert.Equal("GET", c.sentRequestMethod) + assert.Nil(c.sentRequestValues) + assert.Len(tests, 2) + + expectedTest := &Test{ + TestID: 100, + Paused: false, + TestType: "HTTP", + WebsiteName: "www 1", + ContactGroup: []string{"1"}, + Status: "Up", + Uptime: 100, + NodeLocations: []string{"foo", "bar"}, + } + assert.Equal(expectedTest, tests[0]) + + expectedTest = &Test{ + TestID: 101, + Paused: true, + TestType: "HTTP", + WebsiteName: "www 2", + ContactGroup: []string{"2"}, + Status: "Down", + Uptime: 0, + NodeLocations: []string{"foo"}, + TestTags: []string{"test1", "test2"}, + } + assert.Equal(expectedTest, tests[1]) +} + +func TestTests_AllWithFilter(t *testing.T) { + assert := assert.New(t) + require := require.New(t) + + c := &fakeAPIClient{ + fixture: "tests_all_ok.json", + } + + v := url.Values{} + v.Set("tags", "test1,test2") + tt := newTests(c) + tests, err := tt.AllWithFilter(v) + require.Nil(err) + + assert.Equal("/Tests", c.sentRequestPath) + assert.Equal("GET", c.sentRequestMethod) + assert.NotNil(c.sentRequestValues) + assert.Len(tests, 1) + + expectedTest := &Test{ + TestID: 101, + Paused: true, + TestType: "HTTP", + WebsiteName: "www 2", + ContactGroup: []string{"2"}, + Status: "Down", + Uptime: 0, + NodeLocations: []string{"foo"}, + TestTags: []string{"test1", "test2"}, + } + assert.Equal(expectedTest, tests[0]) +} + +func TestTests_Update_OK(t *testing.T) { + assert := assert.New(t) + require := require.New(t) + + c := &fakeAPIClient{ + fixture: "tests_update_ok.json", + } + tt := newTests(c) + + test1 := &Test{ + WebsiteName: "foo", + } + + test2, err := tt.Update(test1) + require.Nil(err) + + assert.Equal("/Tests/Update", c.sentRequestPath) + assert.Equal("PUT", c.sentRequestMethod) + assert.NotNil(c.sentRequestValues) + assert.NotNil(test2) + + assert.Equal(1234, test2.TestID) +} + +func TestTests_Update_Error(t *testing.T) { + assert := assert.New(t) + require := require.New(t) + + c := &fakeAPIClient{ + fixture: "tests_update_error.json", + } + tt := newTests(c) + + test1 := &Test{ + WebsiteName: "foo", + } + + test2, err := tt.Update(test1) + assert.Nil(test2) + + require.NotNil(err) + assert.IsType(&updateError{}, err) + assert.Contains(err.Error(), "issue a") +} + +func TestTests_Update_ErrorWithSliceOfIssues(t *testing.T) { + assert := assert.New(t) + require := require.New(t) + + c := &fakeAPIClient{ + fixture: "tests_update_error_slice_of_issues.json", + } + tt := newTests(c) + + test1 := &Test{ + WebsiteName: "foo", + } + + test2, err := tt.Update(test1) + assert.Nil(test2) + + require.NotNil(err) + assert.IsType(&updateError{}, err) + assert.Equal("Required Data is Missing., hello, world", err.Error()) +} + +func TestTests_Delete_OK(t *testing.T) { + assert := assert.New(t) + require := require.New(t) + + c := &fakeAPIClient{ + fixture: "tests_delete_ok.json", + } + tt := newTests(c) + + err := tt.Delete(1234) + require.Nil(err) + + assert.Equal("/Tests/Details", c.sentRequestPath) + assert.Equal("DELETE", c.sentRequestMethod) + assert.Equal(url.Values{"TestID": {"1234"}}, c.sentRequestValues) +} + +func TestTests_Delete_Error(t *testing.T) { + assert := assert.New(t) + require := require.New(t) + + c := &fakeAPIClient{ + fixture: "tests_delete_error.json", + } + tt := newTests(c) + + err := tt.Delete(1234) + require.NotNil(err) + assert.Equal("this is an error", err.Error()) +} + +func TestTests_Detail_OK(t *testing.T) { + assert := assert.New(t) + require := require.New(t) + + c := &fakeAPIClient{ + fixture: "tests_detail_ok.json", + } + tt := newTests(c) + + test, err := tt.Detail(1234) + require.Nil(err) + + assert.Equal("/Tests/Details", c.sentRequestPath) + assert.Equal("GET", c.sentRequestMethod) + assert.Equal(url.Values{"TestID": {"1234"}}, c.sentRequestValues) + + assert.Equal(test.TestID, 6735) + assert.Equal(test.TestType, "HTTP") + assert.Equal(test.Paused, false) + assert.Equal(test.WebsiteName, "NL") + assert.Equal(test.CustomHeader, `{"some":{"json": ["value"]}}`) + assert.Equal(test.UserAgent, "product/version (comment)") + assert.Equal(test.ContactGroup, []string{"536"}) + assert.Equal(test.Status, "Up") + assert.Equal(test.Uptime, 0.0) + assert.Equal(test.CheckRate, 60) + assert.Equal(test.Timeout, 40) + assert.Equal(test.LogoImage, "") + assert.Equal(test.WebsiteHost, "Various") + assert.Equal(test.FindString, "") + assert.Equal(test.DoNotFind, false) + assert.Equal(test.NodeLocations, []string{"foo", "bar"}) +} + +type fakeAPIClient struct { + sentRequestPath string + sentRequestMethod string + sentRequestValues url.Values + fixture string +} + +func (c *fakeAPIClient) put(path string, v url.Values) (*http.Response, error) { + return c.all("PUT", path, v) +} + +func (c *fakeAPIClient) delete(path string, v url.Values) (*http.Response, error) { + return c.all("DELETE", path, v) +} + +func (c *fakeAPIClient) get(path string, v url.Values) (*http.Response, error) { + return c.all("GET", path, v) +} + +func (c *fakeAPIClient) all(method string, path string, v url.Values) (*http.Response, error) { + c.sentRequestMethod = method + c.sentRequestPath = path + c.sentRequestValues = v + + p := filepath.Join("fixtures", c.fixture) + f, err := os.Open(p) + if err != nil { + log.Fatal(err) + } + + var resp *http.Response + if len(c.sentRequestValues.Get("tags")) > 0 { + var storedResponses []Test + var returnResponses []Test + byteValue, _ := ioutil.ReadAll(f) + json.Unmarshal(byteValue, &storedResponses) + requestedTags := strings.Split(c.sentRequestValues.Get("tags"), ",") + + for _, storedResponse := range storedResponses { + if len(requestedTags) > len(storedResponse.TestTags) { // if we are requesting more tags than whats stored then there are no matches + continue + } + + match := true + for i, tag := range requestedTags { + if tag != storedResponse.TestTags[i] { + match = false + } + } + + if match { // we can add it to the response now + returnResponses = append(returnResponses, storedResponse) + } + } + + if len(returnResponses) == 0 { + return nil, nil + } + + newByteValue, _ := json.Marshal(&returnResponses) + resp = &http.Response{ + Body: ioutil.NopCloser(bytes.NewBuffer(newByteValue)), + } + + } else { + resp = &http.Response{ + Body: f, + } + } + + return resp, nil +} -- cgit v1.2.3 From 82cbfd586d4853b8ef6beafc12c7f2aa015f3c23 Mon Sep 17 00:00:00 2001 From: Alexandre Garand Date: Thu, 27 Jun 2019 12:02:56 +0200 Subject: add ssl tests to terraform provider --- statuscake/provider.go | 1 + statuscake/provider_test.go | 3 + statuscake/resource_statuscakessl.go | 283 ++++++++++++++++++++++++++++++ statuscake/resource_statuscakessl_test.go | 222 +++++++++++++++++++++++ 4 files changed, 509 insertions(+) create mode 100644 statuscake/resource_statuscakessl.go create mode 100644 statuscake/resource_statuscakessl_test.go diff --git a/statuscake/provider.go b/statuscake/provider.go index 93c691f..7f38d7f 100644 --- a/statuscake/provider.go +++ b/statuscake/provider.go @@ -25,6 +25,7 @@ func Provider() terraform.ResourceProvider { ResourcesMap: map[string]*schema.Resource{ "statuscake_test": resourceStatusCakeTest(), + "statuscake_ssl": resourceStatusCakeSsl(), }, ConfigureFunc: providerConfigure, diff --git a/statuscake/provider_test.go b/statuscake/provider_test.go index b1da050..4537960 100644 --- a/statuscake/provider_test.go +++ b/statuscake/provider_test.go @@ -38,4 +38,7 @@ func testAccPreCheck(t *testing.T) { if v := os.Getenv("STATUSCAKE_TEST_CONTACT_GROUP_ID"); v == "" { t.Fatal("STATUSCAKE_TEST_CONTACT_GROUP_ID must be set for acceptance tests") } + if v := os.Getenv("STATUSCAKE_SSL_CONTACT_GROUP_ID"); v == "" { + t.Fatal("STATUSCAKE_SSL_CONTACT_GROUP_ID must be set for acceptance tests") + } } diff --git a/statuscake/resource_statuscakessl.go b/statuscake/resource_statuscakessl.go new file mode 100644 index 0000000..3dba5bd --- /dev/null +++ b/statuscake/resource_statuscakessl.go @@ -0,0 +1,283 @@ +package statuscake + +import ( + "fmt" + "strconv" + + "log" + + "github.com/DreamItGetIT/statuscake" + "github.com/hashicorp/terraform/helper/schema" +) + +func resourceStatusCakeSsl() *schema.Resource { + return &schema.Resource{ + Create: CreateSsl, + Update: UpdateSsl, + Delete: DeleteSsl, + Read: ReadSsl, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, + + Schema: map[string]*schema.Schema{ + "ssl_id": { + Type: schema.TypeString, + Computed: true, + }, + + "domain": { + Type: schema.TypeString, + Required: true, + }, + + "contact_groups": { + Type: schema.TypeList, + Elem: &schema.Schema{Type: schema.TypeString}, + Computed: true, + }, + + "contact_groups_c": { + Type: schema.TypeString, + Required: true, + }, + + "checkrate": { + Type: schema.TypeInt, + Required: true, + }, + + "alert_at": { + Type: schema.TypeString, + Required: true, + }, + + "alert_reminder": { + Type: schema.TypeBool, + Required: true, + }, + + "alert_expiry": { + Type: schema.TypeBool, + Required: true, + }, + + "alert_broken": { + Type: schema.TypeBool, + Required: true, + }, + + "alert_mixed": { + Type: schema.TypeBool, + Required: true, + }, + + "paused": { + Type: schema.TypeBool, + Computed: true, + }, + + "issuer_cn": { + Type: schema.TypeString, + Computed: true, + }, + + "cert_score": { + Type: schema.TypeString, + Computed: true, + }, + + "cipher_score": { + Type: schema.TypeString, + Computed: true, + }, + + "cert_status": { + Type: schema.TypeString, + Computed: true, + }, + + "cipher": { + Type: schema.TypeString, + Computed: true, + }, + + "valid_from_utc": { + Type: schema.TypeString, + Computed: true, + }, + + "valid_until_utc": { + Type: schema.TypeString, + Computed: true, + }, + + "mixed_content": { + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeMap, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + Computed: true, + }, + + "flags": { + Type: schema.TypeMap, + Elem: &schema.Schema{Type: schema.TypeBool}, + Computed: true, + }, + + "last_reminder": { + Type: schema.TypeInt, + Computed: true, + }, + + "last_updated_utc": { + Type: schema.TypeString, + Computed: true, + }, + }, + } +} + +func CreateSsl(d *schema.ResourceData, meta interface{}) error { + client := meta.(*statuscake.Client) + + newSsl := &statuscake.PartialSsl{ + Domain: d.Get("domain").(string), + Checkrate: strconv.Itoa(d.Get("checkrate").(int)), + ContactGroupsC: d.Get("contact_groups_c").(string), + AlertReminder: d.Get("alert_reminder").(bool), + AlertExpiry: d.Get("alert_expiry").(bool), + AlertBroken: d.Get("alert_broken").(bool), + AlertMixed: d.Get("alert_mixed").(bool), + AlertAt: d.Get("alert_at").(string), + } + + log.Printf("[DEBUG] Creating new StatusCake Ssl: %s", d.Get("domain").(string)) + + response, err := statuscake.NewSsls(client).Create(newSsl) + if err != nil { + fmt.Println(newSsl) + fmt.Println(client) + return fmt.Errorf("Error creating StatusCake Ssl: %s", err.Error()) + } + + d.Set("ssl_id", response.ID) + d.Set("contact_groups", response.ContactGroups) + d.Set("paused", response.Paused) + d.Set("issuer_cn", response.IssuerCn) + d.Set("cert_score", response.CertScore) + d.Set("cipher_score", response.CipherScore) + d.Set("cert_status", response.CertStatus) + d.Set("cipher", response.Cipher) + d.Set("valid_from_utc", response.ValidFromUtc) + d.Set("valid_until_utc", response.ValidUntilUtc) + d.Set("mixed_content", response.MixedContent) + d.Set("flags", response.Flags) + d.Set("last_reminder", response.LastReminder) + d.Set("last_updated_utc", response.LastUpdatedUtc) + d.SetId(response.ID) + + return ReadSsl(d, meta) +} + +func UpdateSsl(d *schema.ResourceData, meta interface{}) error { + client := meta.(*statuscake.Client) + + params := getStatusCakeSslInput(d) + + log.Printf("[DEBUG] StatusCake Ssl Update for %s", d.Id()) + _, err := statuscake.NewSsls(client).Update(params) + if err != nil { + return fmt.Errorf("Error Updating StatusCake Ssl: %s", err.Error()) + } + return nil +} + +func DeleteSsl(d *schema.ResourceData, meta interface{}) error { + client := meta.(*statuscake.Client) + + log.Printf("[DEBUG] Deleting StatusCake Ssl: %s", d.Id()) + err := statuscake.NewSsls(client).Delete(d.Id()) + + return err +} + +func ReadSsl(d *schema.ResourceData, meta interface{}) error { + client := meta.(*statuscake.Client) + + response, err := statuscake.NewSsls(client).Detail(d.Id()) + if err != nil { + return fmt.Errorf("Error Getting StatusCake Ssl Details for %s: Error: %s", d.Id(), err) + } + d.Set("domain", response.Domain) + d.Set("checkrate", response.Checkrate) + d.Set("contact_groups_c", response.ContactGroupsC) + d.Set("alert_reminder", response.AlertReminder) + d.Set("alert_expiry", response.AlertExpiry) + d.Set("alert_broken", response.AlertBroken) + d.Set("alert_mixed", response.AlertMixed) + d.Set("alert_at", response.AlertAt) + d.Set("ssl_id", response.ID) + d.Set("contact_groups", response.ContactGroups) + d.Set("paused", response.Paused) + d.Set("issuer_cn", response.IssuerCn) + d.Set("cert_score", response.CertScore) + d.Set("cipher_score", response.CipherScore) + d.Set("cert_status", response.CertStatus) + d.Set("cipher", response.Cipher) + d.Set("valid_from_utc", response.ValidFromUtc) + d.Set("valid_until_utc", response.ValidUntilUtc) + d.Set("mixed_content", response.MixedContent) + d.Set("flags", response.Flags) + d.Set("last_reminder", response.LastReminder) + d.Set("last_updated_utc", response.LastUpdatedUtc) + d.SetId(response.ID) + + return nil +} + +func getStatusCakeSslInput(d *schema.ResourceData) *statuscake.PartialSsl { + sslId, parseErr := strconv.Atoi(d.Id()) + if parseErr != nil { + log.Printf("[DEBUG] Error Parsing StatusCake Id: %s", d.Id()) + } + ssl := &statuscake.PartialSsl{ + ID: sslId, + } + + if v, ok := d.GetOk("domain"); ok { + ssl.Domain = v.(string) + } + + if v, ok := d.GetOk("checkrate"); ok { + ssl.Checkrate = strconv.Itoa(v.(int)) + } + + if v, ok := d.GetOk("contact_groups_c"); ok { + ssl.ContactGroupsC = v.(string) + } + + if v, ok := d.GetOk("alert_reminder"); ok { + ssl.AlertReminder = v.(bool) + } + + if v, ok := d.GetOk("alert_expiry"); ok { + ssl.AlertExpiry = v.(bool) + } + + if v, ok := d.GetOk("alert_broken"); ok { + ssl.AlertBroken = v.(bool) + } + + if v, ok := d.GetOk("alert_mixed"); ok { + ssl.AlertMixed = v.(bool) + } + + if v, ok := d.GetOk("alert_at"); ok { + ssl.AlertAt = v.(string) + } + + return ssl +} diff --git a/statuscake/resource_statuscakessl_test.go b/statuscake/resource_statuscakessl_test.go new file mode 100644 index 0000000..a9a83da --- /dev/null +++ b/statuscake/resource_statuscakessl_test.go @@ -0,0 +1,222 @@ +package statuscake + +import ( + "fmt" + "os" + "strconv" + "testing" + + "github.com/DreamItGetIT/statuscake" + "github.com/hashicorp/terraform/helper/resource" + "github.com/hashicorp/terraform/terraform" +) + +func TestAccStatusCakeSsl_basic(t *testing.T) { + var ssl statuscake.Ssl + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccSslCheckDestroy(&ssl), + Steps: []resource.TestStep{ + { + Config: interpolateTerraformTemplateSsl(testAccSslConfig_basic), + Check: resource.ComposeTestCheckFunc( + testAccSslCheckExists("statuscake_ssl.exemple", &ssl), + testAccSslCheckAttributes("statuscake_ssl.exemple", &ssl), + ), + }, + }, + }) +} + +func TestAccStatusCakeSsl_withUpdate(t *testing.T) { + var ssl statuscake.Ssl + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccSslCheckDestroy(&ssl), + Steps: []resource.TestStep{ + { + Config: interpolateTerraformTemplateSsl(testAccSslConfig_basic), + Check: resource.ComposeTestCheckFunc( + testAccSslCheckExists("statuscake_ssl.exemple", &ssl), + testAccSslCheckAttributes("statuscake_ssl.exemple", &ssl), + ), + }, + + { + Config: testAccSslConfig_update, + Check: resource.ComposeTestCheckFunc( + testAccSslCheckExists("statuscake_ssl.exemple", &ssl), + testAccSslCheckAttributes("statuscake_ssl.exemple", &ssl), + resource.TestCheckResourceAttr("statuscake_ssl.exemple", "check_rate", "86400"), + resource.TestCheckResourceAttr("statuscake_ssl.exemple", "domain", "https://www.exemple.com"), + resource.TestCheckResourceAttr("statuscake_ssl.exemple", "contact_group_c", ""), + resource.TestCheckResourceAttr("statuscake_ssl.exemple", "alert_at", "18,8,2019"), + resource.TestCheckResourceAttr("statuscake_ssl.exemple", "alert_reminder", "false"), + resource.TestCheckResourceAttr("statuscake_ssl.exemple", "alert_expiry", "false"), + resource.TestCheckResourceAttr("statuscake_ssl.exemple", "alert_broken", "true"), + resource.TestCheckResourceAttr("statuscake_ssl.exemple", "alert_mixed", "false"), + ), + }, + }, + }) +} + +func testAccSslCheckExists(rn string, ssl *statuscake.Ssl) resource.TestCheckFunc { + return func(s *terraform.State) error { + rs, ok := s.RootModule().Resources[rn] + if !ok { + return fmt.Errorf("resource not found: %s", rn) + } + + if rs.Primary.ID == "" { + return fmt.Errorf("SslID not set") + } + + client := testAccProvider.Meta().(*statuscake.Client) + sslId := rs.Primary.ID + + gotSsl, err := statuscake.NewSsls(client).Detail(sslId) + if err != nil { + return fmt.Errorf("error getting ssl: %s", err) + } + + *ssl = *gotSsl + + return nil + } +} + +func testAccSslCheckAttributes(rn string, ssl *statuscake.Ssl) resource.TestCheckFunc { + return func(s *terraform.State) error { + attrs := s.RootModule().Resources[rn].Primary.Attributes + + check := func(key, stateValue, sslValue string) error { + if sslValue != stateValue { + return fmt.Errorf("different values for %s in state (%s) and in statuscake (%s)", + key, stateValue, sslValue) + } + return nil + } + + for key, value := range attrs { + var err error + + switch key { + case "domain": + err = check(key, value, ssl.Domain) + case "contact_groups_c": + err = check(key, value, ssl.ContactGroupsC) + case "checkrate": + err = check(key, value, strconv.Itoa(ssl.Checkrate)) + case "alert_at": + err = check(key, value, ssl.AlertAt) + case "alert_reminder": + err = check(key, value, strconv.FormatBool(ssl.AlertReminder)) + case "alert_expiry": + err = check(key, value, strconv.FormatBool(ssl.AlertExpiry)) + case "alert_broken": + err = check(key, value, strconv.FormatBool(ssl.AlertBroken)) + case "alert_mixed": + err = check(key, value, strconv.FormatBool(ssl.AlertMixed)) + case "paused": + err = check(key, value, strconv.FormatBool(ssl.Paused)) + case "issuer_cn": + err = check(key, value, ssl.IssuerCn) + case "contact_groups": + for _, tv := range ssl.ContactGroups { + err = check(key, value, tv) + if err != nil { + return err + } + } + case "cert_score": + err = check(key, value, ssl.CertScore) + case "cert_status": + err = check(key, value, ssl.CertStatus) + case "cipher": + err = check(key, value, ssl.Cipher) + case "valid_from_utc": + err = check(key, value, ssl.ValidFromUtc) + case "valid_until_utc": + err = check(key, value, ssl.ValidUntilUtc) + case "last_reminder": + err = check(key, value, strconv.Itoa(ssl.LastReminder)) + case "last_updated_utc": + err = check(key, value, ssl.LastUpdatedUtc) + case "flags": + for _, tv := range ssl.Flags { + err = check(key, value, strconv.FormatBool(tv)) + if err != nil { + return err + } + } + + case "mixed_content": + for _, tv := range ssl.MixedContent { + for _, tv2 := range tv { + err = check(key, value, tv2) + if err != nil { + return err + } + } + } + } + if err != nil { + return err + } + } + return nil + } +} + +func testAccSslCheckDestroy(ssl *statuscake.Ssl) resource.TestCheckFunc { + return func(s *terraform.State) error { + client := testAccProvider.Meta().(*statuscake.Client) + _, err := statuscake.NewSsls(client).Detail(ssl.ID) + if err == nil { + return fmt.Errorf("ssl still exists") + } + + return nil + } +} + +func interpolateTerraformTemplateSsl(template string) string { + sslContactGroupId := "43402" + + if v := os.Getenv("STATUSCAKE_SSL_CONTACT_GROUP_ID"); v != "" { + sslContactGroupId = v + } + + return fmt.Sprintf(template, sslContactGroupId) +} + +const testAccSslConfig_basic = ` +resource "statuscake_ssl" "exemple" { + domain = "https://www.exemple.com" + contact_groups_c = "%s" + checkrate = 3600 + alert_at = "18,7,2019" + alert_reminder = true + alert_expiry = true + alert_broken = false + alert_mixed = true +} +` + +const testAccSslConfig_update = ` +resource "statuscake_ssl" "exemple" { + domain = "https://www.exemple.com" + contact_groups_c = "" + checkrate = 86400 + alert_at = "18,8,2019" + alert_reminder = false + alert_expiry = false + alert_broken = true + alert_mixed = false +} +` -- cgit v1.2.3 From 03f6b10bbcb52b8096abab2b0f3aee7219a3938d Mon Sep 17 00:00:00 2001 From: Alexandre Garand Date: Thu, 27 Jun 2019 14:01:18 +0200 Subject: fix test --- statuscake/resource_statuscakessl_test.go | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/statuscake/resource_statuscakessl_test.go b/statuscake/resource_statuscakessl_test.go index a9a83da..fa48bad 100644 --- a/statuscake/resource_statuscakessl_test.go +++ b/statuscake/resource_statuscakessl_test.go @@ -2,13 +2,12 @@ package statuscake import ( "fmt" - "os" - "strconv" - "testing" - "github.com/DreamItGetIT/statuscake" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/terraform" + "os" + "strconv" + "testing" ) func TestAccStatusCakeSsl_basic(t *testing.T) { @@ -51,10 +50,10 @@ func TestAccStatusCakeSsl_withUpdate(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccSslCheckExists("statuscake_ssl.exemple", &ssl), testAccSslCheckAttributes("statuscake_ssl.exemple", &ssl), - resource.TestCheckResourceAttr("statuscake_ssl.exemple", "check_rate", "86400"), + resource.TestCheckResourceAttr("statuscake_ssl.exemple", "checkrate", "86400"), resource.TestCheckResourceAttr("statuscake_ssl.exemple", "domain", "https://www.exemple.com"), - resource.TestCheckResourceAttr("statuscake_ssl.exemple", "contact_group_c", ""), - resource.TestCheckResourceAttr("statuscake_ssl.exemple", "alert_at", "18,8,2019"), + resource.TestCheckResourceAttr("statuscake_ssl.exemple", "contact_groups_c", ""), + resource.TestCheckResourceAttr("statuscake_ssl.exemple", "alert_at", "18,81,2019"), resource.TestCheckResourceAttr("statuscake_ssl.exemple", "alert_reminder", "false"), resource.TestCheckResourceAttr("statuscake_ssl.exemple", "alert_expiry", "false"), resource.TestCheckResourceAttr("statuscake_ssl.exemple", "alert_broken", "true"), @@ -83,7 +82,7 @@ func testAccSslCheckExists(rn string, ssl *statuscake.Ssl) resource.TestCheckFun if err != nil { return fmt.Errorf("error getting ssl: %s", err) } - + gotSsl.LastUpdatedUtc = "0000-00-00 00:00:00" // quick fix to avoid issue with it because the state is updated before the value change but it is changed when gotSsl is created *ssl = *gotSsl return nil @@ -122,6 +121,8 @@ func testAccSslCheckAttributes(rn string, ssl *statuscake.Ssl) resource.TestChec err = check(key, value, strconv.FormatBool(ssl.AlertBroken)) case "alert_mixed": err = check(key, value, strconv.FormatBool(ssl.AlertMixed)) + case "last_updated_utc": + err = check(key, value, ssl.LastUpdatedUtc) case "paused": err = check(key, value, strconv.FormatBool(ssl.Paused)) case "issuer_cn": @@ -145,8 +146,6 @@ func testAccSslCheckAttributes(rn string, ssl *statuscake.Ssl) resource.TestChec err = check(key, value, ssl.ValidUntilUtc) case "last_reminder": err = check(key, value, strconv.Itoa(ssl.LastReminder)) - case "last_updated_utc": - err = check(key, value, ssl.LastUpdatedUtc) case "flags": for _, tv := range ssl.Flags { err = check(key, value, strconv.FormatBool(tv)) @@ -191,6 +190,9 @@ func interpolateTerraformTemplateSsl(template string) string { if v := os.Getenv("STATUSCAKE_SSL_CONTACT_GROUP_ID"); v != "" { sslContactGroupId = v } + if sslContactGroupId == "-1" { + sslContactGroupId = "" + } return fmt.Sprintf(template, sslContactGroupId) } @@ -200,7 +202,7 @@ resource "statuscake_ssl" "exemple" { domain = "https://www.exemple.com" contact_groups_c = "%s" checkrate = 3600 - alert_at = "18,7,2019" + alert_at = "18,71,2019" alert_reminder = true alert_expiry = true alert_broken = false @@ -213,7 +215,7 @@ resource "statuscake_ssl" "exemple" { domain = "https://www.exemple.com" contact_groups_c = "" checkrate = 86400 - alert_at = "18,8,2019" + alert_at = "18,81,2019" alert_reminder = false alert_expiry = false alert_broken = true -- cgit v1.2.3 From 1a77fed162947c5e49268edc216e080a35ef42a5 Mon Sep 17 00:00:00 2001 From: Alexandre Garand Date: Thu, 27 Jun 2019 14:25:03 +0200 Subject: add go-querystring --- vendor/github.com/google/go-querystring/.gitignore | 1 + .../github.com/google/go-querystring/.travis.yml | 5 + .../google/go-querystring/CONTRIBUTING.md | 67 +++++ vendor/github.com/google/go-querystring/LICENSE | 27 ++ vendor/github.com/google/go-querystring/README.md | 37 +++ vendor/github.com/google/go-querystring/go.mod | 1 + .../google/go-querystring/query/encode.go | 320 ++++++++++++++++++++ .../google/go-querystring/query/encode_test.go | 328 +++++++++++++++++++++ 8 files changed, 786 insertions(+) create mode 100644 vendor/github.com/google/go-querystring/.gitignore create mode 100644 vendor/github.com/google/go-querystring/.travis.yml create mode 100644 vendor/github.com/google/go-querystring/CONTRIBUTING.md create mode 100644 vendor/github.com/google/go-querystring/LICENSE create mode 100644 vendor/github.com/google/go-querystring/README.md create mode 100644 vendor/github.com/google/go-querystring/go.mod create mode 100644 vendor/github.com/google/go-querystring/query/encode.go create mode 100644 vendor/github.com/google/go-querystring/query/encode_test.go diff --git a/vendor/github.com/google/go-querystring/.gitignore b/vendor/github.com/google/go-querystring/.gitignore new file mode 100644 index 0000000..9ed3b07 --- /dev/null +++ b/vendor/github.com/google/go-querystring/.gitignore @@ -0,0 +1 @@ +*.test diff --git a/vendor/github.com/google/go-querystring/.travis.yml b/vendor/github.com/google/go-querystring/.travis.yml new file mode 100644 index 0000000..881d087 --- /dev/null +++ b/vendor/github.com/google/go-querystring/.travis.yml @@ -0,0 +1,5 @@ +language: go + +go: + - 1.x + - 1.11.x diff --git a/vendor/github.com/google/go-querystring/CONTRIBUTING.md b/vendor/github.com/google/go-querystring/CONTRIBUTING.md new file mode 100644 index 0000000..51cf5cd --- /dev/null +++ b/vendor/github.com/google/go-querystring/CONTRIBUTING.md @@ -0,0 +1,67 @@ +# How to contribute # + +We'd love to accept your patches and contributions to this project. There are +a just a few small guidelines you need to follow. + + +## Contributor License Agreement ## + +Contributions to any Google project must be accompanied by a Contributor +License Agreement. This is not a copyright **assignment**, it simply gives +Google permission to use and redistribute your contributions as part of the +project. + + * If you are an individual writing original source code and you're sure you + own the intellectual property, then you'll need to sign an [individual + CLA][]. + + * If you work for a company that wants to allow you to contribute your work, + then you'll need to sign a [corporate CLA][]. + +You generally only need to submit a CLA once, so if you've already submitted +one (even if it was for a different project), you probably don't need to do it +again. + +[individual CLA]: https://developers.google.com/open-source/cla/individual +[corporate CLA]: https://developers.google.com/open-source/cla/corporate + + +## Submitting a patch ## + + 1. It's generally best to start by opening a new issue describing the bug or + feature you're intending to fix. Even if you think it's relatively minor, + it's helpful to know what people are working on. Mention in the initial + issue that you are planning to work on that bug or feature so that it can + be assigned to you. + + 1. Follow the normal process of [forking][] the project, and setup a new + branch to work in. It's important that each group of changes be done in + separate branches in order to ensure that a pull request only includes the + commits related to that bug or feature. + + 1. Go makes it very simple to ensure properly formatted code, so always run + `go fmt` on your code before committing it. You should also run + [golint][] over your code. As noted in the [golint readme][], it's not + strictly necessary that your code be completely "lint-free", but this will + help you find common style issues. + + 1. Any significant changes should almost always be accompanied by tests. The + project already has good test coverage, so look at some of the existing + tests if you're unsure how to go about it. [gocov][] and [gocov-html][] + are invaluable tools for seeing which parts of your code aren't being + exercised by your tests. + + 1. Do your best to have [well-formed commit messages][] for each change. + This provides consistency throughout the project, and ensures that commit + messages are able to be formatted properly by various git tools. + + 1. Finally, push the commits to your fork and submit a [pull request][]. + +[forking]: https://help.github.com/articles/fork-a-repo +[golint]: https://github.com/golang/lint +[golint readme]: https://github.com/golang/lint/blob/master/README +[gocov]: https://github.com/axw/gocov +[gocov-html]: https://github.com/matm/gocov-html +[well-formed commit messages]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html +[squash]: http://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits +[pull request]: https://help.github.com/articles/creating-a-pull-request diff --git a/vendor/github.com/google/go-querystring/LICENSE b/vendor/github.com/google/go-querystring/LICENSE new file mode 100644 index 0000000..ae121a1 --- /dev/null +++ b/vendor/github.com/google/go-querystring/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2013 Google. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/github.com/google/go-querystring/README.md b/vendor/github.com/google/go-querystring/README.md new file mode 100644 index 0000000..0e600be --- /dev/null +++ b/vendor/github.com/google/go-querystring/README.md @@ -0,0 +1,37 @@ +# go-querystring # + +[![GoDoc](https://godoc.org/github.com/google/go-querystring/query?status.svg)](https://godoc.org/github.com/google/go-querystring/query) [![Build Status](https://travis-ci.org/google/go-querystring.svg?branch=master)](https://travis-ci.org/google/go-querystring) + +go-querystring is Go library for encoding structs into URL query parameters. + +## Usage ## + +```go +import "github.com/google/go-querystring/query" +``` + +go-querystring is designed to assist in scenarios where you want to construct a +URL using a struct that represents the URL query parameters. You might do this +to enforce the type safety of your parameters, for example, as is done in the +[go-github][] library. + +The query package exports a single `Values()` function. A simple example: + +```go +type Options struct { + Query string `url:"q"` + ShowAll bool `url:"all"` + Page int `url:"page"` +} + +opt := Options{ "foo", true, 2 } +v, _ := query.Values(opt) +fmt.Print(v.Encode()) // will output: "q=foo&all=true&page=2" +``` + +[go-github]: https://github.com/google/go-github/commit/994f6f8405f052a117d2d0b500054341048fbb08 + +## License ## + +This library is distributed under the BSD-style license found in the [LICENSE](./LICENSE) +file. diff --git a/vendor/github.com/google/go-querystring/go.mod b/vendor/github.com/google/go-querystring/go.mod new file mode 100644 index 0000000..45dca2d --- /dev/null +++ b/vendor/github.com/google/go-querystring/go.mod @@ -0,0 +1 @@ +module github.com/google/go-querystring diff --git a/vendor/github.com/google/go-querystring/query/encode.go b/vendor/github.com/google/go-querystring/query/encode.go new file mode 100644 index 0000000..37080b1 --- /dev/null +++ b/vendor/github.com/google/go-querystring/query/encode.go @@ -0,0 +1,320 @@ +// Copyright 2013 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package query implements encoding of structs into URL query parameters. +// +// As a simple example: +// +// type Options struct { +// Query string `url:"q"` +// ShowAll bool `url:"all"` +// Page int `url:"page"` +// } +// +// opt := Options{ "foo", true, 2 } +// v, _ := query.Values(opt) +// fmt.Print(v.Encode()) // will output: "q=foo&all=true&page=2" +// +// The exact mapping between Go values and url.Values is described in the +// documentation for the Values() function. +package query + +import ( + "bytes" + "fmt" + "net/url" + "reflect" + "strconv" + "strings" + "time" +) + +var timeType = reflect.TypeOf(time.Time{}) + +var encoderType = reflect.TypeOf(new(Encoder)).Elem() + +// Encoder is an interface implemented by any type that wishes to encode +// itself into URL values in a non-standard way. +type Encoder interface { + EncodeValues(key string, v *url.Values) error +} + +// Values returns the url.Values encoding of v. +// +// Values expects to be passed a struct, and traverses it recursively using the +// following encoding rules. +// +// Each exported struct field is encoded as a URL parameter unless +// +// - the field's tag is "-", or +// - the field is empty and its tag specifies the "omitempty" option +// +// The empty values are false, 0, any nil pointer or interface value, any array +// slice, map, or string of length zero, and any time.Time that returns true +// for IsZero(). +// +// The URL parameter name defaults to the struct field name but can be +// specified in the struct field's tag value. The "url" key in the struct +// field's tag value is the key name, followed by an optional comma and +// options. For example: +// +// // Field is ignored by this package. +// Field int `url:"-"` +// +// // Field appears as URL parameter "myName". +// Field int `url:"myName"` +// +// // Field appears as URL parameter "myName" and the field is omitted if +// // its value is empty +// Field int `url:"myName,omitempty"` +// +// // Field appears as URL parameter "Field" (the default), but the field +// // is skipped if empty. Note the leading comma. +// Field int `url:",omitempty"` +// +// For encoding individual field values, the following type-dependent rules +// apply: +// +// Boolean values default to encoding as the strings "true" or "false". +// Including the "int" option signals that the field should be encoded as the +// strings "1" or "0". +// +// time.Time values default to encoding as RFC3339 timestamps. Including the +// "unix" option signals that the field should be encoded as a Unix time (see +// time.Unix()) +// +// Slice and Array values default to encoding as multiple URL values of the +// same name. Including the "comma" option signals that the field should be +// encoded as a single comma-delimited value. Including the "space" option +// similarly encodes the value as a single space-delimited string. Including +// the "semicolon" option will encode the value as a semicolon-delimited string. +// Including the "brackets" option signals that the multiple URL values should +// have "[]" appended to the value name. "numbered" will append a number to +// the end of each incidence of the value name, example: +// name0=value0&name1=value1, etc. +// +// Anonymous struct fields are usually encoded as if their inner exported +// fields were fields in the outer struct, subject to the standard Go +// visibility rules. An anonymous struct field with a name given in its URL +// tag is treated as having that name, rather than being anonymous. +// +// Non-nil pointer values are encoded as the value pointed to. +// +// Nested structs are encoded including parent fields in value names for +// scoping. e.g: +// +// "user[name]=acme&user[addr][postcode]=1234&user[addr][city]=SFO" +// +// All other values are encoded using their default string representation. +// +// Multiple fields that encode to the same URL parameter name will be included +// as multiple URL values of the same name. +func Values(v interface{}) (url.Values, error) { + values := make(url.Values) + val := reflect.ValueOf(v) + for val.Kind() == reflect.Ptr { + if val.IsNil() { + return values, nil + } + val = val.Elem() + } + + if v == nil { + return values, nil + } + + if val.Kind() != reflect.Struct { + return nil, fmt.Errorf("query: Values() expects struct input. Got %v", val.Kind()) + } + + err := reflectValue(values, val, "") + return values, err +} + +// reflectValue populates the values parameter from the struct fields in val. +// Embedded structs are followed recursively (using the rules defined in the +// Values function documentation) breadth-first. +func reflectValue(values url.Values, val reflect.Value, scope string) error { + var embedded []reflect.Value + + typ := val.Type() + for i := 0; i < typ.NumField(); i++ { + sf := typ.Field(i) + if sf.PkgPath != "" && !sf.Anonymous { // unexported + continue + } + + sv := val.Field(i) + tag := sf.Tag.Get("url") + if tag == "-" { + continue + } + name, opts := parseTag(tag) + if name == "" { + if sf.Anonymous && sv.Kind() == reflect.Struct { + // save embedded struct for later processing + embedded = append(embedded, sv) + continue + } + + name = sf.Name + } + + if scope != "" { + name = scope + "[" + name + "]" + } + + if opts.Contains("omitempty") && isEmptyValue(sv) { + continue + } + + if sv.Type().Implements(encoderType) { + if !reflect.Indirect(sv).IsValid() { + sv = reflect.New(sv.Type().Elem()) + } + + m := sv.Interface().(Encoder) + if err := m.EncodeValues(name, &values); err != nil { + return err + } + continue + } + + if sv.Kind() == reflect.Slice || sv.Kind() == reflect.Array { + var del byte + if opts.Contains("comma") { + del = ',' + } else if opts.Contains("space") { + del = ' ' + } else if opts.Contains("semicolon") { + del = ';' + } else if opts.Contains("brackets") { + name = name + "[]" + } + + if del != 0 { + s := new(bytes.Buffer) + first := true + for i := 0; i < sv.Len(); i++ { + if first { + first = false + } else { + s.WriteByte(del) + } + s.WriteString(valueString(sv.Index(i), opts)) + } + values.Add(name, s.String()) + } else { + for i := 0; i < sv.Len(); i++ { + k := name + if opts.Contains("numbered") { + k = fmt.Sprintf("%s%d", name, i) + } + values.Add(k, valueString(sv.Index(i), opts)) + } + } + continue + } + + for sv.Kind() == reflect.Ptr { + if sv.IsNil() { + break + } + sv = sv.Elem() + } + + if sv.Type() == timeType { + values.Add(name, valueString(sv, opts)) + continue + } + + if sv.Kind() == reflect.Struct { + reflectValue(values, sv, name) + continue + } + + values.Add(name, valueString(sv, opts)) + } + + for _, f := range embedded { + if err := reflectValue(values, f, scope); err != nil { + return err + } + } + + return nil +} + +// valueString returns the string representation of a value. +func valueString(v reflect.Value, opts tagOptions) string { + for v.Kind() == reflect.Ptr { + if v.IsNil() { + return "" + } + v = v.Elem() + } + + if v.Kind() == reflect.Bool && opts.Contains("int") { + if v.Bool() { + return "1" + } + return "0" + } + + if v.Type() == timeType { + t := v.Interface().(time.Time) + if opts.Contains("unix") { + return strconv.FormatInt(t.Unix(), 10) + } + return t.Format(time.RFC3339) + } + + return fmt.Sprint(v.Interface()) +} + +// isEmptyValue checks if a value should be considered empty for the purposes +// of omitting fields with the "omitempty" option. +func isEmptyValue(v reflect.Value) bool { + switch v.Kind() { + case reflect.Array, reflect.Map, reflect.Slice, reflect.String: + return v.Len() == 0 + case reflect.Bool: + return !v.Bool() + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + return v.Int() == 0 + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: + return v.Uint() == 0 + case reflect.Float32, reflect.Float64: + return v.Float() == 0 + case reflect.Interface, reflect.Ptr: + return v.IsNil() + } + + if v.Type() == timeType { + return v.Interface().(time.Time).IsZero() + } + + return false +} + +// tagOptions is the string following a comma in a struct field's "url" tag, or +// the empty string. It does not include the leading comma. +type tagOptions []string + +// parseTag splits a struct field's url tag into its name and comma-separated +// options. +func parseTag(tag string) (string, tagOptions) { + s := strings.Split(tag, ",") + return s[0], s[1:] +} + +// Contains checks whether the tagOptions contains the specified option. +func (o tagOptions) Contains(option string) bool { + for _, s := range o { + if s == option { + return true + } + } + return false +} diff --git a/vendor/github.com/google/go-querystring/query/encode_test.go b/vendor/github.com/google/go-querystring/query/encode_test.go new file mode 100644 index 0000000..77bea5a --- /dev/null +++ b/vendor/github.com/google/go-querystring/query/encode_test.go @@ -0,0 +1,328 @@ +// Copyright 2013 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package query + +import ( + "fmt" + "net/url" + "reflect" + "testing" + "time" +) + +type Nested struct { + A SubNested `url:"a"` + B *SubNested `url:"b"` + Ptr *SubNested `url:"ptr,omitempty"` +} + +type SubNested struct { + Value string `url:"value"` +} + +func TestValues_types(t *testing.T) { + str := "string" + strPtr := &str + timeVal := time.Date(2000, 1, 1, 12, 34, 56, 0, time.UTC) + + tests := []struct { + in interface{} + want url.Values + }{ + { + // basic primitives + struct { + A string + B int + C uint + D float32 + E bool + }{}, + url.Values{ + "A": {""}, + "B": {"0"}, + "C": {"0"}, + "D": {"0"}, + "E": {"false"}, + }, + }, + { + // pointers + struct { + A *string + B *int + C **string + D *time.Time + }{ + A: strPtr, + C: &strPtr, + D: &timeVal, + }, + url.Values{ + "A": {str}, + "B": {""}, + "C": {str}, + "D": {"2000-01-01T12:34:56Z"}, + }, + }, + { + // slices and arrays + struct { + A []string + B []string `url:",comma"` + C []string `url:",space"` + D [2]string + E [2]string `url:",comma"` + F [2]string `url:",space"` + G []*string `url:",space"` + H []bool `url:",int,space"` + I []string `url:",brackets"` + J []string `url:",semicolon"` + K []string `url:",numbered"` + }{ + A: []string{"a", "b"}, + B: []string{"a", "b"}, + C: []string{"a", "b"}, + D: [2]string{"a", "b"}, + E: [2]string{"a", "b"}, + F: [2]string{"a", "b"}, + G: []*string{&str, &str}, + H: []bool{true, false}, + I: []string{"a", "b"}, + J: []string{"a", "b"}, + K: []string{"a", "b"}, + }, + url.Values{ + "A": {"a", "b"}, + "B": {"a,b"}, + "C": {"a b"}, + "D": {"a", "b"}, + "E": {"a,b"}, + "F": {"a b"}, + "G": {"string string"}, + "H": {"1 0"}, + "I[]": {"a", "b"}, + "J": {"a;b"}, + "K0": {"a"}, + "K1": {"b"}, + }, + }, + { + // other types + struct { + A time.Time + B time.Time `url:",unix"` + C bool `url:",int"` + D bool `url:",int"` + }{ + A: time.Date(2000, 1, 1, 12, 34, 56, 0, time.UTC), + B: time.Date(2000, 1, 1, 12, 34, 56, 0, time.UTC), + C: true, + D: false, + }, + url.Values{ + "A": {"2000-01-01T12:34:56Z"}, + "B": {"946730096"}, + "C": {"1"}, + "D": {"0"}, + }, + }, + { + struct { + Nest Nested `url:"nest"` + }{ + Nested{ + A: SubNested{ + Value: "that", + }, + }, + }, + url.Values{ + "nest[a][value]": {"that"}, + "nest[b]": {""}, + }, + }, + { + struct { + Nest Nested `url:"nest"` + }{ + Nested{ + Ptr: &SubNested{ + Value: "that", + }, + }, + }, + url.Values{ + "nest[a][value]": {""}, + "nest[b]": {""}, + "nest[ptr][value]": {"that"}, + }, + }, + { + nil, + url.Values{}, + }, + } + + for i, tt := range tests { + v, err := Values(tt.in) + if err != nil { + t.Errorf("%d. Values(%q) returned error: %v", i, tt.in, err) + } + + if !reflect.DeepEqual(tt.want, v) { + t.Errorf("%d. Values(%q) returned %v, want %v", i, tt.in, v, tt.want) + } + } +} + +func TestValues_omitEmpty(t *testing.T) { + str := "" + s := struct { + a string + A string + B string `url:",omitempty"` + C string `url:"-"` + D string `url:"omitempty"` // actually named omitempty, not an option + E *string `url:",omitempty"` + }{E: &str} + + v, err := Values(s) + if err != nil { + t.Errorf("Values(%v) returned error: %v", s, err) + } + + want := url.Values{ + "A": {""}, + "omitempty": {""}, + "E": {""}, // E is included because the pointer is not empty, even though the string being pointed to is + } + if !reflect.DeepEqual(want, v) { + t.Errorf("Values(%v) returned %v, want %v", s, v, want) + } +} + +type A struct { + B +} + +type B struct { + C string +} + +type D struct { + B + C string +} + +type e struct { + B + C string +} + +type F struct { + e +} + +func TestValues_embeddedStructs(t *testing.T) { + tests := []struct { + in interface{} + want url.Values + }{ + { + A{B{C: "foo"}}, + url.Values{"C": {"foo"}}, + }, + { + D{B: B{C: "bar"}, C: "foo"}, + url.Values{"C": {"foo", "bar"}}, + }, + { + F{e{B: B{C: "bar"}, C: "foo"}}, // With unexported embed + url.Values{"C": {"foo", "bar"}}, + }, + } + + for i, tt := range tests { + v, err := Values(tt.in) + if err != nil { + t.Errorf("%d. Values(%q) returned error: %v", i, tt.in, err) + } + + if !reflect.DeepEqual(tt.want, v) { + t.Errorf("%d. Values(%q) returned %v, want %v", i, tt.in, v, tt.want) + } + } +} + +func TestValues_invalidInput(t *testing.T) { + _, err := Values("") + if err == nil { + t.Errorf("expected Values() to return an error on invalid input") + } +} + +type EncodedArgs []string + +func (m EncodedArgs) EncodeValues(key string, v *url.Values) error { + for i, arg := range m { + v.Set(fmt.Sprintf("%s.%d", key, i), arg) + } + return nil +} + +func TestValues_Marshaler(t *testing.T) { + s := struct { + Args EncodedArgs `url:"arg"` + }{[]string{"a", "b", "c"}} + v, err := Values(s) + if err != nil { + t.Errorf("Values(%q) returned error: %v", s, err) + } + + want := url.Values{ + "arg.0": {"a"}, + "arg.1": {"b"}, + "arg.2": {"c"}, + } + if !reflect.DeepEqual(want, v) { + t.Errorf("Values(%q) returned %v, want %v", s, v, want) + } +} + +func TestValues_MarshalerWithNilPointer(t *testing.T) { + s := struct { + Args *EncodedArgs `url:"arg"` + }{} + v, err := Values(s) + if err != nil { + t.Errorf("Values(%v) returned error: %v", s, err) + } + + want := url.Values{} + if !reflect.DeepEqual(want, v) { + t.Errorf("Values(%v) returned %v, want %v", s, v, want) + } +} + +func TestTagParsing(t *testing.T) { + name, opts := parseTag("field,foobar,foo") + if name != "field" { + t.Fatalf("name = %q, want field", name) + } + for _, tt := range []struct { + opt string + want bool + }{ + {"foobar", true}, + {"foo", true}, + {"bar", false}, + {"field", false}, + } { + if opts.Contains(tt.opt) != tt.want { + t.Errorf("Contains(%q) = %v", tt.opt, !tt.want) + } + } +} -- cgit v1.2.3 From 7899b1039403821c5d03eff95e0e58fdbafe1f0a Mon Sep 17 00:00:00 2001 From: Alexandre Garand Date: Thu, 27 Jun 2019 15:32:22 +0200 Subject: Update go modules dependencies --- go.mod | 2 +- go.sum | 64 ++++-------------------------------------------------- vendor/modules.txt | 4 +++- 3 files changed, 8 insertions(+), 62 deletions(-) diff --git a/go.mod b/go.mod index d999246..2e3c996 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/terraform-providers/terraform-provider-statuscake require ( - github.com/DreamItGetIT/statuscake v0.0.0-20190218105717-471b24d8edfb + github.com/DreamItGetIT/statuscake v0.0.0-20190625125909-fc745efe187b github.com/hashicorp/terraform v0.12.0 ) diff --git a/go.sum b/go.sum index cc8f846..306afd7 100644 --- a/go.sum +++ b/go.sum @@ -8,25 +8,20 @@ dmitri.shuralyov.com/html/belt v0.0.0-20180602232347-f7d459c86be0/go.mod h1:JLBr dmitri.shuralyov.com/service/change v0.0.0-20181023043359-a85b471d5412/go.mod h1:a1inKt/atXimZ4Mv927x+r7UpyzRUf4emIoiiSC2TN4= dmitri.shuralyov.com/state v0.0.0-20180228185332-28bcc343414c/go.mod h1:0PRwlb0D6DFvNNtx+9ybjezNCa8XF0xaYcETyp6rHWU= git.apache.org/thrift.git v0.0.0-20180902110319-2566ecd5d999/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg= -github.com/Azure/azure-sdk-for-go v21.3.0+incompatible h1:YFvAka2WKAl2xnJkYV1e1b7E2z88AgFszDzWU18ejMY= github.com/Azure/azure-sdk-for-go v21.3.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= -github.com/Azure/go-autorest v10.15.4+incompatible h1:q+DRrRdbCnkY7f2WxQBx58TwCGkEdMAK/hkZ10g0Pzk= github.com/Azure/go-autorest v10.15.4+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24= -github.com/Azure/go-ntlmssp v0.0.0-20180810175552-4a21cbd618b4 h1:pSm8mp0T2OH2CPmPDPtwHPr3VAQaOwVF/JbllOPP4xA= github.com/Azure/go-ntlmssp v0.0.0-20180810175552-4a21cbd618b4/go.mod h1:chxPXzSsl7ZWRAuOIE23GDNzjWuZquvFlgA8xmpunjU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/ChrisTrenkamp/goxpath v0.0.0-20170922090931-c385f95c6022 h1:y8Gs8CzNfDF5AZvjr+5UyGQvQEBL7pwo+v+wX6q9JI8= github.com/ChrisTrenkamp/goxpath v0.0.0-20170922090931-c385f95c6022/go.mod h1:nuWgzSkT5PnyOd+272uUmV0dnAnAn42Mk7PiQC5VzN4= github.com/DreamItGetIT/statuscake v0.0.0-20190218105717-471b24d8edfb h1:vJ3lnCyZNmSV/OKyw4d7GuZHFrUaa3FY6/NqtvRE0lw= github.com/DreamItGetIT/statuscake v0.0.0-20190218105717-471b24d8edfb/go.mod h1:OclNh7ZacJo61GDJablmsOZ7l8/AVtzGqP8G7baOdAs= -github.com/Unknwon/com v0.0.0-20151008135407-28b053d5a292 h1:tuQ7w+my8a8mkwN7x2TSd7OzTjkZ7rAeSyH4xncuAMI= +github.com/DreamItGetIT/statuscake v0.0.0-20190625125909-fc745efe187b h1:yUbHQh9UVg9muJwkgX2AaID/Yps2qUCVyeIUd8gcB4M= +github.com/DreamItGetIT/statuscake v0.0.0-20190625125909-fc745efe187b/go.mod h1:OclNh7ZacJo61GDJablmsOZ7l8/AVtzGqP8G7baOdAs= github.com/Unknwon/com v0.0.0-20151008135407-28b053d5a292/go.mod h1:KYCjqMOeHpNuTOiFQU6WEcTG7poCJrUs0YgyHNtn1no= github.com/abdullin/seq v0.0.0-20160510034733-d5467c17e7af/go.mod h1:5Jv4cbFiHJMsVxt52+i0Ha45fjshj6wxYr1r19tB9bw= -github.com/agext/levenshtein v1.2.1 h1:QmvMAjj2aEICytGiWzmxoE0x2KZvE0fvmqMOfy2tjT8= github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= github.com/agext/levenshtein v1.2.2 h1:0S/Yg6LYmFJ5stwQeRp6EeOcCbj7xiqQSdNelsXvaqE= github.com/agext/levenshtein v1.2.2/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= -github.com/agl/ed25519 v0.0.0-20150830182803-278e1ec8e8a6 h1:LoeFxdq5zUCBQPhbQKE6zvoGwHMxCBlqwbH9+9kHoHA= github.com/agl/ed25519 v0.0.0-20150830182803-278e1ec8e8a6/go.mod h1:WPjqKcmVOxf0XSf3YxCJs6N6AOSrOx3obionmG7T0y0= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= github.com/antchfx/xpath v0.0.0-20190129040759-c8489ed3251e/go.mod h1:Yee4kTMuNiPYJ7nSNorELQMr1J33uOpXDMByNYhvtNk= @@ -38,7 +33,6 @@ github.com/apparentlymart/go-dump v0.0.0-20190214190832-042adf3cf4a0 h1:MzVXffFU github.com/apparentlymart/go-dump v0.0.0-20190214190832-042adf3cf4a0/go.mod h1:oL81AME2rN47vu18xqj1S1jPIPuN7afo62yKTNn3XMM= github.com/apparentlymart/go-textseg v1.0.0 h1:rRmlIsPEEhUTIKQb7T++Nz/A5Q6C9IuX2wFoYVvnCs0= github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/Nj9VFpLOpjS5yuumk= -github.com/armon/circbuf v0.0.0-20190214190532-5111143e8da2 h1:7Ip0wMmLHLRJdrloDxZfhMm0xrLXZS8+COSu2bXmEQs= github.com/armon/circbuf v0.0.0-20190214190532-5111143e8da2/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= @@ -60,28 +54,21 @@ github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBT github.com/bsm/go-vlq v0.0.0-20150828105119-ec6e8d4f5f4e/go.mod h1:N+BjUcTjSxc2mtRGSCPsat1kze3CUtvJN3/jTXlp29k= github.com/cheggaaa/pb v1.0.27/go.mod h1:pQciLPpbU0oxA0h+VJYYLxO+XeDQb5pZijXscXHm81s= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= -github.com/chzyer/readline v0.0.0-20161106042343-c914be64f07d h1:aG5FcWiZTOhPQzYIxwxSR1zEOxzL32fwr1CsaCfhO6w= github.com/chzyer/readline v0.0.0-20161106042343-c914be64f07d/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/coreos/bbolt v1.3.0/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= -github.com/coreos/etcd v3.3.10+incompatible h1:jFneRYjIvLMLhDLCzuTuU4rSJUjRplcJQ7pD7MnhC04= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= -github.com/coreos/go-semver v0.2.0 h1:3Jm3tLmsgAYcjC+4Up7hJrFBPr+n7rAqYeSw/SZazuY= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd v0.0.0-20181012123002-c6f51f82210d/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= -github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= -github.com/dimchansky/utfbom v1.0.0 h1:fGC2kkf4qOoKqZ4q7iIh+Vef4ubC1c38UDsEyZynZPc= github.com/dimchansky/utfbom v1.0.0/go.mod h1:rO41eb7gLfo8SF1jd9F8HplJm1Fewwi4mQvIirEdv+8= github.com/dnaeon/go-vcr v0.0.0-20180920040454-5637cf3d8a31/go.mod h1:aBB1+wY4s93YsC3HHjMBMrwTj2R9FHDzUr9KyGc8n1E= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= -github.com/dylanmei/iso8601 v0.1.0 h1:812NGQDBcqquTfH5Yeo7lwR0nzx/cKdsmf3qMjPURUI= github.com/dylanmei/iso8601 v0.1.0/go.mod h1:w9KhXSgIyROl1DefbMYIE7UVSIvELTbMrCfx+QkYnoQ= github.com/dylanmei/winrmtest v0.0.0-20190225150635-99b7fe2fddf1/go.mod h1:lcy9/2gH1jn/VCLouHA6tOEwLoNVd4GW6zhuKLmHC2Y= github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= @@ -93,7 +80,6 @@ github.com/gliderlabs/ssh v0.1.1/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aev github.com/go-test/deep v1.0.1 h1:UQhStjbkDClarlmv0am7OXXO4/GaPdCGiUiMTvi28sg= github.com/go-test/deep v1.0.1/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= -github.com/gogo/protobuf v1.2.0 h1:xU6/SpYbvkNYiptHJYEDRseDLvYE7wSqhYYNy0QSUzI= github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= @@ -103,7 +89,6 @@ github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfb github.com/golang/mock v1.2.0 h1:28o5sBqPkBsMGnC6b4MvE2TzSr5/AT4c/1fLqVGIwlk= github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.0 h1:kbxbvI4Un1LUWKxufD+BiE6AEExYYgkQLQmLFqA1LFk= github.com/golang/protobuf v1.3.0/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a1/R87v0= @@ -121,11 +106,8 @@ github.com/googleapis/gax-go v2.0.0+incompatible h1:j0GKcs05QVmm7yesiZq2+9cxHkNK github.com/googleapis/gax-go v2.0.0+incompatible/go.mod h1:SFVmujtThgffbyetf+mdk2eWhX2bMyUtNHzFKcPA9HY= github.com/googleapis/gax-go/v2 v2.0.3 h1:siORttZ36U2R/WjiJuDz8znElWBiAlO9rVt+mqJt0Cc= github.com/googleapis/gax-go/v2 v2.0.3/go.mod h1:LLvjysVCY1JZeum8Z6l8qUty8fiNwE08qbEPm1M08qg= -github.com/gophercloud/gophercloud v0.0.0-20190208042652-bc37892e1968 h1:Pu+HW4kcQozw0QyrTTgLE+3RXNqFhQNNzhbnoLFL83c= github.com/gophercloud/gophercloud v0.0.0-20190208042652-bc37892e1968/go.mod h1:3WdhXV3rUYy9p6AUW8d94kr+HS62Y4VL9mBnFxsD8q4= -github.com/gophercloud/utils v0.0.0-20190128072930-fbb6ab446f01 h1:OgCNGSnEalfkRpn//WGJHhpo7fkP+LhTpvEITZ7CkK4= github.com/gophercloud/utils v0.0.0-20190128072930-fbb6ab446f01/go.mod h1:wjDF8z83zTeg5eMLml5EBSlAhbF7G8DobyI1YsMuyzw= -github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= @@ -133,20 +115,16 @@ github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmg github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= github.com/grpc-ecosystem/grpc-gateway v1.5.0/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpgL2+G+NZTnrVHpWWfpdw= github.com/grpc-ecosystem/grpc-gateway v1.5.1/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpgL2+G+NZTnrVHpWWfpdw= -github.com/hashicorp/aws-sdk-go-base v0.2.0 h1:5bjZnWCvQg9Im5CHZr9t90IaFC4uvVlMl2fTh23IoCk= github.com/hashicorp/aws-sdk-go-base v0.2.0/go.mod h1:ZIWACGGi0N7a4DZbf15yuE1JQORmWLtBcVM6F5SXNFU= -github.com/hashicorp/consul v0.0.0-20171026175957-610f3c86a089 h1:1eDpXAxTh0iPv+1kc9/gfSI2pxRERDsTk/lNGolwHn8= github.com/hashicorp/consul v0.0.0-20171026175957-610f3c86a089/go.mod h1:mFrjN1mfidgJfYP1xrJCF+AfRhr6Eaqhb2+sfyn/OOI= github.com/hashicorp/errwrap v0.0.0-20180715044906-d6c0cd880357/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= -github.com/hashicorp/go-azure-helpers v0.0.0-20190129193224-166dfd221bb2 h1:VBRx+yPYUZaobnn5ANBcOUf4hhWpTHSQgftG4TcDkhI= github.com/hashicorp/go-azure-helpers v0.0.0-20190129193224-166dfd221bb2/go.mod h1:lu62V//auUow6k0IykxLK2DCNW8qTmpm8KqhYVWattA= -github.com/hashicorp/go-checkpoint v0.5.0 h1:MFYpPZCnQqQTE18jFwSII6eUQrD/oxMFp3mlgcqk5mU= github.com/hashicorp/go-checkpoint v0.5.0/go.mod h1:7nfLNL10NsxqO4iWuW6tWW0HjZuDrwkBuEQsVcpCOgg= github.com/hashicorp/go-cleanhttp v0.5.0 h1:wvCrVc9TjDls6+YGAF2hAifE1E5U1+b4tH6KdvN3Gig= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= -github.com/hashicorp/go-getter v1.3.0 h1:pFMSFlI9l5NaeuzkpE3L7BYk9qQ9juTAgXW/H0cqxcU= +github.com/hashicorp/go-getter v1.3.0 h1:zVkuohrXQAfI32em/DcGmurxxVwrnJk+m5/KybEPLSw= github.com/hashicorp/go-getter v1.3.0/go.mod h1:/O1k/AizTN0QmfEKknCYGvICeyKUDqCYA8vvWtGWDeQ= github.com/hashicorp/go-hclog v0.0.0-20180709165350-ff2cf002a8dd/go.mod h1:9bjs9uLqI8l75knNv3lV1kA55veR+WUPSiKIWcQHudI= github.com/hashicorp/go-hclog v0.0.0-20181001195459-61d530d6c27f h1:Yv9YzBlAETjy6AOX9eLBZ3nshNVRREgerT/3nvxlGho= @@ -158,18 +136,13 @@ github.com/hashicorp/go-multierror v1.0.0 h1:iVjPR7a6H0tWELX5NxNe7bYopibicUzc7uP github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/go-plugin v1.0.1-0.20190430211030-5692942914bb h1:Zg2pmmk0lrLFL85lQGt08bOUBpIBaVs6/psiAyx0c4w= github.com/hashicorp/go-plugin v1.0.1-0.20190430211030-5692942914bb/go.mod h1:++UyYGoz3o5w9ZzAdZxtQKrWWP+iqPBn3cQptSMzBuY= -github.com/hashicorp/go-retryablehttp v0.5.2 h1:AoISa4P4IsW0/m4T6St8Yw38gTl5GtBAgfkhYh1xAz4= github.com/hashicorp/go-retryablehttp v0.5.2/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= -github.com/hashicorp/go-rootcerts v1.0.0 h1:Rqb66Oo1X/eSV1x66xbDccZjhJigjg0+e82kpwzSwCI= github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= github.com/hashicorp/go-safetemp v1.0.0 h1:2HR189eFNrjHQyENnQMMpCiBAsRxzbTMIgBhEyExpmo= github.com/hashicorp/go-safetemp v1.0.0/go.mod h1:oaerMy3BhqiTbVye6QuFhFtIceqFoDHxNAB65b+Rj1I= -github.com/hashicorp/go-slug v0.3.0 h1:L0c+AvH/J64iMNF4VqRaRku2DMTEuHioPVS7kMjWIU8= github.com/hashicorp/go-slug v0.3.0/go.mod h1:I5tq5Lv0E2xcNXNkmx7BSfzi1PsJ2cNjs3cC3LwyhK8= github.com/hashicorp/go-sockaddr v0.0.0-20180320115054-6d291a969b86/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= -github.com/hashicorp/go-tfe v0.3.16 h1:GS2yv580p0co4j3FBVaC6Zahd9mxdCGehhJ0qqzFMH0= github.com/hashicorp/go-tfe v0.3.16/go.mod h1:SuPHR+OcxvzBZNye7nGPfwZTEyd3rWPfLVbCgyZPezM= -github.com/hashicorp/go-uuid v1.0.0 h1:RS8zrF7PhGwyNPOtxSClXXj9HA8feRnJzgnI1RJCSnM= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1BE= github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= @@ -187,7 +160,7 @@ github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= github.com/hashicorp/memberlist v0.1.0/go.mod h1:ncdBp14cuox2iFOq3kDiquKU6fqsTBc3W6JvZwjxxsE= github.com/hashicorp/serf v0.0.0-20160124182025-e4ec8cc423bb/go.mod h1:h/Ru6tmZazX7WO/GDmwdpS975F019L4t5ng5IgwbNrE= -github.com/hashicorp/terraform v0.12.0 h1:It2vmod2dBMB4+r+aUW2Afx0HlftyUwzNsNH3I2vrJ8= +github.com/hashicorp/terraform v0.12.0 h1:B5lTDWSdEbbjxrTZQ8GdsDlH7FnDrIvF42GykbhQ6tA= github.com/hashicorp/terraform v0.12.0/go.mod h1:Ke0ig9gGZ8rhV6OddAhBYt5nXmpvXsuNQQ8w9qYBZfU= github.com/hashicorp/terraform-config-inspect v0.0.0-20190327195015-8022a2663a70 h1:oZm5nE11yhzsTRz/YrUyDMSvixePqjoZihwn8ipuOYI= github.com/hashicorp/terraform-config-inspect v0.0.0-20190327195015-8022a2663a70/go.mod h1:ItvqtvbC3K23FFET62ZwnkwtpbKZm8t8eMcWjmVVjD8= @@ -201,14 +174,10 @@ github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8/go.mod h1:Nht github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= -github.com/joyent/triton-go v0.0.0-20180313100802-d8f9c0314926 h1:kie3qOosvRKqwij2HGzXWffwpXvcqfPPXRUw8I4F/mg= github.com/joyent/triton-go v0.0.0-20180313100802-d8f9c0314926/go.mod h1:U+RSyWxWd04xTqnuOQxnai7XGS2PrPY2cfGoDKtMHjA= -github.com/jtolds/gls v4.2.1+incompatible h1:fSuqC+Gmlu6l/ZYAoZzx2pyucC8Xza35fpRVWLVmUEE= github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/kardianos/osext v0.0.0-20170510131534-ae77be60afb1/go.mod h1:1NbS8ALrpOvjt0rHPNLyCIeMtbizbir8U//inJ+zuB8= -github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 h1:iQTw/8FWTuc7uiaSepXwyf3o52HaUYcV+Tu66S3F5GA= github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0/go.mod h1:1NbS8ALrpOvjt0rHPNLyCIeMtbizbir8U//inJ+zuB8= -github.com/keybase/go-crypto v0.0.0-20161004153544-93f5b35093ba h1:NARVGAAgEXvoMeNPHhPFt1SBt1VMznA3Gnz9d0qj+co= github.com/keybase/go-crypto v0.0.0-20161004153544-93f5b35093ba/go.mod h1:ghbZscTyKdM07+Fw3KSi0hcJm+AlEUWj8QLlPtijN/M= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/konsorten/go-windows-terminal-sequences v0.0.0-20180402223658-b729f2633dfe/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= @@ -220,15 +189,10 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348 h1:MtvEpTB6LX3vkb4ax0b5D2DHbNAUsen0Gx5wZoq3lV4= github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k= -github.com/lib/pq v1.0.0 h1:X5PMW56eZitiTeO7tKzZxFCSpbFZJtkMMooicw2us9A= github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= -github.com/lusis/go-artifactory v0.0.0-20160115162124-7e4ce345df82 h1:wnfcqULT+N2seWf6y4yHzmi7GD2kNx4Ute0qArktD48= github.com/lusis/go-artifactory v0.0.0-20160115162124-7e4ce345df82/go.mod h1:y54tfGmO3NKssKveTEFFzH8C/akrSOy/iW9qEAUDV84= -github.com/marstr/guid v1.1.0 h1:/M4H/1G4avsieL6BbUwCOBzulmoeKVP5ux/3mQNnbyI= github.com/marstr/guid v1.1.0/go.mod h1:74gB1z2wpxxInTG6yaqA7KrtM0NZ+RbrcqDvYHefzho= -github.com/masterzen/simplexml v0.0.0-20160608183007-4572e39b1ab9 h1:SmVbOZFWAlyQshuMfOkiAx1f5oUTsOGG5IXplAEYeeM= github.com/masterzen/simplexml v0.0.0-20160608183007-4572e39b1ab9/go.mod h1:kCEbxUJlNDEBNbdQMkPSp6yaKcRXVI6f4ddk8Riv4bc= -github.com/masterzen/winrm v0.0.0-20190223112901-5e5c9a7fe54b h1:/1RFh2SLCJ+tEnT73+Fh5R2AO89sQqs8ba7o+hx1G0Y= github.com/masterzen/winrm v0.0.0-20190223112901-5e5c9a7fe54b/go.mod h1:wr1VqkwW0AB5JS0QLy5GpVMS9E3VtRoSYXUYyVk46KY= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.1 h1:G1f5SKeVxmagw/IyvzvtZE4Gybcc4Tr1tf7I8z0XgOg= @@ -238,7 +202,6 @@ github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNx github.com/mattn/go-isatty v0.0.5 h1:tHXDdz1cpzGaovsTB+TVB8q90WEokoVmfMqoVcrLUgw= github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= -github.com/mattn/go-shellwords v1.0.4 h1:xmZZyxuP+bYKAKkA9ABYXVNJ+G/Wf3R8d8vAP3LDJJk= github.com/mattn/go-shellwords v1.0.4/go.mod h1:3xCvwCdWdlDJUrvuMn7Wuy9eWs4pE8vqg+NOMyg4B2o= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/microcosm-cc/bluemonday v1.0.1/go.mod h1:hsXNsILzKxV+sX77C5b8FSuKF00vh2OMYv+xgHpAMF4= @@ -251,12 +214,10 @@ github.com/mitchellh/copystructure v1.0.0 h1:Laisrj+bAB6b/yJwB5Bt3ITZhGJdqmxquMK github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= github.com/mitchellh/go-homedir v1.0.0 h1:vKb8ShqSby24Yrqr/yDYkuFz8d0WUjys40rvnGC8aR0= github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= -github.com/mitchellh/go-linereader v0.0.0-20190213213312-1b945b3263eb h1:GRiLv4rgyqjqzxbhJke65IYUf4NCOOvrPOJbV/sPxkM= github.com/mitchellh/go-linereader v0.0.0-20190213213312-1b945b3263eb/go.mod h1:OaY7UOoTkkrX3wRwjpYRKafIkkyeD0UtweSHAWWiqQM= github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= github.com/mitchellh/go-testing-interface v1.0.0 h1:fzU/JVNcaqHQEcVFAKeR41fkiLdIPrefOvVG1VZ96U0= github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= -github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 h1:DpOJ2HYzCv8LZP15IdmG+YdwD2luVPHITV96TkirNBM= github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= github.com/mitchellh/go-wordwrap v1.0.0 h1:6GlHJ/LTGMrIJbwgdqdl2eEH8o+Exx/0m8ir9Gns0u4= github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= @@ -264,15 +225,12 @@ github.com/mitchellh/hashstructure v1.0.0 h1:ZkRJX1CyOoTkar7p/mLS5TZU4nJ1Rn/F8u9 github.com/mitchellh/hashstructure v1.0.0/go.mod h1:QjSHrPWS+BGUVBYkbTZWEnOh3G1DutKwClXU/ABz6AQ= github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/mitchellh/panicwrap v0.0.0-20190213213626-17011010aaa4 h1:jw9tsdJ1FQmUkyTXdIF/nByTX+mMnnp16glnvGZMsC4= github.com/mitchellh/panicwrap v0.0.0-20190213213626-17011010aaa4/go.mod h1:YYMf4xtQnR8LRC0vKi3afvQ5QwRPQ17zjcpkBCufb+I= -github.com/mitchellh/prefixedio v0.0.0-20190213213902-5733675afd51 h1:eD92Am0Qf3rqhsOeA1zwBHSfRkoHrt4o6uORamdmJP8= github.com/mitchellh/prefixedio v0.0.0-20190213213902-5733675afd51/go.mod h1:kB1naBgV9ORnkiTVeyJOI1DavaJkG4oNIq0Af6ZVKUo= github.com/mitchellh/reflectwalk v1.0.0 h1:9D+8oIskB4VJBN5SFlmc27fSlIBZaov1Wpk/IfikLNY= github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/neelance/astrewrite v0.0.0-20160511093645-99348263ae86/go.mod h1:kHJEU3ofeGjhHklVoIGuVj85JJwZ6kWPaJwCIxgnFmo= github.com/neelance/sourcemap v0.0.0-20151028013722-8c68805598ab/go.mod h1:Qr6/a/Q4r9LP1IltGz7tA7iOK1WonHEYhu1HRBA7ZiM= -github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d h1:VhgPp6v9qf9Agr/56bj7Y/xa04UccTW04VP0Qed4vnQ= github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d/go.mod h1:YUTz3bUH2ZwIWBy3CJBeOBEugqcmXREj14T+iG/4k4U= github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= @@ -280,10 +238,8 @@ github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/openzipkin/zipkin-go v0.1.1/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTmOf0Erfk+hxe8= -github.com/packer-community/winrmcp v0.0.0-20180102160824-81144009af58 h1:m3CEgv3ah1Rhy82L+c0QG/U3VyY1UsvsIdkh0/rU97Y= github.com/packer-community/winrmcp v0.0.0-20180102160824-81144009af58/go.mod h1:f6Izs6JvFTdnRbziASagjZ2vmf55NSIkC/weStxCHqk= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= -github.com/pkg/errors v0.0.0-20170505043639-c605e284fe17 h1:chPfVn+gpAM5CTpTyVU9j8J+xgRGwmoDlNDLjKnJiYo= github.com/pkg/errors v0.0.0-20170505043639-c605e284fe17/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= @@ -295,7 +251,6 @@ github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1: github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= -github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= @@ -323,7 +278,6 @@ github.com/shurcooL/sanitized_anchor_name v0.0.0-20170918181015-86672fcb3f95/go. github.com/shurcooL/users v0.0.0-20180125191416-49c67e49c537/go.mod h1:QJTqeLYEDaXHZDBsXlPCDqdhQuJkuw4NOtaxYe3xii4= github.com/shurcooL/webdavfs v0.0.0-20170829043945-18c3829fa133/go.mod h1:hKmq5kWdCj2z2KEozexVbfEZIWiTjhE0+UjmZgPqehw= github.com/sirupsen/logrus v1.1.1/go.mod h1:zrgwTnHtNr00buQ1vSptGe8m1f/BbgsPukg8qsT7A+A= -github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v0.0.0-20180222194500-ef6db91d284a/go.mod h1:XDJAKZRPZ1CvBcN2aX5YOUTYGHki24fSF0Iv48Ibg0s= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= @@ -336,23 +290,18 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/svanharmelen/jsonapi v0.0.0-20180618144545-0c0828c3f16d h1:Z4EH+5EffvBEhh37F0C0DnpklTMh00JOkjW5zK3ofBI= github.com/svanharmelen/jsonapi v0.0.0-20180618144545-0c0828c3f16d/go.mod h1:BSTlc8jOjh0niykqEGVXOLXdi9o0r0kR8tCYiMvjFgw= github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA= -github.com/terraform-providers/terraform-provider-openstack v1.15.0 h1:adpjqej+F8BAX9dHmuPF47sUIkgifeqBu6p7iCsyj0Y= github.com/terraform-providers/terraform-provider-openstack v1.15.0/go.mod h1:2aQ6n/BtChAl1y2S60vebhyJyZXBsuAI5G4+lHrT1Ew= github.com/tmc/grpc-websocket-proxy v0.0.0-20171017195756-830351dc03c6/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= -github.com/ugorji/go v0.0.0-20180813092308-00b869d2f4a5 h1:cMjKdf4PxEBN9K5HaD9UMW8gkTbM0kMzkTa9SJe0WNQ= github.com/ugorji/go v0.0.0-20180813092308-00b869d2f4a5/go.mod h1:hnLbHMwcvSihnDhEfx2/BzKp2xb0Y+ErdfYcrs9tkJQ= github.com/ulikunitz/xz v0.5.5 h1:pFrO0lVpTBXLpYw+pnLj6TbvHuyjXMfjGeCwSqCVwok= github.com/ulikunitz/xz v0.5.5/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4ABRW8= github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= github.com/vmihailenco/msgpack v4.0.1+incompatible h1:RMF1enSPeKTlXrXdOcqjFUElywVZjjC6pqse21bKbEU= github.com/vmihailenco/msgpack v4.0.1+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= -github.com/xanzy/ssh-agent v0.2.1 h1:TCbipTQL2JiiCprBWx9frJ2eJlCYT00NmctrHxVAr70= github.com/xanzy/ssh-agent v0.2.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4= github.com/xiang90/probing v0.0.0-20160813154853-07dd2e8dfe18/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= -github.com/xlab/treeprint v0.0.0-20161029104018-1d6e34225557 h1:Jpn2j6wHkC9wJv5iMfJhKqrZJx3TahFx+7sbZ7zQdxs= github.com/xlab/treeprint v0.0.0-20161029104018-1d6e34225557/go.mod h1:ce1O1j6UtZfjr22oyGxGLbauSBp2YVXpARAosm7dHBg= github.com/zclconf/go-cty v0.0.0-20181129180422-88fbe721e0f8/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s= github.com/zclconf/go-cty v0.0.0-20190426224007-b18a157db9e2/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s= @@ -398,7 +347,6 @@ golang.org/x/oauth2 v0.0.0-20190220154721-9b3c75971fc9/go.mod h1:gOpvHmFTYa4Iltr golang.org/x/perf v0.0.0-20180704124530-6e6d33e29852/go.mod h1:JLpeXjPJfIyPr5TlbXLkXWLhP8nz10XfvxElABhCtcw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FYywz3ker1l1vDZRCRefw= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -415,15 +363,12 @@ golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190502175342-a43fa875dd82 h1:vsphBvatvfbhlb4PO1BYSr9dzugGxJ/SQHoNufZJq1w= golang.org/x/sys v0.0.0-20190502175342-a43fa875dd82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20181108054448-85acf8d2951c h1:fqgJT0MGcGpPgpWU7VRdRjuArfcOvC4AoJmILihzhDg= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 h1:SvFZT6jyqRaOeXpc5h/JSfZenJ2O330aBsf7JfSUXmQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -456,7 +401,6 @@ gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMy gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= grpc.go4.org v0.0.0-20170609214715-11d0a25b4919/go.mod h1:77eQGdRu53HpSqPFJFmuJdjuHRquDANNeA4x7B8WQ9o= honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/vendor/modules.txt b/vendor/modules.txt index b1009a7..d93cd37 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -6,7 +6,7 @@ cloud.google.com/go/internal/optional cloud.google.com/go/internal/trace cloud.google.com/go/internal/version cloud.google.com/go/compute/metadata -# github.com/DreamItGetIT/statuscake v0.0.0-20190218105717-471b24d8edfb +# github.com/DreamItGetIT/statuscake v0.0.0-20190625125909-fc745efe187b github.com/DreamItGetIT/statuscake # github.com/agext/levenshtein v1.2.2 github.com/agext/levenshtein @@ -73,6 +73,8 @@ github.com/google/go-cmp/cmp github.com/google/go-cmp/cmp/internal/diff github.com/google/go-cmp/cmp/internal/function github.com/google/go-cmp/cmp/internal/value +# github.com/google/go-querystring v1.0.0 +github.com/google/go-querystring/query # github.com/googleapis/gax-go/v2 v2.0.3 github.com/googleapis/gax-go/v2 # github.com/hashicorp/errwrap v1.0.0 -- cgit v1.2.3 From 325ba48bdd2e456d702e17d927d7d0f58a47503e Mon Sep 17 00:00:00 2001 From: Alexandre Garand Date: Mon, 1 Jul 2019 13:10:19 +0200 Subject: remove Println used for debug --- statuscake/resource_statuscakessl.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/statuscake/resource_statuscakessl.go b/statuscake/resource_statuscakessl.go index 3dba5bd..f07d6eb 100644 --- a/statuscake/resource_statuscakessl.go +++ b/statuscake/resource_statuscakessl.go @@ -158,8 +158,6 @@ func CreateSsl(d *schema.ResourceData, meta interface{}) error { response, err := statuscake.NewSsls(client).Create(newSsl) if err != nil { - fmt.Println(newSsl) - fmt.Println(client) return fmt.Errorf("Error creating StatusCake Ssl: %s", err.Error()) } -- cgit v1.2.3 From 0bb80147ede7473cf569fc1b65d8bbd1f01616b6 Mon Sep 17 00:00:00 2001 From: Alexandre Garand Date: Mon, 1 Jul 2019 17:49:23 +0200 Subject: update go.mod --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 2e3c996..74c84aa 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/terraform-providers/terraform-provider-statuscake require ( - github.com/DreamItGetIT/statuscake v0.0.0-20190625125909-fc745efe187b + github.com/DreamItGetIT/statuscake v0.0.0-20190628135227-71a9c9823950 github.com/hashicorp/terraform v0.12.0 ) diff --git a/go.sum b/go.sum index 306afd7..6ebf685 100644 --- a/go.sum +++ b/go.sum @@ -17,6 +17,8 @@ github.com/DreamItGetIT/statuscake v0.0.0-20190218105717-471b24d8edfb h1:vJ3lnCy github.com/DreamItGetIT/statuscake v0.0.0-20190218105717-471b24d8edfb/go.mod h1:OclNh7ZacJo61GDJablmsOZ7l8/AVtzGqP8G7baOdAs= github.com/DreamItGetIT/statuscake v0.0.0-20190625125909-fc745efe187b h1:yUbHQh9UVg9muJwkgX2AaID/Yps2qUCVyeIUd8gcB4M= github.com/DreamItGetIT/statuscake v0.0.0-20190625125909-fc745efe187b/go.mod h1:OclNh7ZacJo61GDJablmsOZ7l8/AVtzGqP8G7baOdAs= +github.com/DreamItGetIT/statuscake v0.0.0-20190628135227-71a9c9823950 h1:lD09IZzV8+5/Lt83alOpxo/QCnRQue0DLTrqcqk3mcE= +github.com/DreamItGetIT/statuscake v0.0.0-20190628135227-71a9c9823950/go.mod h1:OclNh7ZacJo61GDJablmsOZ7l8/AVtzGqP8G7baOdAs= github.com/Unknwon/com v0.0.0-20151008135407-28b053d5a292/go.mod h1:KYCjqMOeHpNuTOiFQU6WEcTG7poCJrUs0YgyHNtn1no= github.com/abdullin/seq v0.0.0-20160510034733-d5467c17e7af/go.mod h1:5Jv4cbFiHJMsVxt52+i0Ha45fjshj6wxYr1r19tB9bw= github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= -- cgit v1.2.3 From f6072b0623ecc1dbef4bf26c3e8d57f58aaf3f7d Mon Sep 17 00:00:00 2001 From: Alexandre Garand Date: Tue, 9 Jul 2019 11:32:06 +0200 Subject: update documentation for the ssl resource --- website/docs/index.html.markdown | 13 +++++++- website/docs/r/ssl.html.markdown | 72 ++++++++++++++++++++++++++++++++++++++++ website/statuscake.erb | 3 ++ 3 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 website/docs/r/ssl.html.markdown diff --git a/website/docs/index.html.markdown b/website/docs/index.html.markdown index d25a866..db2e56d 100644 --- a/website/docs/index.html.markdown +++ b/website/docs/index.html.markdown @@ -3,7 +3,7 @@ layout: "statuscake" page_title: "Provider: StatusCake" sidebar_current: "docs-statuscake-index" description: |- - The StatusCake provider configures tests in StatusCake. + The StatusCake provider configures tests and in StatusCake. --- # StatusCake Provider @@ -36,4 +36,15 @@ resource "statuscake_test" "google" { check_rate = 300 contact_id = 12345 } + +resource "statuscake_ssl" "google" { + domain = "https://www.google.com" + contact_groups_c = "3,12" + checkrate = 3600 + alert_at = "18,71,344" + alert_reminder = true + alert_expiry = true + alert_broken = false + alert_mixed = true +} ``` diff --git a/website/docs/r/ssl.html.markdown b/website/docs/r/ssl.html.markdown new file mode 100644 index 0000000..4b768dd --- /dev/null +++ b/website/docs/r/ssl.html.markdown @@ -0,0 +1,72 @@ +--- +layout: "statuscake" +page_title: "StatusCake: statuscake_ssl" +sidebar_current: "docs-statuscake-ssl" +description: |- + The statuscake_ssl resource allows StatusCake ssl tests to be managed by Terraform. +--- + +# statuscake\_ssl + +The ssl resource allows StatusCake ssl tests to be managed by Terraform. + +## Example Usage + +```hcl +resource "statuscake_ssl" "google" { + domain = "https://www.google.com" + contact_groups_c = "3,12" + checkrate = 3600 + alert_at = "18,71,344" + alert_reminder = true + alert_expiry = true + alert_broken = false + alert_mixed = true +} +``` + +## Argument Reference + +The following arguments are supported: + +* `domain` - (Required) URL to check, has to start with https:// +* `contact_groups_c` - (Required) Contactgroup IDs, separated by a comma. Can be an empty string +* `checkrate` - (Required) Checkrate in seconds. Accepted: [300, 600, 1800, 3600, 86400, 2073600] +* `alert_at` - (Required) When you wish to receive reminders. Must be exactly 3 numeric values seperated by commas +* `alert_reminder` - (Required) Set to true to enable reminder alerts. False to disable. Also see alert_at +* `alert_expiry` - (Required) Set to true to enable expiration alerts. False to disable +* `alert_broken` - (Required) Set to true to enable broken alerts. False to disable +* `alert_mixed` - (Required) Set to true to enable mixed content alerts. False to disable + +## Attributes Reference + +The following attribute is exported: + +* `ssl_id` - A unique identifier for the ssl test. +* `issuer_cn` - +* `paused` - Whether the test has been paused (Administrative only) +* `cert_score` - Certificate score in % +* `cipher_score` - Cipher strength in % +* `cert_status` - Certificate status +* `cipher` - Cipher code (SSL spec) +* `valid_from_utc` - Certificate Validity Start (In UTC/GMT+0) +* `valid_until_utc` - Certificate Validity End (In UTC/GMT+0) +* `mixed_content` - Mixed content if present. Empty array if not. +* `last_reminder` - The last reminder to be detected (days) +* `last_updated_utc` - When the certificate has last been updated (Either by user action or by testing) +* `flags` : + * `is_extended` : Certificate has an Extended Validation certificate + * `has_pfs` : Certificate has Perfect Forward Secrecy enabled + * `is_broken` : Certificate has errors + * `is_expired` : Certificate is expired + * `is_missing` : Certificate not present + * `is_revoked` : Certificate has been revoked by CA + * `is_mixed` : Website contains Mixed Content + +## Import + +StatusCake ssl tests can be imported using the ssl id, e.g. + +``` +tf import statuscake_ssl.example 123 +``` diff --git a/website/statuscake.erb b/website/statuscake.erb index d5edf59..652552f 100644 --- a/website/statuscake.erb +++ b/website/statuscake.erb @@ -16,6 +16,9 @@ > statuscake_test + > + statuscake_ssl + -- cgit v1.2.3 From 464a0a808240c83e365ddc7a4c52b82ecf9b76c4 Mon Sep 17 00:00:00 2001 From: Alexandre Garand Date: Wed, 24 Jul 2019 14:25:01 +0200 Subject: contact_groups accept list --- statuscake/resource_statuscakessl.go | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/statuscake/resource_statuscakessl.go b/statuscake/resource_statuscakessl.go index f07d6eb..2ee50e6 100644 --- a/statuscake/resource_statuscakessl.go +++ b/statuscake/resource_statuscakessl.go @@ -4,10 +4,10 @@ import ( "fmt" "strconv" - "log" - "github.com/DreamItGetIT/statuscake" "github.com/hashicorp/terraform/helper/schema" + "log" + "strings" ) func resourceStatusCakeSsl() *schema.Resource { @@ -32,14 +32,18 @@ func resourceStatusCakeSsl() *schema.Resource { }, "contact_groups": { - Type: schema.TypeList, - Elem: &schema.Schema{Type: schema.TypeString}, - Computed: true, + Type: schema.TypeSet, + Elem: &schema.Schema{Type: schema.TypeString}, + Optional: true, + Computed: true, + ConflictsWith: []string{"contact_groups_c"}, }, "contact_groups_c": { - Type: schema.TypeString, - Required: true, + Type: schema.TypeString, + Optional: true, + Computed: true, + ConflictsWith: []string{"contact_groups"}, }, "checkrate": { @@ -143,6 +147,10 @@ func resourceStatusCakeSsl() *schema.Resource { func CreateSsl(d *schema.ResourceData, meta interface{}) error { client := meta.(*statuscake.Client) + if v, ok := d.GetOk("contact_groups"); ok { + d.Set("contact_groups_c", strings.Join(castSetToSliceStrings(v.(*schema.Set).List()), ",")) + } + newSsl := &statuscake.PartialSsl{ Domain: d.Get("domain").(string), Checkrate: strconv.Itoa(d.Get("checkrate").(int)), @@ -162,7 +170,6 @@ func CreateSsl(d *schema.ResourceData, meta interface{}) error { } d.Set("ssl_id", response.ID) - d.Set("contact_groups", response.ContactGroups) d.Set("paused", response.Paused) d.Set("issuer_cn", response.IssuerCn) d.Set("cert_score", response.CertScore) @@ -253,7 +260,9 @@ func getStatusCakeSslInput(d *schema.ResourceData) *statuscake.PartialSsl { ssl.Checkrate = strconv.Itoa(v.(int)) } - if v, ok := d.GetOk("contact_groups_c"); ok { + if v, ok := d.GetOk("contact_groups"); ok { + ssl.ContactGroupsC = strings.Join(castSetToSliceStrings(v.(*schema.Set).List()), ",") + } else if v, ok := d.GetOk("contact_groups_c"); ok { ssl.ContactGroupsC = v.(string) } -- cgit v1.2.3