1+ // httpclient_auth_validation_test.go
12package httpclient
23
34import (
@@ -7,6 +8,10 @@ import (
78 "github.com/stretchr/testify/assert"
89)
910
11+ // TestIsValidClientID tests the IsValidClientID function with various client ID inputs.
12+ // It verifies that valid UUIDs are correctly identified as such, and invalid formats
13+ // are appropriately flagged with an error message. Additionally, it checks that empty
14+ // client IDs are considered valid according to the updated logic.
1015func TestIsValidClientID (t * testing.T ) {
1116 tests := []struct {
1217 clientID string
@@ -25,6 +30,10 @@ func TestIsValidClientID(t *testing.T) {
2530 }
2631}
2732
33+ // TestIsValidClientSecret tests the IsValidClientSecret function with various client secret inputs.
34+ // It ensures that client secrets that meet the minimum length requirement and contain the necessary
35+ // character types are validated correctly. It also checks that short or invalid client secrets are
36+ // flagged appropriately, and that empty client secrets are considered valid as per the updated logic.
2837func TestIsValidClientSecret (t * testing.T ) {
2938 tests := []struct {
3039 clientSecret string
@@ -43,6 +52,10 @@ func TestIsValidClientSecret(t *testing.T) {
4352 }
4453}
4554
55+ // TestIsValidUsername tests the IsValidUsername function with various username inputs.
56+ // This function verifies that usernames consisting of alphanumeric characters and password safe
57+ // special characters are considered valid. It also checks that usernames with unsafe characters
58+ // are correctly identified as invalid.
4659func TestIsValidUsername (t * testing.T ) {
4760 tests := []struct {
4861 username string
@@ -61,6 +74,9 @@ func TestIsValidUsername(t *testing.T) {
6174 }
6275}
6376
77+ // TestIsValidPassword tests the IsValidPassword function with various password inputs.
78+ // It ensures that passwords meeting the minimum length requirement are validated correctly,
79+ // and that short passwords are appropriately flagged as invalid.
6480func TestIsValidPassword (t * testing.T ) {
6581 tests := []struct {
6682 password string
@@ -78,6 +94,11 @@ func TestIsValidPassword(t *testing.T) {
7894 }
7995}
8096
97+ // TestDetermineAuthMethod tests the DetermineAuthMethod function with various authentication configurations.
98+ // It checks that the function correctly identifies the authentication method to be used based on the provided
99+ // credentials. Scenarios include valid OAuth credentials, valid bearer token credentials, and various combinations
100+ // of invalid or missing credentials. The function should return "oauth" for valid OAuth credentials, "bearer" for
101+ // valid bearer token credentials, and "unknown" with an error message for invalid or incomplete credentials.
81102func TestDetermineAuthMethod (t * testing.T ) {
82103 tests := []struct {
83104 authConfig AuthConfig
0 commit comments