git-lfs/lfsapi/ntlm_auth_test_nix.go
Fabrizio Steiner 2a166fd94e Use SSPI ntlm authentication on windows:
This brings support for SingleSignOn on windows using the default credentials of the currently logged in user if
an empty username and empty password is provided from gitcredentials. This plays well with the Git for windows
implementation which stores an empty username and password if it should use the default credentials.
2018-02-27 17:02:57 +01:00

37 lines
965 B
Go

// +build !windows
package lfsapi
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestNtlmClientSession(t *testing.T) {
cli, err := NewClient(nil)
require.Nil(t, err)
creds := &ntmlCredentials{domain: "MOOSEDOMAIN", username: "canadian", password: "MooseAntlersYeah"}
session1, err := cli.ntlmClientSession(creds)
assert.Nil(t, err)
assert.NotNil(t, session1)
// The second call should ignore creds and give the session we just created.
badCreds := &ntmlCredentials{domain: "MOOSEDOMAIN", username: "badusername", password: "MooseAntlersYeah"}
session2, err := cli.ntlmClientSession(badCreds)
assert.Nil(t, err)
assert.NotNil(t, session2)
assert.EqualValues(t, session1, session2)
}
func TestNtlmClientSessionBadCreds(t *testing.T) {
cli, err := NewClient(nil)
require.Nil(t, err)
// Single-Sign-On is not supported on *nix
_, err = cli.ntlmClientSession(nil)
assert.NotNil(t, err)
}