mirror of
https://github.com/pomerium/pomerium.git
synced 2025-07-09 21:08:11 +02:00
logs: add new log scrubber (#1346)
This commit is contained in:
parent
3caaf29899
commit
8ab0dcb45b
3 changed files with 193 additions and 0 deletions
31
pkg/logutil/scrub_test.go
Normal file
31
pkg/logutil/scrub_test.go
Normal file
|
@ -0,0 +1,31 @@
|
|||
package logutil
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"google.golang.org/protobuf/types/known/anypb"
|
||||
"google.golang.org/protobuf/types/known/wrapperspb"
|
||||
|
||||
"github.com/pomerium/pomerium/pkg/grpc/user"
|
||||
)
|
||||
|
||||
func TestScrubber(t *testing.T) {
|
||||
s := NewScrubber("pomerium").Whitelist("user.User", "version", "id")
|
||||
c1, _ := anypb.New(wrapperspb.String("claim1"))
|
||||
u := s.ScrubProto(&user.User{
|
||||
Version: "v1",
|
||||
Id: "u1",
|
||||
Name: "name1",
|
||||
Email: "user@example.com",
|
||||
Claims: map[string]*anypb.Any{
|
||||
"key1": c1,
|
||||
},
|
||||
}).(*user.User)
|
||||
|
||||
assert.Equal(t, "v1", u.Version)
|
||||
assert.Equal(t, "u1", u.Id)
|
||||
assert.Equal(t, s.hmacString("name1"), u.Name)
|
||||
assert.Equal(t, s.hmacString("user@example.com"), u.Email)
|
||||
assert.Equal(t, s.hmacString("claim1"), u.GetClaim("key1"))
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue