Skip to content

Commit 7038359

Browse files
committed
api: create AuthDialer and ProtocolDialer
To disable SSL by default we want to transfer `OpenSslDialer` to the go-openssl repository. In order to do so, we need to minimize the amount of copy-paste of the private functions. `AuthDialer` is created as a dialer-wrapper, that calls authentication methods. `ProtoDialer` is created to check the `ProtocolInfo` in the created connection. `NoAuth` constant is added for dialers, that do not require authentication Part of #301
1 parent 6ba01ff commit 7038359

File tree

7 files changed

+417
-77
lines changed

7 files changed

+417
-77
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ Versioning](http://semver.org/spec/v2.0.0.html) except to the first release.
3737
the response (#237)
3838
- Ability to mock connections for tests (#237). Added new types `MockDoer`,
3939
`MockRequest` to `test_helpers`.
40+
- `AuthDialer` and `ProtocolDialer` types for creating a dialer with
41+
authentication and `ProtocolInfo` check (#301)
42+
- `NoAuth` constant for dialers that do not require authentication (#301)
4043

4144
### Changed
4245

auth.go

+5
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ const (
2727
// available only for the Tarantool Enterprise Edition (EE) with
2828
// SSL transport.
2929
PapSha256Auth
30+
31+
// NoAuth is used when no authentication is needed.
32+
NoAuth Auth = 1 << 15
3033
)
3134

3235
// String returns a string representation of an authentication method.
@@ -38,6 +41,8 @@ func (a Auth) String() string {
3841
return chapSha1
3942
case PapSha256Auth:
4043
return papSha256
44+
case NoAuth:
45+
return "no-auth"
4146
default:
4247
return fmt.Sprintf("unknown auth type (code %d)", a)
4348
}

auth_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ func TestAuth_String(t *testing.T) {
1717
{AutoAuth, "auto"},
1818
{ChapSha1Auth, "chap-sha1"},
1919
{PapSha256Auth, "pap-sha256"},
20+
{NoAuth, "no-auth"},
2021
{Auth(unknownId), fmt.Sprintf("unknown auth type (code %d)", unknownId)},
2122
}
2223

connection.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,9 @@ func (conn *Connection) dial(ctx context.Context) error {
440440
}
441441

442442
conn.addr = c.Addr()
443-
conn.Greeting.Version = c.Greeting().Version
443+
connGreeting := c.Greeting()
444+
conn.Greeting.Version = connGreeting.Version
445+
conn.Greeting.Salt = connGreeting.Salt
444446
conn.serverProtocolInfo = c.ProtocolInfo()
445447

446448
spaceAndIndexNamesSupported :=

0 commit comments

Comments
 (0)