Skip to content

Commit

Permalink
Add configure module test
Browse files Browse the repository at this point in the history
  • Loading branch information
tinaboyce committed Dec 27, 2023
1 parent 4c09fe7 commit a4b0362
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions cmd/saml2aws/commands/configure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,26 @@ import (
"github.com/versent/saml2aws/v2/pkg/provider/onelogin"
)

// Configure module
func TestConfigureStoresCredentialOnSupportedStorage(t *testing.T) {
commonFlags := &flags.CommonFlags{URL: "https://id.example.com", Username: "some-username", Password: "password", SkipPrompt: true}
creds := &credentials.Credentials{ServerURL: "https://id.example.com", Username: "some-username", Secret: "password"}
helperMock := &mocks.Helper{}
helperMock.Mock.On("Add", creds).Return(nil).Once()
helperMock.Mock.On("SupportsCredentialStorage").Return(true).Once()
oldCurrentHelper := credentials.CurrentHelper
credentials.CurrentHelper = helperMock

err := Configure(commonFlags)
// making linter happy
if err != nil {
credentials.CurrentHelper = oldCurrentHelper
}

helperMock.AssertCalled(t, "Add", creds)
credentials.CurrentHelper = oldCurrentHelper
}

// Store Credentials module
func TestStoreCredentialsOnDisabledKeychainFlagReturnsNil(t *testing.T) {
commonFlags := &flags.CommonFlags{DisableKeychain: true}
Expand Down

0 comments on commit a4b0362

Please sign in to comment.