Skip to content

Commit

Permalink
fix: improve authenticate method call parameters in fuzzing test (#184)
Browse files Browse the repository at this point in the history
  • Loading branch information
btfhernandez authored Jan 17, 2025
1 parent 1c99dc8 commit 1b7968b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
18 changes: 17 additions & 1 deletion fuzzing/managed_accounts/get_managed_accounts_fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ type TestConfig struct {
response string
}

// the recommended version is 3.1. If no version is specified,
// the default API version 3.0 will be used
var apiVersion string = "3.1"

func FuzzGetManagedAccount(f *testing.F) {

testConfig := TestConfig{
Expand Down Expand Up @@ -83,8 +87,20 @@ func FuzzGetManagedAccount(f *testing.F) {
backoffDefinition := backoff.NewExponentialBackOff()
backoffDefinition.MaxElapsedTime = time.Second

authParamsOauth := &authentication.AuthenticationParametersObj{
HTTPClient: *httpClientObj,
BackoffDefinition: backoffDefinition,
EndpointURL: "https://fake.api.com:443/BeyondTrust/api/public/v3/",
APIVersion: apiVersion,
ClientID: "fakeone_a654+9sdf7+8we4f",
ClientSecret: "fakeone_a654+9sdf7+8we4f",
ApiKey: "",
Logger: zapLogger,
RetryMaxElapsedTimeSeconds: 300,
}

// instantiating authenticate obj, injecting httpClient object
var authenticate, _ = authentication.Authenticate(*httpClientObj, backoffDefinition, "https://fake.api.com:443/BeyondTrust/api/public/v3/", "fakeone_a654+9sdf7+8we4f", "fakeone_aasd156465sfdef", zapLogger, 300)
var authenticate, _ = authentication.Authenticate(*authParamsOauth)

apiUrl, _ := url.Parse(testConfig.server.URL + "/")
authenticate.ApiUrl = *apiUrl
Expand Down
18 changes: 17 additions & 1 deletion fuzzing/secrets/get_secrets_fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ type TestConfig struct {
response string
}

// the recommended version is 3.1. If no version is specified,
// the default API version 3.0 will be used
var apiVersion string = "3.1"

func FuzzGetSecret(f *testing.F) {

testConfig := TestConfig{
Expand Down Expand Up @@ -72,8 +76,20 @@ func FuzzGetSecret(f *testing.F) {
backoffDefinition := backoff.NewExponentialBackOff()
backoffDefinition.MaxElapsedTime = time.Second

authParamsOauth := &authentication.AuthenticationParametersObj{
HTTPClient: *httpClientObj,
BackoffDefinition: backoffDefinition,
EndpointURL: "https://fake.api.com:443/BeyondTrust/api/public/v3/",
APIVersion: apiVersion,
ClientID: "fakeone_a654+9sdf7+8we4f",
ClientSecret: "fakeone_a654+9sdf7+8we4f",
ApiKey: "",
Logger: zapLogger,
RetryMaxElapsedTimeSeconds: 300,
}

// instantiating authenticate obj, injecting httpClient object
var authenticate, _ = authentication.Authenticate(*httpClientObj, backoffDefinition, "https://fake.api.com:443/BeyondTrust/api/public/v3/", "fakeone_a654+9sdf7+8we4f", "fakeone_aasd156465sfdef", zapLogger, 300)
var authenticate, _ = authentication.Authenticate(*authParamsOauth)

apiUrl, _ := url.Parse(testConfig.server.URL + "/")
authenticate.ApiUrl = *apiUrl
Expand Down

0 comments on commit 1b7968b

Please sign in to comment.