forked from grepplabs/kafka-proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
233 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ sudo: false | |
language: go | ||
|
||
go: | ||
- "1.10.x" | ||
- "1.11.x" | ||
|
||
env: | ||
global: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM golang:1.10 as builder | ||
FROM golang:1.11 as builder | ||
|
||
ARG GOOS=linux | ||
ARG GOARCH=amd64 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,60 @@ func TestSaslOauthParseToken(t *testing.T) { | |
saslAuthBytes, err := hex.DecodeString(saslBytes) | ||
a.Nil(err) | ||
|
||
token, err := SaslOAuthBearer{}.GetToken(saslAuthBytes) | ||
token, authzid, extensions, err := SaslOAuthBearer{}.GetClientInitialResponse(saslAuthBytes) | ||
a.Nil(err) | ||
a.Empty(authzid) | ||
a.Empty(extensions) | ||
a.Equal("eyJhbGciOiJub25lIn0.eyJleHAiOjEuNTM5NTE2Njk0NDE4RTksImlhdCI6MS41Mzk1MTMwOTQ0MThFOSwic3ViIjoiYWxpY2UyIn0.", token) | ||
|
||
a.Equal(saslAuthBytes, SaslOAuthBearer{}.ToBytes(token, authzid, extensions)) | ||
|
||
} | ||
func TestSaslOAuthBearerToBytes(t *testing.T) { | ||
a := assert.New(t) | ||
token, authzid, extensions, err := SaslOAuthBearer{}.GetClientInitialResponse([]byte("n,,\u0001auth=Bearer 123.345.567\u0001nineteen=42\u0001\u0001")) | ||
a.Nil(err) | ||
a.Equal("123.345.567", token) | ||
a.Empty(authzid) | ||
a.Equal(map[string]string{"nineteen": "42"}, extensions) | ||
} | ||
|
||
func TestSaslOAuthBearerAuthorizationId(t *testing.T) { | ||
a := assert.New(t) | ||
token, authzid, extensions, err := SaslOAuthBearer{}.GetClientInitialResponse([]byte("n,a=myuser,\u0001auth=Bearer 345\u0001\u0001")) | ||
a.Nil(err) | ||
a.Equal("345", token) | ||
a.Equal("myuser", authzid) | ||
a.Empty(extensions) | ||
} | ||
|
||
func TestSaslOAuthBearerExtensions(t *testing.T) { | ||
a := assert.New(t) | ||
token, authzid, extensions, err := SaslOAuthBearer{}.GetClientInitialResponse([]byte("n,,\u0001propA=valueA1, valueA2\u0001auth=Bearer 567\u0001propB=valueB\u0001\u0001")) | ||
a.Nil(err) | ||
a.Equal("567", token) | ||
a.Empty(authzid) | ||
a.Equal(map[string]string{"propA": "valueA1, valueA2", "propB": "valueB"}, extensions) | ||
} | ||
|
||
func TestSaslOAuthBearerRfc7688Example(t *testing.T) { | ||
a := assert.New(t) | ||
message := "n,[email protected],\u0001host=server.example.com\u0001port=143\u0001" + | ||
"auth=Bearer vF9dft4qmTc2Nvb3RlckBhbHRhdmlzdGEuY29tCg\u0001\u0001" | ||
token, authzid, extensions, err := SaslOAuthBearer{}.GetClientInitialResponse([]byte(message)) | ||
a.Nil(err) | ||
a.Equal("vF9dft4qmTc2Nvb3RlckBhbHRhdmlzdGEuY29tCg", token) | ||
a.Equal("[email protected]", authzid) | ||
a.Equal(map[string]string{"host": "server.example.com", "port": "143"}, extensions) | ||
} | ||
|
||
func TestSaslOAuthBearerNoExtensionsFromByteArray(t *testing.T) { | ||
a := assert.New(t) | ||
message := "n,[email protected],\u0001" + | ||
"auth=Bearer vF9dft4qmTc2Nvb3RlckBhbHRhdmlzdGEuY29tCg\u0001\u0001" | ||
token, authzid, extensions, err := SaslOAuthBearer{}.GetClientInitialResponse([]byte(message)) | ||
a.Nil(err) | ||
a.Equal("vF9dft4qmTc2Nvb3RlckBhbHRhdmlzdGEuY29tCg", token) | ||
a.Equal("[email protected]", authzid) | ||
a.Empty(extensions) | ||
} |