Skip to content

Instantly share code, notes, and snippets.

@cjbj
Created August 7, 2020 07:37
Show Gist options
  • Save cjbj/75c97fed20b052c0515a1439f4f95c2d to your computer and use it in GitHub Desktop.
Save cjbj/75c97fed20b052c0515a1439f4f95c2d to your computer and use it in GitHub Desktop.
cjones@localhost:~/go/src/github.com/godror/godror$ echo $(git log --pretty=format:'%h ' -n 1)
ac04606
cjones@localhost:~/go/src/github.com/godror/godror$ go test ./dsn
--- FAIL: TestParse (0.00s)
--- FAIL: TestParse/logfmt (0.00s)
dsn_test.go:213: user=user password=pass connectString=localhost/sid heterogeneousPool=1
dsn_test.go:220: parse of "user=user password=pass connectString=localhost/sid heterogeneousPool=1"
got
dsn.ConnectionParams{CommonParams:dsn.CommonParams{Username:"user", ConnectString:"", Password:dsn.Password{secret:"pass"}, ConfigDir:"", LibDir:"", OnInit:(func(driver.Conn) error)(nil), OnInitStmts:[]string(nil), AlterSession:[][2]string(nil), Timezone:(*time.Location)(0x732ce0), EnableEvents:false}, ConnParams:dsn.ConnParams{NewPassword:dsn.Password{secret:""}, ConnClass:"", IsSysDBA:false, IsSysOper:false, IsSysASM:false, IsPrelim:false, ShardingKey:[]interface {}(nil), SuperShardingKey:[]interface {}(nil)}, PoolParams:dsn.PoolParams{MinSessions:1, MaxSessions:1000, SessionIncrement:1, WaitTimeout:30000000000, MaxLifeTime:3600000000000, SessionTimeout:300000000000, Heterogeneous:true, ExternalAuth:false}, NewPassword:dsn.Password{secret:""}, StandaloneConnection:false},
wanted
dsn.ConnectionParams{CommonParams:dsn.CommonParams{Username:"user", ConnectString:"localhost/Sid", Password:dsn.Password{secret:"pass"}, ConfigDir:"", LibDir:"", OnInit:(func(driver.Conn) error)(nil), OnInitStmts:[]string(nil), AlterSession:[][2]string(nil), Timezone:(*time.Location)(0x732ce0), EnableEvents:false}, ConnParams:dsn.ConnParams{NewPassword:dsn.Password{secret:""}, ConnClass:"", IsSysDBA:false, IsSysOper:false, IsSysASM:false, IsPrelim:false, ShardingKey:[]interface {}(nil), SuperShardingKey:[]interface {}(nil)}, PoolParams:dsn.PoolParams{MinSessions:1, MaxSessions:1000, SessionIncrement:1, WaitTimeout:30000000000, MaxLifeTime:3600000000000, SessionTimeout:300000000000, Heterogeneous:true, ExternalAuth:false}, NewPassword:dsn.Password{secret:""}, StandaloneConnection:false}
  dsn.ConnectionParams{
   CommonParams: dsn.CommonParams{
   Username: "user",
-  ConnectString: "localhost/Sid",
+  ConnectString: "",
   Password: s"SECRET-rO3TfrHuUhY=",
   ConfigDir: "",
   ... // 6 identical fields
   },
   ConnParams: dsn.ConnParams{},
   PoolParams: dsn.PoolParams{MinSessions: 1, MaxSessions: 1000, SessionIncrement: 1, WaitTimeout: s"30s", MaxLifeTime: s"1h0m0s", SessionTimeout: s"5m0s", Heterogeneous: true},
   ... // 2 identical fields
  }
--- FAIL: TestParse/logfmt_libDir (0.00s)
dsn_test.go:213: user="user" password="pass"
connectString="localhost/orclpdb1"
libDir="/Users/cjones/instantclient_19_3"
dsn_test.go:220: parse of "user=\"user\" password=\"pass\" \n\t\t\tconnectString=\"localhost/orclpdb1\"\n\t\t\tlibDir=\"/Users/cjones/instantclient_19_3\""
got
dsn.ConnectionParams{CommonParams:dsn.CommonParams{Username:"user", ConnectString:"", Password:dsn.Password{secret:"pass"}, ConfigDir:"", LibDir:"/Users/cjones/instantclient_19_3", OnInit:(func(driver.Conn) error)(nil), OnInitStmts:[]string(nil), AlterSession:[][2]string(nil), Timezone:(*time.Location)(0x732ce0), EnableEvents:false}, ConnParams:dsn.ConnParams{NewPassword:dsn.Password{secret:""}, ConnClass:"", IsSysDBA:false, IsSysOper:false, IsSysASM:false, IsPrelim:false, ShardingKey:[]interface {}(nil), SuperShardingKey:[]interface {}(nil)}, PoolParams:dsn.PoolParams{MinSessions:1, MaxSessions:1000, SessionIncrement:1, WaitTimeout:30000000000, MaxLifeTime:3600000000000, SessionTimeout:300000000000, Heterogeneous:false, ExternalAuth:false}, NewPassword:dsn.Password{secret:""}, StandaloneConnection:false},
wanted
dsn.ConnectionParams{CommonParams:dsn.CommonParams{Username:"user", ConnectString:"localhost/orclpdb1", Password:dsn.Password{secret:"pass"}, ConfigDir:"", LibDir:"/Users/cjones/instantclient_19_3", OnInit:(func(driver.Conn) error)(nil), OnInitStmts:[]string(nil), AlterSession:[][2]string(nil), Timezone:(*time.Location)(0x732ce0), EnableEvents:false}, ConnParams:dsn.ConnParams{NewPassword:dsn.Password{secret:""}, ConnClass:"", IsSysDBA:false, IsSysOper:false, IsSysASM:false, IsPrelim:false, ShardingKey:[]interface {}(nil), SuperShardingKey:[]interface {}(nil)}, PoolParams:dsn.PoolParams{MinSessions:1, MaxSessions:1000, SessionIncrement:1, WaitTimeout:30000000000, MaxLifeTime:3600000000000, SessionTimeout:300000000000, Heterogeneous:false, ExternalAuth:false}, NewPassword:dsn.Password{secret:""}, StandaloneConnection:false}
  dsn.ConnectionParams{
   CommonParams: dsn.CommonParams{
   Username: "user",
-  ConnectString: "localhost/orclpdb1",
+  ConnectString: "",
   Password: s"SECRET-rO3TfrHuUhY=",
   ConfigDir: "",
   ... // 6 identical fields
   },
   ConnParams: dsn.ConnParams{},
   PoolParams: dsn.PoolParams{MinSessions: 1, MaxSessions: 1000, SessionIncrement: 1, WaitTimeout: s"30s", MaxLifeTime: s"1h0m0s", SessionTimeout: s"5m0s"},
   ... // 2 identical fields
  }
--- FAIL: TestParse/logfmt_multiline (0.00s)
dsn_test.go:213: user=user
password=pass
connectString=localhost/sid
heterogeneousPool=1
dsn_test.go:220: parse of "user=user\npassword=pass\nconnectString=localhost/sid\nheterogeneousPool=1"
got
dsn.ConnectionParams{CommonParams:dsn.CommonParams{Username:"user", ConnectString:"", Password:dsn.Password{secret:"pass"}, ConfigDir:"", LibDir:"", OnInit:(func(driver.Conn) error)(nil), OnInitStmts:[]string(nil), AlterSession:[][2]string(nil), Timezone:(*time.Location)(0x732ce0), EnableEvents:false}, ConnParams:dsn.ConnParams{NewPassword:dsn.Password{secret:""}, ConnClass:"", IsSysDBA:false, IsSysOper:false, IsSysASM:false, IsPrelim:false, ShardingKey:[]interface {}(nil), SuperShardingKey:[]interface {}(nil)}, PoolParams:dsn.PoolParams{MinSessions:1, MaxSessions:1000, SessionIncrement:1, WaitTimeout:30000000000, MaxLifeTime:3600000000000, SessionTimeout:300000000000, Heterogeneous:true, ExternalAuth:false}, NewPassword:dsn.Password{secret:""}, StandaloneConnection:false},
wanted
dsn.ConnectionParams{CommonParams:dsn.CommonParams{Username:"user", ConnectString:"localhost/Sid", Password:dsn.Password{secret:"pass"}, ConfigDir:"", LibDir:"", OnInit:(func(driver.Conn) error)(nil), OnInitStmts:[]string(nil), AlterSession:[][2]string(nil), Timezone:(*time.Location)(0x732ce0), EnableEvents:false}, ConnParams:dsn.ConnParams{NewPassword:dsn.Password{secret:""}, ConnClass:"", IsSysDBA:false, IsSysOper:false, IsSysASM:false, IsPrelim:false, ShardingKey:[]interface {}(nil), SuperShardingKey:[]interface {}(nil)}, PoolParams:dsn.PoolParams{MinSessions:1, MaxSessions:1000, SessionIncrement:1, WaitTimeout:30000000000, MaxLifeTime:3600000000000, SessionTimeout:300000000000, Heterogeneous:true, ExternalAuth:false}, NewPassword:dsn.Password{secret:""}, StandaloneConnection:false}
  dsn.ConnectionParams{
   CommonParams: dsn.CommonParams{
   Username: "user",
-  ConnectString: "localhost/Sid",
+  ConnectString: "",
   Password: s"SECRET-rO3TfrHuUhY=",
   ConfigDir: "",
   ... // 6 identical fields
   },
   ConnParams: dsn.ConnParams{},
   PoolParams: dsn.PoolParams{MinSessions: 1, MaxSessions: 1000, SessionIncrement: 1, WaitTimeout: s"30s", MaxLifeTime: s"1h0m0s", SessionTimeout: s"5m0s", Heterogeneous: true},
   ... // 2 identical fields
  }
--- FAIL: TestParse/easy (0.00s)
dsn_test.go:213: scott@tcps://salesserver1:1521/sales.us.example.com?ssl_server_cert_dn="cn=sales,cn=Oracle Context Server,dc=us,dc=example,dc=com"&sdu=8128&connect_timeout=60
dsn_test.go:220: parse of "scott@tcps://salesserver1:1521/sales.us.example.com?ssl_server_cert_dn=\"cn=sales,cn=Oracle Context Server,dc=us,dc=example,dc=com\"&sdu=8128&connect_timeout=60"
got
dsn.ConnectionParams{CommonParams:dsn.CommonParams{Username:"", ConnectString:"scott@tcps://salesserver1:1521/sales.us.example.com?ssl_server_cert_dn=\"cn=sales,cn=Oracle Context Server,dc=us,dc=example,dc=com\"&sdu=8128&connect_timeout=60", Password:dsn.Password{secret:""}, ConfigDir:"", LibDir:"", OnInit:(func(driver.Conn) error)(nil), OnInitStmts:[]string(nil), AlterSession:[][2]string(nil), Timezone:(*time.Location)(0x732ce0), EnableEvents:false}, ConnParams:dsn.ConnParams{NewPassword:dsn.Password{secret:""}, ConnClass:"", IsSysDBA:false, IsSysOper:false, IsSysASM:false, IsPrelim:false, ShardingKey:[]interface {}(nil), SuperShardingKey:[]interface {}(nil)}, PoolParams:dsn.PoolParams{MinSessions:1, MaxSessions:1000, SessionIncrement:1, WaitTimeout:30000000000, MaxLifeTime:3600000000000, SessionTimeout:300000000000, Heterogeneous:false, ExternalAuth:true}, NewPassword:dsn.Password{secret:""}, StandaloneConnection:false},
wanted
dsn.ConnectionParams{CommonParams:dsn.CommonParams{Username:"scott", ConnectString:"tcps://salesserver1:1521/sales.us.example.com?ssl_server_cert_dn=\"cn=sales,cn=Oracle Context Server,dc=us,dc=example,dc=com\"&sdu=8128&connect_timeout=60", Password:dsn.Password{secret:""}, ConfigDir:"", LibDir:"", OnInit:(func(driver.Conn) error)(nil), OnInitStmts:[]string(nil), AlterSession:[][2]string(nil), Timezone:(*time.Location)(0x732ce0), EnableEvents:false}, ConnParams:dsn.ConnParams{NewPassword:dsn.Password{secret:""}, ConnClass:"", IsSysDBA:false, IsSysOper:false, IsSysASM:false, IsPrelim:false, ShardingKey:[]interface {}(nil), SuperShardingKey:[]interface {}(nil)}, PoolParams:dsn.PoolParams{MinSessions:1, MaxSessions:1000, SessionIncrement:1, WaitTimeout:30000000000, MaxLifeTime:3600000000000, SessionTimeout:300000000000, Heterogeneous:false, ExternalAuth:false}, NewPassword:dsn.Password{secret:""}, StandaloneConnection:false}
  dsn.ConnectionParams{
   CommonParams: dsn.CommonParams{
-  Username: "scott",
+  Username: "",
   ConnectString: strings.Join({
+  "scott@",
   "tcps://salesserver1:1521/sales.us.example.com?ssl_server_cert_dn",
   `="cn=sales,cn=Oracle Context Server,dc=us,dc=example,dc=com"&sdu`,
   "=8128&connect_timeout=60",
   }, ""),
   Password: s"",
   ConfigDir: "",
   ... // 6 identical fields
   },
   ConnParams: dsn.ConnParams{},
   PoolParams: dsn.PoolParams{
   ... // 5 identical fields
   SessionTimeout: s"5m0s",
   Heterogeneous: false,
-  ExternalAuth: false,
+  ExternalAuth: true,
   },
   NewPassword: s"",
   StandaloneConnection: false,
  }
--- FAIL: TestParse/logfmt_oldpw (0.00s)
dsn_test.go:213: connectString=user/pass@localhost/sid heterogeneousPool=1
dsn_test.go:220: parse of "connectString=user/pass@localhost/sid heterogeneousPool=1"
got
dsn.ConnectionParams{CommonParams:dsn.CommonParams{Username:"user", ConnectString:"localhost/sid", Password:dsn.Password{secret:"pass"}, ConfigDir:"", LibDir:"", OnInit:(func(driver.Conn) error)(nil), OnInitStmts:[]string(nil), AlterSession:[][2]string(nil), Timezone:(*time.Location)(0x732ce0), EnableEvents:false}, ConnParams:dsn.ConnParams{NewPassword:dsn.Password{secret:""}, ConnClass:"", IsSysDBA:false, IsSysOper:false, IsSysASM:false, IsPrelim:false, ShardingKey:[]interface {}(nil), SuperShardingKey:[]interface {}(nil)}, PoolParams:dsn.PoolParams{MinSessions:1, MaxSessions:1000, SessionIncrement:1, WaitTimeout:30000000000, MaxLifeTime:3600000000000, SessionTimeout:300000000000, Heterogeneous:true, ExternalAuth:false}, NewPassword:dsn.Password{secret:""}, StandaloneConnection:false},
wanted
dsn.ConnectionParams{CommonParams:dsn.CommonParams{Username:"user", ConnectString:"localhost/Sid", Password:dsn.Password{secret:"pass"}, ConfigDir:"", LibDir:"", OnInit:(func(driver.Conn) error)(nil), OnInitStmts:[]string(nil), AlterSession:[][2]string(nil), Timezone:(*time.Location)(0x732ce0), EnableEvents:false}, ConnParams:dsn.ConnParams{NewPassword:dsn.Password{secret:""}, ConnClass:"", IsSysDBA:false, IsSysOper:false, IsSysASM:false, IsPrelim:false, ShardingKey:[]interface {}(nil), SuperShardingKey:[]interface {}(nil)}, PoolParams:dsn.PoolParams{MinSessions:1, MaxSessions:1000, SessionIncrement:1, WaitTimeout:30000000000, MaxLifeTime:3600000000000, SessionTimeout:300000000000, Heterogeneous:true, ExternalAuth:false}, NewPassword:dsn.Password{secret:""}, StandaloneConnection:false}
  dsn.ConnectionParams{
   CommonParams: dsn.CommonParams{
   Username: "user",
-  ConnectString: "localhost/Sid",
+  ConnectString: "localhost/sid",
   Password: s"SECRET-rO3TfrHuUhY=",
   ConfigDir: "",
   ... // 6 identical fields
   },
   ConnParams: dsn.ConnParams{},
   PoolParams: dsn.PoolParams{MinSessions: 1, MaxSessions: 1000, SessionIncrement: 1, WaitTimeout: s"30s", MaxLifeTime: s"1h0m0s", SessionTimeout: s"5m0s", Heterogeneous: true},
   ... // 2 identical fields
  }
--- FAIL: TestParse/@ (0.00s)
dsn_test.go:213: user=cc password="c@c*1" connectString=192.168.1.1/cc configDir=
connectionClass= enableEvents=0 heterogeneousPool=0 libDir= poolIncrement=0
poolMaxSessions=0 poolMinSessions=0 poolSessionMaxLifetime=1h0m0s poolSessionTimeout=5m0s
poolWaitTimeout=30s prelim=0 standaloneConnection=0 sysasm=0 sysdba=0 sysoper=0
timezone=local
dsn_test.go:220: parse of "user=cc password=\"c@c*1\" connectString=192.168.1.1/cc configDir=\nconnectionClass= enableEvents=0 heterogeneousPool=0 libDir= poolIncrement=0\npoolMaxSessions=0 poolMinSessions=0 poolSessionMaxLifetime=1h0m0s poolSessionTimeout=5m0s\npoolWaitTimeout=30s prelim=0 standaloneConnection=0 sysasm=0 sysdba=0 sysoper=0\ntimezone=local"
got
dsn.ConnectionParams{CommonParams:dsn.CommonParams{Username:"cc", ConnectString:"", Password:dsn.Password{secret:"c@c*1"}, ConfigDir:"", LibDir:"", OnInit:(func(driver.Conn) error)(nil), OnInitStmts:[]string(nil), AlterSession:[][2]string(nil), Timezone:(*time.Location)(0x732ce0), EnableEvents:false}, ConnParams:dsn.ConnParams{NewPassword:dsn.Password{secret:""}, ConnClass:"", IsSysDBA:false, IsSysOper:false, IsSysASM:false, IsPrelim:false, ShardingKey:[]interface {}(nil), SuperShardingKey:[]interface {}(nil)}, PoolParams:dsn.PoolParams{MinSessions:0, MaxSessions:0, SessionIncrement:0, WaitTimeout:30000000000, MaxLifeTime:3600000000000, SessionTimeout:300000000000, Heterogeneous:false, ExternalAuth:false}, NewPassword:dsn.Password{secret:""}, StandaloneConnection:false},
wanted
dsn.ConnectionParams{CommonParams:dsn.CommonParams{Username:"cc", ConnectString:"192.168.1.1/cc", Password:dsn.Password{secret:"c@c*1"}, ConfigDir:"", LibDir:"", OnInit:(func(driver.Conn) error)(nil), OnInitStmts:[]string(nil), AlterSession:[][2]string(nil), Timezone:(*time.Location)(0x732ce0), EnableEvents:false}, ConnParams:dsn.ConnParams{NewPassword:dsn.Password{secret:""}, ConnClass:"", IsSysDBA:false, IsSysOper:false, IsSysASM:false, IsPrelim:false, ShardingKey:[]interface {}(nil), SuperShardingKey:[]interface {}(nil)}, PoolParams:dsn.PoolParams{MinSessions:0, MaxSessions:0, SessionIncrement:0, WaitTimeout:30000000000, MaxLifeTime:3600000000000, SessionTimeout:300000000000, Heterogeneous:false, ExternalAuth:false}, NewPassword:dsn.Password{secret:""}, StandaloneConnection:false}
  dsn.ConnectionParams{
   CommonParams: dsn.CommonParams{
   Username: "cc",
-  ConnectString: "192.168.1.1/cc",
+  ConnectString: "",
   Password: s"SECRET-2rWWtCF_53Q=",
   ConfigDir: "",
   ... // 6 identical fields
   },
   ConnParams: dsn.ConnParams{},
   PoolParams: dsn.PoolParams{WaitTimeout: s"30s", MaxLifeTime: s"1h0m0s", SessionTimeout: s"5m0s"},
   ... // 2 identical fields
  }
FAIL
FAIL github.com/godror/godror/dsn 0.003s
FAIL
cjones@localhost:~/go/src/github.com/godror/godror$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment