-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
provider/pagerduty: Validate credentials (#12854)
* Validate credentials * Add ability to skip validation * Update provider documentation * invalidCredentials -> invalidCreds * Include original error message * Update description for skip_credentials_validation * Add config test * set skip_credentials_validation default to false
- Loading branch information
Showing
5 changed files
with
72 additions
and
1 deletion.
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,28 @@ | ||
package pagerduty | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
// Test config with an empty token | ||
func TestConfigEmptyToken(t *testing.T) { | ||
config := Config{ | ||
Token: "", | ||
} | ||
|
||
if _, err := config.Client(); err == nil { | ||
t.Fatalf("expected error, but got nil") | ||
} | ||
} | ||
|
||
// Test config with invalid token but with SkipCredsValidation | ||
func TestConfigSkipCredsValidation(t *testing.T) { | ||
config := Config{ | ||
Token: "foo", | ||
SkipCredsValidation: true, | ||
} | ||
|
||
if _, err := config.Client(); err != nil { | ||
t.Fatalf("error: expected the client to not fail: %v", err) | ||
} | ||
} |
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
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