From 56a851d04ce1b396d45067af23a48f8ff9e83c21 Mon Sep 17 00:00:00 2001 From: "bracha.yalon" Date: Thu, 18 Jan 2024 09:08:28 +0200 Subject: [PATCH] fix tests --- incapsula/config_test.go | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/incapsula/config_test.go b/incapsula/config_test.go index adac30ac..c74c072a 100644 --- a/incapsula/config_test.go +++ b/incapsula/config_test.go @@ -52,7 +52,18 @@ func TestMissingBaseURL(t *testing.T) { } func TestMissingBaseURLRev2(t *testing.T) { - config := Config{APIID: "foo", APIKey: "bar", BaseURL: "foobar.com", BaseURLRev2: ""} + config := Config{APIID: "foo", APIKey: "bar", BaseURL: "foobar.com", BaseURLRev2: "", BaseURLRev3: "foobar.com"} + client, err := config.Client() + if err == nil { + t.Errorf("Should have received an error, got a client: %q", client) + } + if err.Error() != missingBaseURLRev2Message { + t.Errorf("Should have received missing Base URL Revision 2 message, got: %s", err) + } +} + +func TestMissingBaseURLRev3(t *testing.T) { + config := Config{APIID: "foo", APIKey: "bar", BaseURL: "foobar.com", BaseURLRev2: "foobar.com", BaseURLRev3: ""} client, err := config.Client() if err == nil { t.Errorf("Should have received an error, got a client: %q", client) @@ -63,7 +74,7 @@ func TestMissingBaseURLRev2(t *testing.T) { } func TestMissingBaseURLAPI(t *testing.T) { - config := Config{APIID: "foo", APIKey: "bar", BaseURL: "foobar.com", BaseURLRev2: "foobar.com", BaseURLAPI: ""} + config := Config{APIID: "foo", APIKey: "bar", BaseURL: "foobar.com", BaseURLRev2: "foobar.com", BaseURLRev3: "foobar.com", BaseURLAPI: ""} client, err := config.Client() if err == nil { t.Errorf("Should have received an error, got a client: %q", client) @@ -82,7 +93,7 @@ func TestInvalidCredentials(t *testing.T) { })) defer server.Close() - config := Config{APIID: "bad", APIKey: "bad", BaseURL: server.URL, BaseURLRev2: server.URL, BaseURLAPI: server.URL} + config := Config{APIID: "bad", APIKey: "bad", BaseURL: server.URL, BaseURLRev2: server.URL, BaseURLRev3: server.URL, BaseURLAPI: server.URL} client, err := config.Client() if err == nil { t.Errorf("Should have received an error, got a client: %q", client) @@ -101,7 +112,7 @@ func TestValidCredentials(t *testing.T) { })) defer server.Close() - config := Config{APIID: "good", APIKey: "good", BaseURL: server.URL, BaseURLRev2: server.URL, BaseURLAPI: server.URL} + config := Config{APIID: "good", APIKey: "good", BaseURL: server.URL, BaseURLRev2: server.URL, BaseURLRev3: server.URL, BaseURLAPI: server.URL} client, err := config.Client() if err != nil { t.Errorf("Should not have received an error, got: %s", err)