proxy: move properties to atomically updated state (#1280)

* authenticate: remove cookie options

* authenticate: remove shared key field

* authenticate: remove shared cipher property

* authenticate: move properties to separate state struct

* proxy: allow local state to be updated on configuration changes

* fix test

* return new connection

* use warn, collapse to single line

* address concerns, fix tests
This commit is contained in:
Caleb Doxsey 2020-08-14 11:44:58 -06:00 committed by GitHub
parent 23eea09ed0
commit d9a224a5e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 305 additions and 147 deletions

View file

@ -7,6 +7,7 @@ import (
"testing"
"time"
"github.com/stretchr/testify/assert"
"google.golang.org/grpc"
)
@ -77,3 +78,39 @@ func TestNewGRPC(t *testing.T) {
})
}
}
func TestGetGRPC(t *testing.T) {
cc1, err := GetGRPCClientConn("example", &Options{
Addr: mustParseURL("https://localhost.example"),
})
if !assert.NoError(t, err) {
return
}
cc2, err := GetGRPCClientConn("example", &Options{
Addr: mustParseURL("https://localhost.example"),
})
if !assert.NoError(t, err) {
return
}
assert.Equal(t, cc1, cc2, "GetGRPCClientConn should return the same connection when there are no changes")
cc3, err := GetGRPCClientConn("example", &Options{
Addr: mustParseURL("http://localhost.example"),
WithInsecure: true,
})
if !assert.NoError(t, err) {
return
}
assert.NotEqual(t, cc1, cc3, "GetGRPCClientConn should return a new connection when there are changes")
}
func mustParseURL(rawurl string) *url.URL {
u, err := url.Parse(rawurl)
if err != nil {
panic(err)
}
return u
}