config: multiple endpoints for authorize and databroker (#1957)

* wip

* update docs

* remove dead code
This commit is contained in:
Caleb Doxsey 2021-03-03 09:53:19 -07:00 committed by GitHub
parent 0f0a50be40
commit 664358dfad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 440 additions and 405 deletions

View file

@ -1,7 +1,6 @@
package authorize
import (
"net/url"
"testing"
"github.com/stretchr/testify/assert"
@ -21,40 +20,40 @@ func TestNew(t *testing.T) {
{
"good",
config.Options{
AuthenticateURL: mustParseURL("https://authN.example.com"),
DataBrokerURL: mustParseURL("https://databroker.example.com"),
SharedKey: "2p/Wi2Q6bYDfzmoSEbKqYKtg+DUoLWTEHHs7vOhvL7w=",
Policies: policies,
AuthenticateURL: mustParseURL("https://authN.example.com"),
DataBrokerURLString: "https://databroker.example.com",
SharedKey: "2p/Wi2Q6bYDfzmoSEbKqYKtg+DUoLWTEHHs7vOhvL7w=",
Policies: policies,
},
false,
},
{
"bad shared secret",
config.Options{
AuthenticateURL: mustParseURL("https://authN.example.com"),
DataBrokerURL: mustParseURL("https://databroker.example.com"),
SharedKey: "AZA85podM73CjLCjViDNz1EUvvejKpWp7Hysr0knXA==",
Policies: policies,
AuthenticateURL: mustParseURL("https://authN.example.com"),
DataBrokerURLString: "https://databroker.example.com",
SharedKey: "AZA85podM73CjLCjViDNz1EUvvejKpWp7Hysr0knXA==",
Policies: policies,
},
true,
},
{
"really bad shared secret",
config.Options{
AuthenticateURL: mustParseURL("https://authN.example.com"),
DataBrokerURL: mustParseURL("https://databroker.example.com"),
SharedKey: "sup",
Policies: policies,
AuthenticateURL: mustParseURL("https://authN.example.com"),
DataBrokerURLString: "https://databroker.example.com",
SharedKey: "sup",
Policies: policies,
},
true,
},
{
"validation error, short secret",
config.Options{
AuthenticateURL: mustParseURL("https://authN.example.com"),
DataBrokerURL: mustParseURL("https://databroker.example.com"),
SharedKey: "AZA85podM73CjLCjViDNz1EUvvejKpWp7Hysr0knXA==",
Policies: policies,
AuthenticateURL: mustParseURL("https://authN.example.com"),
DataBrokerURLString: "https://databroker.example.com",
SharedKey: "AZA85podM73CjLCjViDNz1EUvvejKpWp7Hysr0knXA==",
Policies: policies,
},
true,
},
@ -62,10 +61,10 @@ func TestNew(t *testing.T) {
{
"bad databroker url",
config.Options{
AuthenticateURL: mustParseURL("https://authN.example.com"),
DataBrokerURL: &url.URL{},
SharedKey: "AZA85podM73CjLCjViDNz1EUvvejKpWp7Hysr0knXA==",
Policies: policies,
AuthenticateURL: mustParseURL("https://authN.example.com"),
DataBrokerURLString: "BAD",
SharedKey: "AZA85podM73CjLCjViDNz1EUvvejKpWp7Hysr0knXA==",
Policies: policies,
},
true,
},
@ -100,10 +99,10 @@ func TestAuthorize_OnConfigChange(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
o := &config.Options{
AuthenticateURL: mustParseURL("https://authN.example.com"),
DataBrokerURL: mustParseURL("https://databroker.example.com"),
SharedKey: tc.SharedKey,
Policies: tc.Policies,
AuthenticateURL: mustParseURL("https://authN.example.com"),
DataBrokerURLString: "https://databroker.example.com",
SharedKey: tc.SharedKey,
Policies: tc.Policies,
}
a, err := New(&config.Config{Options: o})
require.NoError(t, err)