Skip to content

Commit

Permalink
Add registry authorization (#562)
Browse files Browse the repository at this point in the history
* add registry authorization

Signed-off-by: Nikita Skrynnik <[email protected]>

* fix linter

Signed-off-by: Nikita Skrynnik <[email protected]>

* fix liner funlen parameter

Signed-off-by: Nikita Skrynnik <[email protected]>

* fix all tests

Signed-off-by: Nikita Skrynnik <[email protected]>

Signed-off-by: Nikita Skrynnik <[email protected]>
  • Loading branch information
NikitaSkrynnik authored Dec 7, 2022
1 parent fda2c53 commit 5a7fc19
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ linters-settings:
dupl:
threshold: 150
funlen:
Lines: 100
Lines: 110
Statements: 50
goconst:
min-len: 2
Expand Down
11 changes: 6 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ require (
github.com/edwarnicke/grpcfd v1.1.2
github.com/golang/protobuf v1.5.2
github.com/kelseyhightower/envconfig v1.4.0
github.com/networkservicemesh/api v1.6.2-0.20221123101008-30ff0ca88ee8
github.com/networkservicemesh/sdk v0.5.1-0.20221124104929-d83bdbd65e5a
github.com/networkservicemesh/api v1.6.2-0.20221205183940-84c7ff837cdd
github.com/networkservicemesh/sdk v0.5.1-0.20221207123638-d94a145092d6
github.com/sirupsen/logrus v1.9.0
github.com/spiffe/go-spiffe/v2 v2.0.0
github.com/stretchr/testify v1.8.0
Expand All @@ -26,6 +26,7 @@ require (
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/gobwas/glob v0.2.3 // indirect
github.com/golang-jwt/jwt/v4 v4.2.0 // indirect
github.com/google/go-cmp v0.5.8 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/google/uuid v1.2.0 // indirect
Expand All @@ -52,9 +53,9 @@ require (
go.opentelemetry.io/otel/trace v1.9.0 // indirect
go.opentelemetry.io/proto/otlp v0.19.0 // indirect
golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 // indirect
golang.org/x/net v0.0.0-20220907135653-1e95f45603a7 // indirect
golang.org/x/sys v0.0.0-20220908164124-27713097b956 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/net v0.2.0 // indirect
golang.org/x/sys v0.2.0 // indirect
golang.org/x/text v0.4.0 // indirect
google.golang.org/genproto v0.0.0-20220908141613-51c1cc9bc6d0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/square/go-jose.v2 v2.5.1 // indirect
Expand Down
25 changes: 13 additions & 12 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y=
github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8=
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
github.com/golang-jwt/jwt/v4 v4.2.0 h1:besgBTC8w8HjP6NzQdxwKH9Z5oQMZ24ThTrHp3cZ8eU=
github.com/golang-jwt/jwt/v4 v4.2.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/glog v1.0.0 h1:nfP3RFugxnNRyKgeWd4oI1nYvXpxrx8ck8ZrcizshdQ=
github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4=
Expand Down Expand Up @@ -191,10 +192,10 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 h1:I0XW9+e1XWDxdcEniV4rQAIOPUGDq67JSCiRCgGCZLI=
github.com/miekg/dns v1.1.50 h1:DQUfb9uc6smULcREF09Uc+/Gd46YWqJd5DbpPE9xkcA=
github.com/networkservicemesh/api v1.6.2-0.20221123101008-30ff0ca88ee8 h1:243pLMg7+XD/794gnMlHRePyzxJJwECT+Gg9nAuiwTo=
github.com/networkservicemesh/api v1.6.2-0.20221123101008-30ff0ca88ee8/go.mod h1:hOF2844BSstH1311oDMDgqqXS+kdc77htZNPRKl9mf8=
github.com/networkservicemesh/sdk v0.5.1-0.20221124104929-d83bdbd65e5a h1:cVAxQKXaUyEmzoCwoXEUuQ+JGm3usGk26fUZta10xSY=
github.com/networkservicemesh/sdk v0.5.1-0.20221124104929-d83bdbd65e5a/go.mod h1:wnkxc0GGaktCa8MaL49AmRbT4QZl+CNv9xPdMHBOfjk=
github.com/networkservicemesh/api v1.6.2-0.20221205183940-84c7ff837cdd h1:26HR90HrJFZHIPPP3SCLGNRpPCMFoEnSSZfhHH8MPSo=
github.com/networkservicemesh/api v1.6.2-0.20221205183940-84c7ff837cdd/go.mod h1:hOF2844BSstH1311oDMDgqqXS+kdc77htZNPRKl9mf8=
github.com/networkservicemesh/sdk v0.5.1-0.20221207123638-d94a145092d6 h1:d/HQEcyiJ+AJQoBp3S7feCPWNiERI//vUGHE4eX035U=
github.com/networkservicemesh/sdk v0.5.1-0.20221207123638-d94a145092d6/go.mod h1:zEYFbCVXGlTT5f0x6sx8XtL2GazkYBpCoEpooxkz2vE=
github.com/open-policy-agent/opa v0.44.0 h1:sEZthsrWBqIN+ShTMJ0Hcz6a3GkYsY4FaB2S/ou2hZk=
github.com/open-policy-agent/opa v0.44.0/go.mod h1:YpJaFIk5pq89n/k72c1lVvfvR5uopdJft2tMg1CW/yU=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
Expand Down Expand Up @@ -309,7 +310,7 @@ golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzB
golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s=
golang.org/x/mod v0.7.0 h1:LapD9S96VoQRhi/GrNTqeBJFrUjs5UHCAtTlgwA5oZA=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
Expand Down Expand Up @@ -337,8 +338,8 @@ golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81R
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/net v0.0.0-20220907135653-1e95f45603a7 h1:1WGATo9HAhkWMbfyuVU0tEFP88OIkUvwaHFveQPvzCQ=
golang.org/x/net v0.0.0-20220907135653-1e95f45603a7/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
golang.org/x/net v0.2.0 h1:sZfSu1wtKLGlWI4ZZayP0ck9Y73K1ynO6gqzTdBVdPU=
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
Expand Down Expand Up @@ -383,17 +384,17 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220908164124-27713097b956 h1:XeJjHH1KiLpKGb6lvMiksZ9l0fVUh+AmGcm0nOMEBOY=
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A=
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
Expand Down Expand Up @@ -438,7 +439,7 @@ golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roY
golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
golang.org/x/tools v0.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU=
golang.org/x/tools v0.3.0 h1:SrNbZl6ECOS1qFzgTdQfWXZM9XBkiA6tkFrH9YSTPHM=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
22 changes: 15 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import (
"github.com/edwarnicke/grpcfd"

"github.com/networkservicemesh/sdk/pkg/tools/opentelemetry"
"github.com/networkservicemesh/sdk/pkg/tools/spiffejwt"
"github.com/networkservicemesh/sdk/pkg/tools/token"
"github.com/networkservicemesh/sdk/pkg/tools/tracing"

nested "github.com/antonfisher/nested-logrus-formatter"
Expand All @@ -52,6 +54,7 @@ import (
// Config is configuration for cmd-registry-memory
type Config struct {
ListenOn []url.URL `default:"unix:///listen.on.socket" desc:"url to listen on." split_words:"true"`
MaxTokenLifetime time.Duration `default:"10m" desc:"maximum lifetime of tokens" split_words:"true"`
ProxyRegistryURL url.URL `desc:"url to the proxy registry that handles this domain" split_words:"true"`
ExpirePeriod time.Duration `default:"1s" desc:"period to check expired NSEs" split_words:"true"`
LogLevel string `default:"INFO" desc:"Log level" split_words:"true"`
Expand Down Expand Up @@ -136,17 +139,22 @@ func main() {
clientOptions := append(
tracing.WithTracingDial(),
grpc.WithBlock(),
grpc.WithDefaultCallOptions(grpc.WaitForReady(true)),
grpc.WithDefaultCallOptions(
grpc.WaitForReady(true),
grpc.PerRPCCredentials(token.NewPerRPCCredentials(spiffejwt.TokenGeneratorFunc(source, config.MaxTokenLifetime)))),
grpc.WithTransportCredentials(
grpcfd.TransportCredentials(
credentials.NewTLS(tlsClientConfig),
),
),
grpcfd.TransportCredentials(credentials.NewTLS(tlsClientConfig))),
grpcfd.WithChainStreamInterceptor(),
grpcfd.WithChainUnaryInterceptor(),
)

memory.NewServer(
ctx,
memory.WithAuthorizeNSRegistryServer(authorize.NewNetworkServiceRegistryServer(authorize.Any())),
memory.WithAuthorizeNSERegistryServer(authorize.NewNetworkServiceEndpointRegistryServer(authorize.Any())),
spiffejwt.TokenGeneratorFunc(source, config.MaxTokenLifetime),
memory.WithAuthorizeNSERegistryServer(authorize.NewNetworkServiceEndpointRegistryServer()),
memory.WithAuthorizeNSERegistryClient(authorize.NewNetworkServiceEndpointRegistryClient()),
memory.WithAuthorizeNSRegistryServer(authorize.NewNetworkServiceRegistryServer()),
memory.WithAuthorizeNSRegistryClient(authorize.NewNetworkServiceRegistryClient()),
memory.WithExpireDuration(time.Minute),
memory.WithProxyRegistryURL(&config.ProxyRegistryURL),
memory.WithDialOptions(clientOptions...)).Register(server)
Expand Down
44 changes: 39 additions & 5 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (

nested "github.com/antonfisher/nested-logrus-formatter"
"github.com/edwarnicke/exechelper"
"github.com/edwarnicke/grpcfd"
"github.com/golang/protobuf/ptypes/timestamp"
"github.com/kelseyhightower/envconfig"
"github.com/sirupsen/logrus"
Expand All @@ -45,10 +46,13 @@ import (

"github.com/networkservicemesh/api/pkg/api/registry"
"github.com/networkservicemesh/sdk/pkg/registry/common/begin"
"github.com/networkservicemesh/sdk/pkg/registry/common/grpcmetadata"
"github.com/networkservicemesh/sdk/pkg/registry/common/refresh"
"github.com/networkservicemesh/sdk/pkg/registry/core/next"
"github.com/networkservicemesh/sdk/pkg/tools/log"
"github.com/networkservicemesh/sdk/pkg/tools/spiffejwt"
"github.com/networkservicemesh/sdk/pkg/tools/spire"
"github.com/networkservicemesh/sdk/pkg/tools/token"

main "github.com/networkservicemesh/cmd-registry-memory"
)
Expand Down Expand Up @@ -159,9 +163,18 @@ func (t *RegistryTestSuite) TestNetworkServiceRegistration() {
cc, err := grpc.DialContext(ctx,
t.config.ListenOn[0].String(),
grpc.WithTransportCredentials(credentials.NewTLS(tlsconfig.MTLSClientConfig(t.x509source, t.x509bundle, tlsconfig.AuthorizeAny()))),
grpc.WithDefaultCallOptions(
grpc.WaitForReady(true),
grpc.PerRPCCredentials(token.NewPerRPCCredentials(spiffejwt.TokenGeneratorFunc(t.x509source, t.config.MaxTokenLifetime))),
),
grpcfd.WithChainStreamInterceptor(),
grpcfd.WithChainUnaryInterceptor(),
)
t.NoError(err)
client := registry.NewNetworkServiceRegistryClient(cc)
client := next.NewNetworkServiceRegistryClient(
grpcmetadata.NewNetworkServiceRegistryClient(),
registry.NewNetworkServiceRegistryClient(cc),
)
_, err = client.Register(context.Background(), &registry.NetworkService{
Name: "ns-1",
})
Expand All @@ -186,12 +199,19 @@ func (t *RegistryTestSuite) TestNetworkServiceEndpointRegistration() {
cc, err := grpc.DialContext(ctx,
t.config.ListenOn[0].String(),
grpc.WithTransportCredentials(credentials.NewTLS(tlsconfig.MTLSClientConfig(t.x509source, t.x509bundle, tlsconfig.AuthorizeAny()))),
grpc.WithDefaultCallOptions(
grpc.WaitForReady(true),
grpc.PerRPCCredentials(token.NewPerRPCCredentials(spiffejwt.TokenGeneratorFunc(t.x509source, t.config.MaxTokenLifetime))),
),
grpcfd.WithChainStreamInterceptor(),
grpcfd.WithChainUnaryInterceptor(),
)
t.NoError(err)

client := next.NewNetworkServiceEndpointRegistryClient(
begin.NewNetworkServiceEndpointRegistryClient(),
refresh.NewNetworkServiceEndpointRegistryClient(ctx),
grpcmetadata.NewNetworkServiceEndpointRegistryClient(),
registry.NewNetworkServiceEndpointRegistryClient(cc),
)

Expand All @@ -203,18 +223,18 @@ func (t *RegistryTestSuite) TestNetworkServiceEndpointRegistration() {
},
})

t.Nil(err)
t.NoError(err)
t.NotEmpty(result.Name)
stream, err := client.Find(context.Background(), &registry.NetworkServiceEndpointQuery{NetworkServiceEndpoint: &registry.NetworkServiceEndpoint{
Name: result.Name,
}})
t.Nil(err)
t.NoError(err)
list := registry.ReadNetworkServiceEndpointList(stream)
t.Len(list, 1)
_, err = client.Unregister(context.Background(), result)
t.Nil(err)
t.NoError(err)
stream, err = client.Find(context.Background(), &registry.NetworkServiceEndpointQuery{NetworkServiceEndpoint: result})
t.Nil(err)
t.NoError(err)
list = registry.ReadNetworkServiceEndpointList(stream)
t.Len(list, 0)
}
Expand All @@ -225,9 +245,16 @@ func (t *RegistryTestSuite) TestNetworkServiceEndpointRegistrationExpiration() {
cc, err := grpc.DialContext(ctx,
t.config.ListenOn[0].String(),
grpc.WithTransportCredentials(credentials.NewTLS(tlsconfig.MTLSClientConfig(t.x509source, t.x509bundle, tlsconfig.AuthorizeAny()))),
grpc.WithDefaultCallOptions(
grpc.WaitForReady(true),
grpc.PerRPCCredentials(token.NewPerRPCCredentials(spiffejwt.TokenGeneratorFunc(t.x509source, t.config.MaxTokenLifetime))),
),
grpcfd.WithChainStreamInterceptor(),
grpcfd.WithChainUnaryInterceptor(),
)
t.NoError(err)
client := next.NewNetworkServiceEndpointRegistryClient(
grpcmetadata.NewNetworkServiceEndpointRegistryClient(),
registry.NewNetworkServiceEndpointRegistryClient(cc),
)
expireTime := time.Now().Add(time.Second)
Expand Down Expand Up @@ -262,6 +289,12 @@ func (t *RegistryTestSuite) TestNetworkServiceEndpointClientRefreshingTime() {
cc, err := grpc.DialContext(ctx,
t.config.ListenOn[0].String(),
grpc.WithTransportCredentials(credentials.NewTLS(tlsconfig.MTLSClientConfig(t.x509source, t.x509bundle, tlsconfig.AuthorizeAny()))),
grpc.WithDefaultCallOptions(
grpc.WaitForReady(true),
grpc.PerRPCCredentials(token.NewPerRPCCredentials(spiffejwt.TokenGeneratorFunc(t.x509source, t.config.MaxTokenLifetime))),
),
grpcfd.WithChainStreamInterceptor(),
grpcfd.WithChainUnaryInterceptor(),
)
t.NoError(err)

Expand All @@ -271,6 +304,7 @@ func (t *RegistryTestSuite) TestNetworkServiceEndpointClientRefreshingTime() {
client := next.NewNetworkServiceEndpointRegistryClient(
begin.NewNetworkServiceEndpointRegistryClient(),
refresh.NewNetworkServiceEndpointRegistryClient(ctx),
grpcmetadata.NewNetworkServiceEndpointRegistryClient(),
registry.NewNetworkServiceEndpointRegistryClient(cc),
)
result, regErr := client.Register(context.Background(), &registry.NetworkServiceEndpoint{
Expand Down
3 changes: 3 additions & 0 deletions pkg/imports/imports_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,17 @@ import (
_ "github.com/networkservicemesh/sdk/pkg/registry/chains/memory"
_ "github.com/networkservicemesh/sdk/pkg/registry/common/authorize"
_ "github.com/networkservicemesh/sdk/pkg/registry/common/begin"
_ "github.com/networkservicemesh/sdk/pkg/registry/common/grpcmetadata"
_ "github.com/networkservicemesh/sdk/pkg/registry/common/refresh"
_ "github.com/networkservicemesh/sdk/pkg/registry/core/next"
_ "github.com/networkservicemesh/sdk/pkg/tools/debug"
_ "github.com/networkservicemesh/sdk/pkg/tools/grpcutils"
_ "github.com/networkservicemesh/sdk/pkg/tools/log"
_ "github.com/networkservicemesh/sdk/pkg/tools/log/logruslogger"
_ "github.com/networkservicemesh/sdk/pkg/tools/opentelemetry"
_ "github.com/networkservicemesh/sdk/pkg/tools/spiffejwt"
_ "github.com/networkservicemesh/sdk/pkg/tools/spire"
_ "github.com/networkservicemesh/sdk/pkg/tools/token"
_ "github.com/networkservicemesh/sdk/pkg/tools/tracing"
_ "github.com/sirupsen/logrus"
_ "github.com/spiffe/go-spiffe/v2/bundle/x509bundle"
Expand Down

0 comments on commit 5a7fc19

Please sign in to comment.