-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes Hashivault configuration with Chains
Initially when kms was misconfigured, then the chains controller pod was getting panic and ended up getting crashed Hence, this patch checks it the vault address is valid and if it is not valid, then returns the error which handles the pod from getting panic and crashed Signed-off-by: PuneetPunamiya <[email protected]>
- Loading branch information
1 parent
52b918e
commit c18a75b
Showing
2 changed files
with
62 additions
and
2 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,45 @@ | ||
/* | ||
Copyright 2023 The Tekton Authors | ||
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 kms creates a signer using a key management server | ||
|
||
package kms | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/tektoncd/chains/pkg/config" | ||
) | ||
|
||
func TestInValidVaultAddressTimeout(t *testing.T) { | ||
cfg := config.KMSSigner{} | ||
cfg.Auth.Address = "http://8.8.8.8:8200" | ||
|
||
_, err := NewSigner(context.TODO(), cfg) | ||
expectedErrorMessage := "dial tcp 8.8.8.8:8200: i/o timeout" | ||
if err.Error() != expectedErrorMessage { | ||
t.Errorf("Expected error message '%s', but got '%s'", expectedErrorMessage, err.Error()) | ||
} | ||
} | ||
|
||
func TestInValidVaultAddressConnectionRefused(t *testing.T) { | ||
cfg := config.KMSSigner{} | ||
cfg.Auth.Address = "http://127.0.0.1:8200" | ||
|
||
_, err := NewSigner(context.TODO(), cfg) | ||
expectedErrorMessage := "dial tcp 127.0.0.1:8200: connect: connection refused" | ||
if err.Error() != expectedErrorMessage { | ||
t.Errorf("Expected error message '%s', but got '%s'", expectedErrorMessage, err.Error()) | ||
} | ||
} |