Skip to content

Commit

Permalink
add tests for AAD connection strings
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmey committed Jan 30, 2020
1 parent 4875a21 commit 8f194c4
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions conn_str_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ func TestInvalidConnectionString(t *testing.T) {
"failoverport=invalid",
"applicationintent=ReadOnly",

// AAD
"fedauth=ActiveDirectoryApplication;user id=clientidwithouttenantid;clientcertpath=/secrets/spn.pem",
"fedauth=UnknownType",
// encryption cannot be disabled for AAD
"encrypt=DISABLE;fedauth=ActiveDirectoryPassword;user [email protected];password=secret",
"encrypt=DISABLE;fedauth=ActiveDirectoryMSI",
"encrypt=DISABLE;fedauth=ActiveDirectoryApplication;user id=clientid@tenantid;clientcertpath=/secrets/spn.pem",

// ODBC mode
"odbc:password={",
"odbc:password={somepass",
Expand Down Expand Up @@ -74,6 +82,17 @@ func TestValidConnectionString(t *testing.T) {
{"log=64;packet size=8192", func(p connectParams) bool { return p.logFlags == 64 && p.packetSize == 8192 }},
{"log=64;packet size=48000", func(p connectParams) bool { return p.logFlags == 64 && p.packetSize == 32767 }},

// AAD
{"fedauth=ActiveDirectoryPassword;user [email protected];password=secret", func(p connectParams) bool {
return p.fedAuthLibrary == fedAuthLibraryADAL && p.fedAuthADALWorkflow == fedAuthADALWorkflowPassword
}},
{"fedauth=ActiveDirectoryMSI", func(p connectParams) bool {
return p.fedAuthLibrary == fedAuthLibraryADAL && p.fedAuthADALWorkflow == fedAuthADALWorkflowMSI
}},
{"fedauth=ActiveDirectoryApplication;user id=clientid@tenantid;clientcertpath=/secrets/spn.pem", func(p connectParams) bool {
return p.fedAuthLibrary == fedAuthLibrarySecurityToken && p.user == "clientid" && p.aadTenantID == "tenantid" && p.aadClientCertPath == "/secrets/spn.pem"
}},

// those are supported currently, but maybe should not be
{"someparam", func(p connectParams) bool { return true }},
{";;=;", func(p connectParams) bool { return true }},
Expand Down

0 comments on commit 8f194c4

Please sign in to comment.