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 ae0a7bc
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions conn_str_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ func TestInvalidConnectionString(t *testing.T) {
"trustservercertificate=invalid",
"failoverport=invalid",
"applicationintent=ReadOnly",
"encrypt=DISABLE;tls key log file=key.log",

// 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={",
Expand Down Expand Up @@ -74,6 +83,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 ae0a7bc

Please sign in to comment.