-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: update panther base url * chore: extract function and add test * update test
- Loading branch information
1 parent
e2ac4d8
commit 9aeee34
Showing
3 changed files
with
57 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package panther | ||
|
||
import ( | ||
"github.com/stretchr/testify/assert" | ||
"reflect" | ||
"testing" | ||
) | ||
|
||
// Customer with custom url that provides the graphql endpoint (legacy behavior) | ||
func TestCreateAPIClient_CustomURLWithGraphEndpoint(t *testing.T) { | ||
url := "panther-url/public/graphql" | ||
client := *CreateAPIClient(url, "token") | ||
graphUrl := reflect.ValueOf(client).FieldByIndex([]int{0}).Elem().FieldByName("url").String() | ||
assert.Equal(t, "panther-url/public/graphql", graphUrl) | ||
assert.Equal(t, "panther-url/log-sources/http", client.RestClient.url) | ||
} | ||
|
||
// Customer with custom url that provides the panther root url (new behavior) | ||
func TestCreateAPIClient_CustomUrlWithBaseUrl(t *testing.T) { | ||
url := "panther-url" | ||
client := *CreateAPIClient(url, "token") | ||
graphUrl := reflect.ValueOf(client).FieldByIndex([]int{0}).Elem().FieldByName("url").String() | ||
assert.Equal(t, "panther-url/public/graphql", graphUrl) | ||
assert.Equal(t, "panther-url/log-sources/http", client.RestClient.url) | ||
} | ||
|
||
// Customer with API Gateway url that provides the graphql endpoint (legacy behavior) | ||
func TestCreateAPIClient_ApiGWUrlWithGraphEndpoint(t *testing.T) { | ||
url := "panther-url/v1/public/graphql" | ||
client := *CreateAPIClient(url, "token") | ||
graphUrl := reflect.ValueOf(client).FieldByIndex([]int{0}).Elem().FieldByName("url").String() | ||
assert.Equal(t, "panther-url/v1/public/graphql", graphUrl) | ||
assert.Equal(t, "panther-url/v1/log-sources/http", client.RestClient.url) | ||
} | ||
|
||
// Customer with API Gateway url that provides the panther root url (new behavior) | ||
func TestCreateAPIClient_ApiGWUrlWithBaseUrl(t *testing.T) { | ||
url := "panther-url/v1" | ||
client := *CreateAPIClient(url, "token") | ||
graphUrl := reflect.ValueOf(client).FieldByIndex([]int{0}).Elem().FieldByName("url").String() | ||
assert.Equal(t, "panther-url/v1/public/graphql", graphUrl) | ||
assert.Equal(t, "panther-url/v1/log-sources/http", client.RestClient.url) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters