-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(extension/googleclientauth): support id-token (#851)
* feat(extension/googleclientauth): support id-token Signed-off-by: Rintaro Okamura <rintaro.okamura@gmail.com> * fix(extension/googleclientauth): add validation for token_format Signed-off-by: Rintaro Okamura <rintaro.okamura@gmail.com> * refactor(extensions/googleclientauth): use iota for token_format values Signed-off-by: Rintaro Okamura <rintaro.okamura@gmail.com> * fix(extensions/googleclientauth): use same credential Signed-off-by: Rintaro Okamura <rintaro.okamura@gmail.com> * fixup! refactor(extensions/googleclientauth): use iota for token_format values Signed-off-by: Rintaro Okamura <rintaro.okamura@gmail.com> * refactor(extension/googleclientauth): validate audience in validate function Signed-off-by: Rintaro Okamura <rintaro.okamura@gmail.com> * refactor(extension/googleclientauth): remove redundant case Signed-off-by: Rintaro Okamura <rintaro.okamura@gmail.com> * refactor(extension/googleclientauth): remove enum - and simplify token_type related codes Signed-off-by: Rintaro Okamura <rintaro.okamura@gmail.com> * test(extension/googleclientauth): add cases for id_token Signed-off-by: Rintaro Okamura <rintaro.okamura@gmail.com> * Update extension/googleclientauthextension/config.go Co-authored-by: David Ashpole <dashpole@google.com> Signed-off-by: Rintaro Okamura <rintaro.okamura@gmail.com> --------- Signed-off-by: Rintaro Okamura <rintaro.okamura@gmail.com> Co-authored-by: David Ashpole <dashpole@google.com>
- Loading branch information
Showing
9 changed files
with
296 additions
and
6 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
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,58 @@ | ||
// Copyright 2024 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package googleclientauthextension // import "github.com/GoogleCloudPlatform/opentelemetry-operations-go/extension/googleclientauthextension" | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestConfig_Validate_ValidAccessToken(t *testing.T) { | ||
cfg := &Config{ | ||
TokenType: accessToken, | ||
} | ||
|
||
err := cfg.Validate() | ||
assert.NoError(t, err) | ||
} | ||
|
||
func TestConfig_Validate_ValidIDToken(t *testing.T) { | ||
cfg := &Config{ | ||
TokenType: idToken, | ||
Audience: "audience", | ||
} | ||
|
||
err := cfg.Validate() | ||
assert.NoError(t, err) | ||
} | ||
|
||
func TestConfig_Validate_MissingAudience(t *testing.T) { | ||
cfg := &Config{ | ||
TokenType: idToken, | ||
} | ||
|
||
err := cfg.Validate() | ||
assert.Error(t, err) | ||
} | ||
|
||
func TestConfig_Validate_Invalid(t *testing.T) { | ||
cfg := &Config{ | ||
TokenType: "invalid", | ||
} | ||
|
||
err := cfg.Validate() | ||
assert.Error(t, 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
Oops, something went wrong.