This commit is contained in:
Caleb Doxsey 2022-09-30 12:38:05 -06:00
parent bee64a21b8
commit f9def98eb1
17 changed files with 56 additions and 53 deletions

View file

@ -4,6 +4,6 @@ package opa
import _ "embed" // to embed files import _ "embed" // to embed files
// HeadersRego is the headers.rego script.
//go:embed policy/headers.rego //go:embed policy/headers.rego
// HeadersRego is the headers.rego script.
var HeadersRego string var HeadersRego string

View file

@ -1,3 +1,4 @@
// Package main contains pomerium.
package main package main
import ( import (

View file

@ -1,3 +1,4 @@
// Package main contains the pomerium-integration-tests command.
package main package main
import ( import (
@ -78,12 +79,12 @@ func runGenerateConfiguration(ctx context.Context) error {
} }
asYAML, _ := yaml.JSONToYAML([]byte(contents)) asYAML, _ := yaml.JSONToYAML([]byte(contents))
err = os.MkdirAll(filepath.Dir(dstPath), 0755) err = os.MkdirAll(filepath.Dir(dstPath), 0o755)
if err != nil { if err != nil {
return fmt.Errorf("error creating directory (path=%s): %w", dstPath, err) return fmt.Errorf("error creating directory (path=%s): %w", dstPath, err)
} }
err = os.WriteFile(dstPath, asYAML, 0600) err = os.WriteFile(dstPath, asYAML, 0o600)
if err != nil { if err != nil {
return fmt.Errorf("error writing file (path=%s): %w", dstPath, err) return fmt.Errorf("error writing file (path=%s): %w", dstPath, err)
} }

View file

@ -1,3 +1,4 @@
// Package main contains integration tests.
package main package main
import ( import (

View file

@ -66,7 +66,6 @@ func (claims Claims) Claims(v interface{}) error {
// Flatten flattens the claims to a FlattenedClaims map. For example: // Flatten flattens the claims to a FlattenedClaims map. For example:
// //
// { "a": { "b": { "c": 12345 } } } => { "a.b.c": [12345] } // { "a": { "b": { "c": 12345 } } } => { "a.b.c": [12345] }
//
func (claims Claims) Flatten() FlattenedClaims { func (claims Claims) Flatten() FlattenedClaims {
flattened := make(FlattenedClaims) flattened := make(FlattenedClaims)
for k, v := range claims { for k, v := range claims {

View file

@ -120,7 +120,6 @@ func NewClientFromURL(rawURL string, tlsConfig *tls.Config) (redis.UniversalClie
// pool_timeout: duration // pool_timeout: duration
// idle_timeout: duration // idle_timeout: duration
// idle_check_frequency: duration // idle_check_frequency: duration
//
func ParseClusterURL(rawurl string) (*redis.ClusterOptions, error) { func ParseClusterURL(rawurl string) (*redis.ClusterOptions, error) {
u, err := url.Parse(rawurl) u, err := url.Parse(rawurl)
if err != nil { if err != nil {

View file

@ -1,3 +1,4 @@
// Package main contains main.
package main package main
import ( import (
@ -189,7 +190,8 @@ func saveConfig(ctx context.Context, client databroker.DataBrokerServiceClient,
Type: any.GetTypeUrl(), Type: any.GetTypeUrl(),
Id: "test_config", Id: "test_config",
Data: any, Data: any,
}}}) }},
})
if err != nil { if err != nil {
return err return err
} }

View file

@ -22,8 +22,7 @@ type SignedURL struct {
// NewSignedURL creates a new copy of a URL that can be signed with a shared key. // NewSignedURL creates a new copy of a URL that can be signed with a shared key.
// //
// N.B. It is the user's responsibility to make sure the key is 256 bits and // N.B. It is the user's responsibility to make sure the key is 256 bits and the url is not nil.
// the url is not nil.
func NewSignedURL(key []byte, uri *url.URL) *SignedURL { func NewSignedURL(key []byte, uri *url.URL) *SignedURL {
return &SignedURL{uri: *uri, key: key, timeNow: time.Now} // uri is copied return &SignedURL{uri: *uri, key: key, timeNow: time.Now} // uri is copied
} }

View file

@ -1,5 +1,4 @@
// Package pomerium houses the main pomerium CLI command. // Package pomerium houses the main pomerium CLI command.
//
package pomerium package pomerium
import ( import (

View file

@ -9,12 +9,15 @@ import (
) )
func TestMerge(t *testing.T) { func TestMerge(t *testing.T) {
type key1 struct{}
type key2 struct{}
t.Run("value", func(t *testing.T) { t.Run("value", func(t *testing.T) {
ctx1 := context.WithValue(context.Background(), "key1", "value1") ctx1 := context.WithValue(context.Background(), key1{}, "value1")
ctx2 := context.WithValue(context.Background(), "key2", "value2") ctx2 := context.WithValue(context.Background(), key2{}, "value2")
ctx3, _ := Merge(ctx1, ctx2) ctx3, _ := Merge(ctx1, ctx2)
assert.Equal(t, "value1", ctx3.Value("key1")) assert.Equal(t, "value1", ctx3.Value(key1{}))
assert.Equal(t, "value2", ctx3.Value("key2")) assert.Equal(t, "value2", ctx3.Value(key2{}))
}) })
t.Run("cancel", func(t *testing.T) { t.Run("cancel", func(t *testing.T) {
ctx1, cancel1 := context.WithCancel(context.Background()) ctx1, cancel1 := context.WithCancel(context.Background())

View file

@ -10,7 +10,8 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )
// A keypair for NIST P-256 / secp256r1 // A keypair for NIST P-256 / secp256r1.
//
// Generated using: // Generated using:
// openssl ecparam -genkey -name prime256v1 -outform PEM // openssl ecparam -genkey -name prime256v1 -outform PEM
var pemECPrivateKeyP256 = `-----BEGIN EC PARAMETERS----- var pemECPrivateKeyP256 = `-----BEGIN EC PARAMETERS-----

View file

@ -24,7 +24,6 @@ import (
// - Our KEKs are asymmetric Curve25519 keys. We use the *public* key to encrypt the DEK so only the *private* key can // - Our KEKs are asymmetric Curve25519 keys. We use the *public* key to encrypt the DEK so only the *private* key can
// decrypt it. // decrypt it.
// - Our DEKs are symmetric XChaCha20Poly1305 keys. // - Our DEKs are symmetric XChaCha20Poly1305 keys.
//
type KeyEncryptionKey interface { type KeyEncryptionKey interface {
ID() string ID() string
KeyBytes() []byte KeyBytes() []byte

View file

@ -59,7 +59,6 @@ func NewLeasers(leaseName string, ttl time.Duration, client DataBrokerServiceCli
// //
// 1. ctx is canceled // 1. ctx is canceled
// 2. a non-cancel error is returned from handler // 2. a non-cancel error is returned from handler
//
func (locker *Leaser) Run(ctx context.Context) error { func (locker *Leaser) Run(ctx context.Context) error {
retryTicker := time.NewTicker(locker.ttl / 2) retryTicker := time.NewTicker(locker.ttl / 2)
defer retryTicker.Stop() defer retryTicker.Stop()