Skip to content

Commit

Permalink
Added TestSelectUIDPasswordProvider to login flow tests.
Browse files Browse the repository at this point in the history
This tests the code added to detect when the 'dcos-users' provider is
available and select it even if multiple providers are available.

Co-authored-by: Armand Grillet <armand.grillet@outlook.com>
Co-authored-by: Bilal Amarni <bilal.amarni@gmail.com>
  • Loading branch information
armandgrillet and bamarni committed Nov 26, 2018
1 parent 07159a0 commit edb9b75
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions pkg/login/flow_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package login

import (
"testing"

"github.com/spf13/afero"
"github.com/stretchr/testify/require"
)

func TestSelectUIDPasswordProvider(t *testing.T) {
flow := NewFlow(FlowOpts{})
flow.flags = NewFlags(afero.NewMemMapFs(), nil, nil)
flow.flags.username = "hello"
flow.flags.password = "itsme"

providers := Providers{}

providers["login-provider-1"] = &Provider{
ID: "login-provider-1",
Type: DCOSUIDPassword,
Description: "Default DC/OS login provider",
ClientMethod: methodUserCredential,
Config: ProviderConfig{
StartFlowURL: "/acs/api/v1/auth/login",
},
}

providers["login-provider-2"] = &Provider{
ID: "login-provider-2",
Type: DCOSUIDPassword,
Description: "Default DC/OS login provider",
ClientMethod: methodUserCredential,
Config: ProviderConfig{
StartFlowURL: "/acs/api/v1/auth/login",
},
}

provider, err := flow.selectProvider(providers)
require.NoError(t, err)
require.True(t, provider == providers["login-provider-1"] || provider == providers["login-provider-2"])
}

0 comments on commit edb9b75

Please sign in to comment.