generated from crossplane/provider-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: fetch user credentials in sdk (#78)
Co-authored-by: Erik Godding Boye <[email protected]> Co-authored-by: Amund Tenstad <[email protected]>
- Loading branch information
1 parent
b0e9a00
commit ad0ef0a
Showing
3 changed files
with
74 additions
and
0 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,7 @@ | ||
package cloudian | ||
|
||
type Secret string | ||
|
||
func (s Secret) String() string { | ||
return "********" | ||
} |
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,24 @@ | ||
package cloudian | ||
|
||
import ( | ||
"encoding/json" | ||
"testing" | ||
) | ||
|
||
func TestSecretUnmarshal(t *testing.T) { | ||
jsonString := `[{"accessKey":"124","secretKey":"x+2","createDate":1735894172440,"active":true}]` | ||
|
||
var secrets []SecurityInfo | ||
err := json.Unmarshal([]byte(jsonString), &secrets) | ||
if err != nil { | ||
t.Errorf("Error deserializing from JSON: %v", err) | ||
} | ||
|
||
if string(secrets[0].AccessKey) != "124" { | ||
t.Errorf("Expected string equality to 124, got %v", secrets[0].AccessKey) | ||
} | ||
|
||
if secrets[0].AccessKey.String() != "********" { | ||
t.Errorf("Expected obfuscated string, got %v", secrets[0].SecretKey) | ||
} | ||
} |