diff --git a/Makefile b/Makefile index d550ce2f9..3eed0d7e8 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ PROTON_COMMIT := "a1795affeb3f5a6bd8431234e7eb69df253a72c9" install: @echo "Clean up imports..." @go mod download - @go get -d github.com/vektra/mockery/v2@v2.13.1 + @go get -d github.com/vektra/mockery/v2@v2.38.0 build: ## build all CGO_ENABLED=0 go build -o shield . diff --git a/core/user/service.go b/core/user/service.go index 2ecb30019..2876735b2 100644 --- a/core/user/service.go +++ b/core/user/service.go @@ -3,6 +3,8 @@ package user import ( "context" "strings" + + "github.com/goto/shield/pkg/uuid" ) type Service struct { @@ -15,6 +17,13 @@ func NewService(repository Repository) *Service { } } +func (s Service) Get(ctx context.Context, idOrEmail string) (User, error) { + if uuid.IsValid(idOrEmail) { + return s.repository.GetByID(ctx, idOrEmail) + } + return s.repository.GetByEmail(ctx, idOrEmail) +} + func (s Service) GetByID(ctx context.Context, id string) (User, error) { return s.repository.GetByID(ctx, id) } diff --git a/go.mod b/go.mod index 153a7a01e..d6210aef1 100644 --- a/go.mod +++ b/go.mod @@ -37,16 +37,16 @@ require ( github.com/rs/xid v1.4.0 github.com/spf13/afero v1.9.3 github.com/spf13/cobra v1.7.0 - github.com/stretchr/testify v1.8.1 + github.com/stretchr/testify v1.8.2 github.com/tidwall/gjson v1.14.4 go.opencensus.io v0.24.0 go.uber.org/zap v1.24.0 gocloud.dev v0.28.0 golang.org/x/exp v0.0.0-20230108222341-4b8118a2686a - golang.org/x/net v0.5.0 + golang.org/x/net v0.8.0 golang.org/x/oauth2 v0.4.0 google.golang.org/genproto v0.0.0-20230109162033-3c3c17ce83e6 - google.golang.org/grpc v1.51.0 + google.golang.org/grpc v1.52.0 google.golang.org/protobuf v1.28.1 gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v3 v3.0.1 @@ -123,7 +123,6 @@ require ( github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.0.2 // indirect github.com/opencontainers/runc v1.1.2 // indirect - github.com/pelletier/go-toml v1.9.5 // indirect github.com/pelletier/go-toml/v2 v2.0.6 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prometheus/client_golang v1.13.1 // indirect @@ -132,17 +131,17 @@ require ( github.com/prometheus/procfs v0.8.0 // indirect github.com/prometheus/statsd_exporter v0.22.7 // indirect github.com/rivo/uniseg v0.4.4 // indirect - github.com/rs/zerolog v1.28.0 // indirect + github.com/rs/zerolog v1.29.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/schollz/progressbar/v3 v3.13.0 // indirect github.com/sirupsen/logrus v1.9.0 // indirect github.com/spf13/cast v1.5.0 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/spf13/pflag v1.0.5 // indirect - github.com/spf13/viper v1.14.0 // indirect + github.com/spf13/viper v1.15.0 // indirect github.com/stoewer/go-strcase v1.2.0 // indirect github.com/stretchr/objx v0.5.0 // indirect - github.com/subosito/gotenv v1.4.1 // indirect + github.com/subosito/gotenv v1.4.2 // indirect github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/pretty v1.2.1 // indirect github.com/yuin/goldmark v1.5.3 // indirect @@ -151,10 +150,10 @@ require ( go.uber.org/multierr v1.9.0 // indirect golang.org/x/crypto v0.5.0 // indirect golang.org/x/sys v0.7.0 // indirect - golang.org/x/term v0.4.0 // indirect - golang.org/x/text v0.6.0 // indirect + golang.org/x/term v0.6.0 // indirect + golang.org/x/text v0.8.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect - google.golang.org/api v0.106.0 // indirect + google.golang.org/api v0.107.0 // indirect google.golang.org/appengine v1.6.7 // indirect gopkg.in/ini.v1 v1.67.0 // indirect ) diff --git a/go.sum b/go.sum index f9f8b8cc6..997b18fec 100644 --- a/go.sum +++ b/go.sum @@ -1802,8 +1802,6 @@ github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/9 github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE= github.com/pelletier/go-toml v1.8.1/go.mod h1:T2/BmBdy8dvIRq1a/8aqjN41wvWlN4lrapLU/GW4pbc= github.com/pelletier/go-toml v1.9.3/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= -github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8= -github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/pelletier/go-toml/v2 v2.0.6 h1:nrzqCb7j9cDFj2coyLNLaZuJTLjWjlaz6nvTvIwycIU= github.com/pelletier/go-toml/v2 v2.0.6/go.mod h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha2N+QD+EUNTek= github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= @@ -1924,8 +1922,8 @@ github.com/rs/xid v1.4.0 h1:qd7wPTDkN6KQx2VmMBLrpHkiyQwgFXRnkOLacUiaSNY= github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU= github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc= -github.com/rs/zerolog v1.28.0 h1:MirSo27VyNi7RJYP3078AA1+Cyzd2GB66qy3aUHvsWY= -github.com/rs/zerolog v1.28.0/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6usyD0= +github.com/rs/zerolog v1.29.0 h1:Zes4hju04hjbvkVkOhdl2HpZa+0PmVwigmo8XoORE5w= +github.com/rs/zerolog v1.29.0/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6usyD0= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= @@ -2003,8 +2001,8 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= github.com/spf13/viper v1.8.1/go.mod h1:o0Pch8wJ9BVSWGQMbra6iw0oQ5oktSIBaujf1rJH9Ns= -github.com/spf13/viper v1.14.0 h1:Rg7d3Lo706X9tHsJMUjdiwMpHB7W8WnSVOssIY+JElU= -github.com/spf13/viper v1.14.0/go.mod h1:WT//axPky3FdvXHzGw33dNdXXXfFQqmEalje+egj8As= +github.com/spf13/viper v1.15.0 h1:js3yy885G8xwJa6iOISGFwd+qlUo5AvyXb7CiihdtiU= +github.com/spf13/viper v1.15.0/go.mod h1:fFcTBJxvhhzSJiZy8n+PeW6t8l+KeT/uTARa0jHOQLA= github.com/stefanberger/go-pkcs11uri v0.0.0-20201008174630-78d3cae3a980/go.mod h1:AO3tvPzVZ/ayst6UlUKUv6rcPQInYe3IknH3jYhAKu8= github.com/stoewer/go-strcase v1.2.0 h1:Z2iHWqGXH00XYgqDmNgQbIBxf3wrNq0F3feEy0ainaU= github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8= @@ -2027,12 +2025,13 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= +github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stvp/go-udp-testing v0.0.0-20201019212854-469649b16807/go.mod h1:7jxmlfBCDBXRzr0eAQJ48XC1hBu1np4CS5+cHEYfwpc= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= -github.com/subosito/gotenv v1.4.1 h1:jyEFiXpy21Wm81FBN71l9VoMMV8H8jG+qIK3GCpY6Qs= -github.com/subosito/gotenv v1.4.1/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0= +github.com/subosito/gotenv v1.4.2 h1:X1TuBLAMDFbaTAChgCBLu3DU3UPyELpnF2jjJ2cz/S8= +github.com/subosito/gotenv v1.4.2/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0= github.com/syndtr/gocapability v0.0.0-20170704070218-db04d3cc01c8/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= github.com/syndtr/gocapability v0.0.0-20180916011248-d98352740cb2/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= @@ -2399,8 +2398,8 @@ golang.org/x/net v0.0.0-20221014081412-f15817d10f9b/go.mod h1:YDH+HFinaLZZlnHAfS golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/net v0.4.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE= -golang.org/x/net v0.5.0 h1:GyT4nK/YDHSqa1c4753ouYCDajOYKTja9Xb/OHtgvSw= -golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws= +golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= +golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/oauth2 v0.0.0-20180227000427-d7d64896b5ff/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181106182150-f42d05182288/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -2629,8 +2628,9 @@ golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuX golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/term v0.3.0/go.mod h1:q750SLmJuPmVoN1blW3UFBPREJfb1KmY3vwxfr+nFDA= -golang.org/x/term v0.4.0 h1:O7UWfv5+A2qiuulQk30kVinPoMtoIPeVaKLEgLpVkvg= golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ= +golang.org/x/term v0.6.0 h1:clScbb1cHjoCkyRbWwBEUZ5H/tIFu5TAXIqaZD0Gcjw= +golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= 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= @@ -2643,8 +2643,8 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.6.0 h1:3XmdazWV+ubf7QgHSTWeykHOci5oeekaGJBLkrkaw4k= -golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= +golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= 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= @@ -2820,8 +2820,8 @@ google.golang.org/api v0.99.0/go.mod h1:1YOf74vkVndF7pG6hIHuINsM7eWwpVTAfNMNiL91 google.golang.org/api v0.100.0/go.mod h1:ZE3Z2+ZOr87Rx7dqFsdRQkRBk36kDtp/h+QpHbB7a70= google.golang.org/api v0.102.0/go.mod h1:3VFl6/fzoA+qNuS1N1/VfXY4LjoXN/wzeIp7TweWwGo= google.golang.org/api v0.103.0/go.mod h1:hGtW6nK1AC+d9si/UBhw8Xli+QMOf6xyNAyJw4qU9w0= -google.golang.org/api v0.106.0 h1:ffmW0faWCwKkpbbtvlY/K/8fUl+JKvNS5CVzRoyfCv8= -google.golang.org/api v0.106.0/go.mod h1:2Ts0XTHNVWxypznxWOYUeI4g3WdP9Pk2Qk58+a/O9MY= +google.golang.org/api v0.107.0 h1:I2SlFjD8ZWabaIFOfeEDg3pf0BHJDh6iYQ1ic3Yu/UU= +google.golang.org/api v0.107.0/go.mod h1:2Ts0XTHNVWxypznxWOYUeI4g3WdP9Pk2Qk58+a/O9MY= google.golang.org/appengine v1.0.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -3008,8 +3008,9 @@ google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACu google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= -google.golang.org/grpc v1.51.0 h1:E1eGv1FTqoLIdnBCZufiSHgKjlqG6fKFf6pPWtMTh8U= google.golang.org/grpc v1.51.0/go.mod h1:wgNDFcnuBGmxLKI/qn4T+m5BtEBYXJPvibbUPsAIPww= +google.golang.org/grpc v1.52.0 h1:kd48UiU7EHsV4rnLyOJRuP/Il/UHE7gdDAQ+SZI7nZk= +google.golang.org/grpc v1.52.0/go.mod h1:pu6fVzoFb+NBYNAvQL08ic+lvB2IojljRYuun5vorUY= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.2.0/go.mod h1:DNq5QpG7LJqD2AamLZ7zvKE0DEpVl2BSEVjFycAAjRY= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= diff --git a/internal/api/v1beta1/mocks/action_service.go b/internal/api/v1beta1/mocks/action_service.go index f318f9161..0465b16c5 100644 --- a/internal/api/v1beta1/mocks/action_service.go +++ b/internal/api/v1beta1/mocks/action_service.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.38.0. DO NOT EDIT. package mocks @@ -27,6 +27,10 @@ func (_m *ActionService) EXPECT() *ActionService_Expecter { func (_m *ActionService) Create(ctx context.Context, _a1 action.Action) (action.Action, error) { ret := _m.Called(ctx, _a1) + if len(ret) == 0 { + panic("no return value specified for Create") + } + var r0 action.Action var r1 error if rf, ok := ret.Get(0).(func(context.Context, action.Action) (action.Action, error)); ok { @@ -80,6 +84,10 @@ func (_c *ActionService_Create_Call) RunAndReturn(run func(context.Context, acti func (_m *ActionService) Get(ctx context.Context, id string) (action.Action, error) { ret := _m.Called(ctx, id) + if len(ret) == 0 { + panic("no return value specified for Get") + } + var r0 action.Action var r1 error if rf, ok := ret.Get(0).(func(context.Context, string) (action.Action, error)); ok { @@ -133,6 +141,10 @@ func (_c *ActionService_Get_Call) RunAndReturn(run func(context.Context, string) func (_m *ActionService) List(ctx context.Context) ([]action.Action, error) { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for List") + } + var r0 []action.Action var r1 error if rf, ok := ret.Get(0).(func(context.Context) ([]action.Action, error)); ok { @@ -187,6 +199,10 @@ func (_c *ActionService_List_Call) RunAndReturn(run func(context.Context) ([]act func (_m *ActionService) Update(ctx context.Context, id string, _a2 action.Action) (action.Action, error) { ret := _m.Called(ctx, id, _a2) + if len(ret) == 0 { + panic("no return value specified for Update") + } + var r0 action.Action var r1 error if rf, ok := ret.Get(0).(func(context.Context, string, action.Action) (action.Action, error)); ok { diff --git a/internal/api/v1beta1/mocks/group_service.go b/internal/api/v1beta1/mocks/group_service.go index 5746b5ea0..e2ed9d189 100644 --- a/internal/api/v1beta1/mocks/group_service.go +++ b/internal/api/v1beta1/mocks/group_service.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.38.0. DO NOT EDIT. package mocks @@ -28,6 +28,10 @@ func (_m *GroupService) EXPECT() *GroupService_Expecter { func (_m *GroupService) Create(ctx context.Context, grp group.Group) (group.Group, error) { ret := _m.Called(ctx, grp) + if len(ret) == 0 { + panic("no return value specified for Create") + } + var r0 group.Group var r1 error if rf, ok := ret.Get(0).(func(context.Context, group.Group) (group.Group, error)); ok { @@ -81,6 +85,10 @@ func (_c *GroupService_Create_Call) RunAndReturn(run func(context.Context, group func (_m *GroupService) Get(ctx context.Context, id string) (group.Group, error) { ret := _m.Called(ctx, id) + if len(ret) == 0 { + panic("no return value specified for Get") + } + var r0 group.Group var r1 error if rf, ok := ret.Get(0).(func(context.Context, string) (group.Group, error)); ok { @@ -134,6 +142,10 @@ func (_c *GroupService_Get_Call) RunAndReturn(run func(context.Context, string) func (_m *GroupService) List(ctx context.Context, flt group.Filter) ([]group.Group, error) { ret := _m.Called(ctx, flt) + if len(ret) == 0 { + panic("no return value specified for List") + } + var r0 []group.Group var r1 error if rf, ok := ret.Get(0).(func(context.Context, group.Filter) ([]group.Group, error)); ok { @@ -189,6 +201,10 @@ func (_c *GroupService_List_Call) RunAndReturn(run func(context.Context, group.F func (_m *GroupService) ListGroupRelations(ctx context.Context, objectId string, subjectType string, role string) ([]user.User, []group.Group, map[string][]string, map[string][]string, error) { ret := _m.Called(ctx, objectId, subjectType, role) + if len(ret) == 0 { + panic("no return value specified for ListGroupRelations") + } + var r0 []user.User var r1 []group.Group var r2 map[string][]string @@ -273,6 +289,10 @@ func (_c *GroupService_ListGroupRelations_Call) RunAndReturn(run func(context.Co func (_m *GroupService) ListUserGroups(ctx context.Context, userId string, roleId string) ([]group.Group, error) { ret := _m.Called(ctx, userId, roleId) + if len(ret) == 0 { + panic("no return value specified for ListUserGroups") + } + var r0 []group.Group var r1 error if rf, ok := ret.Get(0).(func(context.Context, string, string) ([]group.Group, error)); ok { @@ -329,6 +349,10 @@ func (_c *GroupService_ListUserGroups_Call) RunAndReturn(run func(context.Contex func (_m *GroupService) Update(ctx context.Context, grp group.Group) (group.Group, error) { ret := _m.Called(ctx, grp) + if len(ret) == 0 { + panic("no return value specified for Update") + } + var r0 group.Group var r1 error if rf, ok := ret.Get(0).(func(context.Context, group.Group) (group.Group, error)); ok { diff --git a/internal/api/v1beta1/mocks/namespace_service.go b/internal/api/v1beta1/mocks/namespace_service.go index 70adca300..8ba0e2c9f 100644 --- a/internal/api/v1beta1/mocks/namespace_service.go +++ b/internal/api/v1beta1/mocks/namespace_service.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.38.0. DO NOT EDIT. package mocks @@ -26,6 +26,10 @@ func (_m *NamespaceService) EXPECT() *NamespaceService_Expecter { func (_m *NamespaceService) Create(ctx context.Context, ns namespace.Namespace) (namespace.Namespace, error) { ret := _m.Called(ctx, ns) + if len(ret) == 0 { + panic("no return value specified for Create") + } + var r0 namespace.Namespace var r1 error if rf, ok := ret.Get(0).(func(context.Context, namespace.Namespace) (namespace.Namespace, error)); ok { @@ -79,6 +83,10 @@ func (_c *NamespaceService_Create_Call) RunAndReturn(run func(context.Context, n func (_m *NamespaceService) Get(ctx context.Context, id string) (namespace.Namespace, error) { ret := _m.Called(ctx, id) + if len(ret) == 0 { + panic("no return value specified for Get") + } + var r0 namespace.Namespace var r1 error if rf, ok := ret.Get(0).(func(context.Context, string) (namespace.Namespace, error)); ok { @@ -132,6 +140,10 @@ func (_c *NamespaceService_Get_Call) RunAndReturn(run func(context.Context, stri func (_m *NamespaceService) List(ctx context.Context) ([]namespace.Namespace, error) { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for List") + } + var r0 []namespace.Namespace var r1 error if rf, ok := ret.Get(0).(func(context.Context) ([]namespace.Namespace, error)); ok { @@ -186,6 +198,10 @@ func (_c *NamespaceService_List_Call) RunAndReturn(run func(context.Context) ([] func (_m *NamespaceService) Update(ctx context.Context, ns namespace.Namespace) (namespace.Namespace, error) { ret := _m.Called(ctx, ns) + if len(ret) == 0 { + panic("no return value specified for Update") + } + var r0 namespace.Namespace var r1 error if rf, ok := ret.Get(0).(func(context.Context, namespace.Namespace) (namespace.Namespace, error)); ok { diff --git a/internal/api/v1beta1/mocks/organization_service.go b/internal/api/v1beta1/mocks/organization_service.go index 552b3d236..50cb1b701 100644 --- a/internal/api/v1beta1/mocks/organization_service.go +++ b/internal/api/v1beta1/mocks/organization_service.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.38.0. DO NOT EDIT. package mocks @@ -28,6 +28,10 @@ func (_m *OrganizationService) EXPECT() *OrganizationService_Expecter { func (_m *OrganizationService) Create(ctx context.Context, org organization.Organization) (organization.Organization, error) { ret := _m.Called(ctx, org) + if len(ret) == 0 { + panic("no return value specified for Create") + } + var r0 organization.Organization var r1 error if rf, ok := ret.Get(0).(func(context.Context, organization.Organization) (organization.Organization, error)); ok { @@ -81,6 +85,10 @@ func (_c *OrganizationService_Create_Call) RunAndReturn(run func(context.Context func (_m *OrganizationService) Get(ctx context.Context, idOrSlug string) (organization.Organization, error) { ret := _m.Called(ctx, idOrSlug) + if len(ret) == 0 { + panic("no return value specified for Get") + } + var r0 organization.Organization var r1 error if rf, ok := ret.Get(0).(func(context.Context, string) (organization.Organization, error)); ok { @@ -134,6 +142,10 @@ func (_c *OrganizationService_Get_Call) RunAndReturn(run func(context.Context, s func (_m *OrganizationService) List(ctx context.Context) ([]organization.Organization, error) { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for List") + } + var r0 []organization.Organization var r1 error if rf, ok := ret.Get(0).(func(context.Context) ([]organization.Organization, error)); ok { @@ -188,6 +200,10 @@ func (_c *OrganizationService_List_Call) RunAndReturn(run func(context.Context) func (_m *OrganizationService) ListAdmins(ctx context.Context, id string) ([]user.User, error) { ret := _m.Called(ctx, id) + if len(ret) == 0 { + panic("no return value specified for ListAdmins") + } + var r0 []user.User var r1 error if rf, ok := ret.Get(0).(func(context.Context, string) ([]user.User, error)); ok { @@ -243,6 +259,10 @@ func (_c *OrganizationService_ListAdmins_Call) RunAndReturn(run func(context.Con func (_m *OrganizationService) Update(ctx context.Context, toUpdate organization.Organization) (organization.Organization, error) { ret := _m.Called(ctx, toUpdate) + if len(ret) == 0 { + panic("no return value specified for Update") + } + var r0 organization.Organization var r1 error if rf, ok := ret.Get(0).(func(context.Context, organization.Organization) (organization.Organization, error)); ok { diff --git a/internal/api/v1beta1/mocks/policy_service.go b/internal/api/v1beta1/mocks/policy_service.go index 89d9b93a3..b83763876 100644 --- a/internal/api/v1beta1/mocks/policy_service.go +++ b/internal/api/v1beta1/mocks/policy_service.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.38.0. DO NOT EDIT. package mocks @@ -26,6 +26,10 @@ func (_m *PolicyService) EXPECT() *PolicyService_Expecter { func (_m *PolicyService) Create(ctx context.Context, pol policy.Policy) ([]policy.Policy, error) { ret := _m.Called(ctx, pol) + if len(ret) == 0 { + panic("no return value specified for Create") + } + var r0 []policy.Policy var r1 error if rf, ok := ret.Get(0).(func(context.Context, policy.Policy) ([]policy.Policy, error)); ok { @@ -81,6 +85,10 @@ func (_c *PolicyService_Create_Call) RunAndReturn(run func(context.Context, poli func (_m *PolicyService) Get(ctx context.Context, id string) (policy.Policy, error) { ret := _m.Called(ctx, id) + if len(ret) == 0 { + panic("no return value specified for Get") + } + var r0 policy.Policy var r1 error if rf, ok := ret.Get(0).(func(context.Context, string) (policy.Policy, error)); ok { @@ -134,6 +142,10 @@ func (_c *PolicyService_Get_Call) RunAndReturn(run func(context.Context, string) func (_m *PolicyService) List(ctx context.Context) ([]policy.Policy, error) { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for List") + } + var r0 []policy.Policy var r1 error if rf, ok := ret.Get(0).(func(context.Context) ([]policy.Policy, error)); ok { @@ -188,6 +200,10 @@ func (_c *PolicyService_List_Call) RunAndReturn(run func(context.Context) ([]pol func (_m *PolicyService) Update(ctx context.Context, pol policy.Policy) ([]policy.Policy, error) { ret := _m.Called(ctx, pol) + if len(ret) == 0 { + panic("no return value specified for Update") + } + var r0 []policy.Policy var r1 error if rf, ok := ret.Get(0).(func(context.Context, policy.Policy) ([]policy.Policy, error)); ok { diff --git a/internal/api/v1beta1/mocks/project_service.go b/internal/api/v1beta1/mocks/project_service.go index 95b7c4596..c574e5b4a 100644 --- a/internal/api/v1beta1/mocks/project_service.go +++ b/internal/api/v1beta1/mocks/project_service.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.38.0. DO NOT EDIT. package mocks @@ -28,6 +28,10 @@ func (_m *ProjectService) EXPECT() *ProjectService_Expecter { func (_m *ProjectService) Create(ctx context.Context, prj project.Project) (project.Project, error) { ret := _m.Called(ctx, prj) + if len(ret) == 0 { + panic("no return value specified for Create") + } + var r0 project.Project var r1 error if rf, ok := ret.Get(0).(func(context.Context, project.Project) (project.Project, error)); ok { @@ -81,6 +85,10 @@ func (_c *ProjectService_Create_Call) RunAndReturn(run func(context.Context, pro func (_m *ProjectService) Get(ctx context.Context, idOrSlugd string) (project.Project, error) { ret := _m.Called(ctx, idOrSlugd) + if len(ret) == 0 { + panic("no return value specified for Get") + } + var r0 project.Project var r1 error if rf, ok := ret.Get(0).(func(context.Context, string) (project.Project, error)); ok { @@ -134,6 +142,10 @@ func (_c *ProjectService_Get_Call) RunAndReturn(run func(context.Context, string func (_m *ProjectService) List(ctx context.Context) ([]project.Project, error) { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for List") + } + var r0 []project.Project var r1 error if rf, ok := ret.Get(0).(func(context.Context) ([]project.Project, error)); ok { @@ -188,6 +200,10 @@ func (_c *ProjectService_List_Call) RunAndReturn(run func(context.Context) ([]pr func (_m *ProjectService) ListAdmins(ctx context.Context, id string) ([]user.User, error) { ret := _m.Called(ctx, id) + if len(ret) == 0 { + panic("no return value specified for ListAdmins") + } + var r0 []user.User var r1 error if rf, ok := ret.Get(0).(func(context.Context, string) ([]user.User, error)); ok { @@ -243,6 +259,10 @@ func (_c *ProjectService_ListAdmins_Call) RunAndReturn(run func(context.Context, func (_m *ProjectService) Update(ctx context.Context, toUpdate project.Project) (project.Project, error) { ret := _m.Called(ctx, toUpdate) + if len(ret) == 0 { + panic("no return value specified for Update") + } + var r0 project.Project var r1 error if rf, ok := ret.Get(0).(func(context.Context, project.Project) (project.Project, error)); ok { diff --git a/internal/api/v1beta1/mocks/relation_service.go b/internal/api/v1beta1/mocks/relation_service.go index 585b982e3..4903ff26b 100644 --- a/internal/api/v1beta1/mocks/relation_service.go +++ b/internal/api/v1beta1/mocks/relation_service.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.38.0. DO NOT EDIT. package mocks @@ -26,6 +26,10 @@ func (_m *RelationService) EXPECT() *RelationService_Expecter { func (_m *RelationService) Create(ctx context.Context, rel relation.RelationV2) (relation.RelationV2, error) { ret := _m.Called(ctx, rel) + if len(ret) == 0 { + panic("no return value specified for Create") + } + var r0 relation.RelationV2 var r1 error if rf, ok := ret.Get(0).(func(context.Context, relation.RelationV2) (relation.RelationV2, error)); ok { @@ -79,6 +83,10 @@ func (_c *RelationService_Create_Call) RunAndReturn(run func(context.Context, re func (_m *RelationService) DeleteV2(ctx context.Context, rel relation.RelationV2) error { ret := _m.Called(ctx, rel) + if len(ret) == 0 { + panic("no return value specified for DeleteV2") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, relation.RelationV2) error); ok { r0 = rf(ctx, rel) @@ -122,6 +130,10 @@ func (_c *RelationService_DeleteV2_Call) RunAndReturn(run func(context.Context, func (_m *RelationService) Get(ctx context.Context, id string) (relation.RelationV2, error) { ret := _m.Called(ctx, id) + if len(ret) == 0 { + panic("no return value specified for Get") + } + var r0 relation.RelationV2 var r1 error if rf, ok := ret.Get(0).(func(context.Context, string) (relation.RelationV2, error)); ok { @@ -175,6 +187,10 @@ func (_c *RelationService_Get_Call) RunAndReturn(run func(context.Context, strin func (_m *RelationService) GetRelationByFields(ctx context.Context, rel relation.RelationV2) (relation.RelationV2, error) { ret := _m.Called(ctx, rel) + if len(ret) == 0 { + panic("no return value specified for GetRelationByFields") + } + var r0 relation.RelationV2 var r1 error if rf, ok := ret.Get(0).(func(context.Context, relation.RelationV2) (relation.RelationV2, error)); ok { @@ -228,6 +244,10 @@ func (_c *RelationService_GetRelationByFields_Call) RunAndReturn(run func(contex func (_m *RelationService) List(ctx context.Context) ([]relation.RelationV2, error) { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for List") + } + var r0 []relation.RelationV2 var r1 error if rf, ok := ret.Get(0).(func(context.Context) ([]relation.RelationV2, error)); ok { diff --git a/internal/api/v1beta1/mocks/relation_transformer.go b/internal/api/v1beta1/mocks/relation_transformer.go index 46a2a72f9..4f7f80692 100644 --- a/internal/api/v1beta1/mocks/relation_transformer.go +++ b/internal/api/v1beta1/mocks/relation_transformer.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.38.0. DO NOT EDIT. package mocks @@ -26,6 +26,10 @@ func (_m *RelationTransformer) EXPECT() *RelationTransformer_Expecter { func (_m *RelationTransformer) TransformRelation(ctx context.Context, rlt relation.RelationV2) (relation.RelationV2, error) { ret := _m.Called(ctx, rlt) + if len(ret) == 0 { + panic("no return value specified for TransformRelation") + } + var r0 relation.RelationV2 var r1 error if rf, ok := ret.Get(0).(func(context.Context, relation.RelationV2) (relation.RelationV2, error)); ok { diff --git a/internal/api/v1beta1/mocks/resource_service.go b/internal/api/v1beta1/mocks/resource_service.go index 213d1a811..7ba071259 100644 --- a/internal/api/v1beta1/mocks/resource_service.go +++ b/internal/api/v1beta1/mocks/resource_service.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.38.0. DO NOT EDIT. package mocks @@ -29,6 +29,10 @@ func (_m *ResourceService) EXPECT() *ResourceService_Expecter { func (_m *ResourceService) CheckAuthz(ctx context.Context, _a1 resource.Resource, _a2 action.Action) (bool, error) { ret := _m.Called(ctx, _a1, _a2) + if len(ret) == 0 { + panic("no return value specified for CheckAuthz") + } + var r0 bool var r1 error if rf, ok := ret.Get(0).(func(context.Context, resource.Resource, action.Action) (bool, error)); ok { @@ -83,6 +87,10 @@ func (_c *ResourceService_CheckAuthz_Call) RunAndReturn(run func(context.Context func (_m *ResourceService) Create(ctx context.Context, _a1 resource.Resource) (resource.Resource, error) { ret := _m.Called(ctx, _a1) + if len(ret) == 0 { + panic("no return value specified for Create") + } + var r0 resource.Resource var r1 error if rf, ok := ret.Get(0).(func(context.Context, resource.Resource) (resource.Resource, error)); ok { @@ -136,6 +144,10 @@ func (_c *ResourceService_Create_Call) RunAndReturn(run func(context.Context, re func (_m *ResourceService) Get(ctx context.Context, id string) (resource.Resource, error) { ret := _m.Called(ctx, id) + if len(ret) == 0 { + panic("no return value specified for Get") + } + var r0 resource.Resource var r1 error if rf, ok := ret.Get(0).(func(context.Context, string) (resource.Resource, error)); ok { @@ -189,6 +201,10 @@ func (_c *ResourceService_Get_Call) RunAndReturn(run func(context.Context, strin func (_m *ResourceService) List(ctx context.Context, flt resource.Filter) ([]resource.Resource, error) { ret := _m.Called(ctx, flt) + if len(ret) == 0 { + panic("no return value specified for List") + } + var r0 []resource.Resource var r1 error if rf, ok := ret.Get(0).(func(context.Context, resource.Filter) ([]resource.Resource, error)); ok { @@ -244,6 +260,10 @@ func (_c *ResourceService_List_Call) RunAndReturn(run func(context.Context, reso func (_m *ResourceService) Update(ctx context.Context, id string, _a2 resource.Resource) (resource.Resource, error) { ret := _m.Called(ctx, id, _a2) + if len(ret) == 0 { + panic("no return value specified for Update") + } + var r0 resource.Resource var r1 error if rf, ok := ret.Get(0).(func(context.Context, string, resource.Resource) (resource.Resource, error)); ok { diff --git a/internal/api/v1beta1/mocks/role_service.go b/internal/api/v1beta1/mocks/role_service.go index a0eaaa705..34b031e3b 100644 --- a/internal/api/v1beta1/mocks/role_service.go +++ b/internal/api/v1beta1/mocks/role_service.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.38.0. DO NOT EDIT. package mocks @@ -26,6 +26,10 @@ func (_m *RoleService) EXPECT() *RoleService_Expecter { func (_m *RoleService) Create(ctx context.Context, toCreate role.Role) (role.Role, error) { ret := _m.Called(ctx, toCreate) + if len(ret) == 0 { + panic("no return value specified for Create") + } + var r0 role.Role var r1 error if rf, ok := ret.Get(0).(func(context.Context, role.Role) (role.Role, error)); ok { @@ -79,6 +83,10 @@ func (_c *RoleService_Create_Call) RunAndReturn(run func(context.Context, role.R func (_m *RoleService) Get(ctx context.Context, id string) (role.Role, error) { ret := _m.Called(ctx, id) + if len(ret) == 0 { + panic("no return value specified for Get") + } + var r0 role.Role var r1 error if rf, ok := ret.Get(0).(func(context.Context, string) (role.Role, error)); ok { @@ -132,6 +140,10 @@ func (_c *RoleService_Get_Call) RunAndReturn(run func(context.Context, string) ( func (_m *RoleService) List(ctx context.Context) ([]role.Role, error) { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for List") + } + var r0 []role.Role var r1 error if rf, ok := ret.Get(0).(func(context.Context) ([]role.Role, error)); ok { @@ -186,6 +198,10 @@ func (_c *RoleService_List_Call) RunAndReturn(run func(context.Context) ([]role. func (_m *RoleService) Update(ctx context.Context, toUpdate role.Role) (role.Role, error) { ret := _m.Called(ctx, toUpdate) + if len(ret) == 0 { + panic("no return value specified for Update") + } + var r0 role.Role var r1 error if rf, ok := ret.Get(0).(func(context.Context, role.Role) (role.Role, error)); ok { diff --git a/internal/api/v1beta1/mocks/rule_service.go b/internal/api/v1beta1/mocks/rule_service.go index ba6e6e8cf..4528ac5ce 100644 --- a/internal/api/v1beta1/mocks/rule_service.go +++ b/internal/api/v1beta1/mocks/rule_service.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.38.0. DO NOT EDIT. package mocks @@ -26,6 +26,10 @@ func (_m *RuleService) EXPECT() *RuleService_Expecter { func (_m *RuleService) GetAllConfigs(ctx context.Context) ([]rule.Ruleset, error) { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for GetAllConfigs") + } + var r0 []rule.Ruleset var r1 error if rf, ok := ret.Get(0).(func(context.Context) ([]rule.Ruleset, error)); ok { diff --git a/internal/api/v1beta1/mocks/user_service.go b/internal/api/v1beta1/mocks/user_service.go index 949e92dd6..07c1026ae 100644 --- a/internal/api/v1beta1/mocks/user_service.go +++ b/internal/api/v1beta1/mocks/user_service.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.38.0. DO NOT EDIT. package mocks @@ -26,6 +26,10 @@ func (_m *UserService) EXPECT() *UserService_Expecter { func (_m *UserService) Create(ctx context.Context, _a1 user.User) (user.User, error) { ret := _m.Called(ctx, _a1) + if len(ret) == 0 { + panic("no return value specified for Create") + } + var r0 user.User var r1 error if rf, ok := ret.Get(0).(func(context.Context, user.User) (user.User, error)); ok { @@ -79,6 +83,10 @@ func (_c *UserService_Create_Call) RunAndReturn(run func(context.Context, user.U func (_m *UserService) CreateMetadataKey(ctx context.Context, key user.UserMetadataKey) (user.UserMetadataKey, error) { ret := _m.Called(ctx, key) + if len(ret) == 0 { + panic("no return value specified for CreateMetadataKey") + } + var r0 user.UserMetadataKey var r1 error if rf, ok := ret.Get(0).(func(context.Context, user.UserMetadataKey) (user.UserMetadataKey, error)); ok { @@ -132,6 +140,10 @@ func (_c *UserService_CreateMetadataKey_Call) RunAndReturn(run func(context.Cont func (_m *UserService) FetchCurrentUser(ctx context.Context) (user.User, error) { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for FetchCurrentUser") + } + var r0 user.User var r1 error if rf, ok := ret.Get(0).(func(context.Context) (user.User, error)); ok { @@ -180,23 +192,27 @@ func (_c *UserService_FetchCurrentUser_Call) RunAndReturn(run func(context.Conte return _c } -// GetByEmail provides a mock function with given fields: ctx, email -func (_m *UserService) GetByEmail(ctx context.Context, email string) (user.User, error) { - ret := _m.Called(ctx, email) +// Get provides a mock function with given fields: ctx, idOrEmail +func (_m *UserService) Get(ctx context.Context, idOrEmail string) (user.User, error) { + ret := _m.Called(ctx, idOrEmail) + + if len(ret) == 0 { + panic("no return value specified for Get") + } var r0 user.User var r1 error if rf, ok := ret.Get(0).(func(context.Context, string) (user.User, error)); ok { - return rf(ctx, email) + return rf(ctx, idOrEmail) } if rf, ok := ret.Get(0).(func(context.Context, string) user.User); ok { - r0 = rf(ctx, email) + r0 = rf(ctx, idOrEmail) } else { r0 = ret.Get(0).(user.User) } if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { - r1 = rf(ctx, email) + r1 = rf(ctx, idOrEmail) } else { r1 = ret.Error(1) } @@ -204,52 +220,56 @@ func (_m *UserService) GetByEmail(ctx context.Context, email string) (user.User, return r0, r1 } -// UserService_GetByEmail_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetByEmail' -type UserService_GetByEmail_Call struct { +// UserService_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' +type UserService_Get_Call struct { *mock.Call } -// GetByEmail is a helper method to define mock.On call +// Get is a helper method to define mock.On call // - ctx context.Context -// - email string -func (_e *UserService_Expecter) GetByEmail(ctx interface{}, email interface{}) *UserService_GetByEmail_Call { - return &UserService_GetByEmail_Call{Call: _e.mock.On("GetByEmail", ctx, email)} +// - idOrEmail string +func (_e *UserService_Expecter) Get(ctx interface{}, idOrEmail interface{}) *UserService_Get_Call { + return &UserService_Get_Call{Call: _e.mock.On("Get", ctx, idOrEmail)} } -func (_c *UserService_GetByEmail_Call) Run(run func(ctx context.Context, email string)) *UserService_GetByEmail_Call { +func (_c *UserService_Get_Call) Run(run func(ctx context.Context, idOrEmail string)) *UserService_Get_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(context.Context), args[1].(string)) }) return _c } -func (_c *UserService_GetByEmail_Call) Return(_a0 user.User, _a1 error) *UserService_GetByEmail_Call { +func (_c *UserService_Get_Call) Return(_a0 user.User, _a1 error) *UserService_Get_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *UserService_GetByEmail_Call) RunAndReturn(run func(context.Context, string) (user.User, error)) *UserService_GetByEmail_Call { +func (_c *UserService_Get_Call) RunAndReturn(run func(context.Context, string) (user.User, error)) *UserService_Get_Call { _c.Call.Return(run) return _c } -// GetByID provides a mock function with given fields: ctx, id -func (_m *UserService) GetByID(ctx context.Context, id string) (user.User, error) { - ret := _m.Called(ctx, id) +// GetByEmail provides a mock function with given fields: ctx, email +func (_m *UserService) GetByEmail(ctx context.Context, email string) (user.User, error) { + ret := _m.Called(ctx, email) + + if len(ret) == 0 { + panic("no return value specified for GetByEmail") + } var r0 user.User var r1 error if rf, ok := ret.Get(0).(func(context.Context, string) (user.User, error)); ok { - return rf(ctx, id) + return rf(ctx, email) } if rf, ok := ret.Get(0).(func(context.Context, string) user.User); ok { - r0 = rf(ctx, id) + r0 = rf(ctx, email) } else { r0 = ret.Get(0).(user.User) } if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { - r1 = rf(ctx, id) + r1 = rf(ctx, email) } else { r1 = ret.Error(1) } @@ -257,31 +277,31 @@ func (_m *UserService) GetByID(ctx context.Context, id string) (user.User, error return r0, r1 } -// UserService_GetByID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetByID' -type UserService_GetByID_Call struct { +// UserService_GetByEmail_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetByEmail' +type UserService_GetByEmail_Call struct { *mock.Call } -// GetByID is a helper method to define mock.On call +// GetByEmail is a helper method to define mock.On call // - ctx context.Context -// - id string -func (_e *UserService_Expecter) GetByID(ctx interface{}, id interface{}) *UserService_GetByID_Call { - return &UserService_GetByID_Call{Call: _e.mock.On("GetByID", ctx, id)} +// - email string +func (_e *UserService_Expecter) GetByEmail(ctx interface{}, email interface{}) *UserService_GetByEmail_Call { + return &UserService_GetByEmail_Call{Call: _e.mock.On("GetByEmail", ctx, email)} } -func (_c *UserService_GetByID_Call) Run(run func(ctx context.Context, id string)) *UserService_GetByID_Call { +func (_c *UserService_GetByEmail_Call) Run(run func(ctx context.Context, email string)) *UserService_GetByEmail_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(context.Context), args[1].(string)) }) return _c } -func (_c *UserService_GetByID_Call) Return(_a0 user.User, _a1 error) *UserService_GetByID_Call { +func (_c *UserService_GetByEmail_Call) Return(_a0 user.User, _a1 error) *UserService_GetByEmail_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *UserService_GetByID_Call) RunAndReturn(run func(context.Context, string) (user.User, error)) *UserService_GetByID_Call { +func (_c *UserService_GetByEmail_Call) RunAndReturn(run func(context.Context, string) (user.User, error)) *UserService_GetByEmail_Call { _c.Call.Return(run) return _c } @@ -290,6 +310,10 @@ func (_c *UserService_GetByID_Call) RunAndReturn(run func(context.Context, strin func (_m *UserService) GetByIDs(ctx context.Context, userIDs []string) ([]user.User, error) { ret := _m.Called(ctx, userIDs) + if len(ret) == 0 { + panic("no return value specified for GetByIDs") + } + var r0 []user.User var r1 error if rf, ok := ret.Get(0).(func(context.Context, []string) ([]user.User, error)); ok { @@ -345,6 +369,10 @@ func (_c *UserService_GetByIDs_Call) RunAndReturn(run func(context.Context, []st func (_m *UserService) List(ctx context.Context, flt user.Filter) (user.PagedUsers, error) { ret := _m.Called(ctx, flt) + if len(ret) == 0 { + panic("no return value specified for List") + } + var r0 user.PagedUsers var r1 error if rf, ok := ret.Get(0).(func(context.Context, user.Filter) (user.PagedUsers, error)); ok { @@ -398,6 +426,10 @@ func (_c *UserService_List_Call) RunAndReturn(run func(context.Context, user.Fil func (_m *UserService) UpdateByEmail(ctx context.Context, toUpdate user.User) (user.User, error) { ret := _m.Called(ctx, toUpdate) + if len(ret) == 0 { + panic("no return value specified for UpdateByEmail") + } + var r0 user.User var r1 error if rf, ok := ret.Get(0).(func(context.Context, user.User) (user.User, error)); ok { @@ -451,6 +483,10 @@ func (_c *UserService_UpdateByEmail_Call) RunAndReturn(run func(context.Context, func (_m *UserService) UpdateByID(ctx context.Context, toUpdate user.User) (user.User, error) { ret := _m.Called(ctx, toUpdate) + if len(ret) == 0 { + panic("no return value specified for UpdateByID") + } + var r0 user.User var r1 error if rf, ok := ret.Get(0).(func(context.Context, user.User) (user.User, error)); ok { diff --git a/internal/api/v1beta1/user.go b/internal/api/v1beta1/user.go index 5a145801b..86c51613b 100644 --- a/internal/api/v1beta1/user.go +++ b/internal/api/v1beta1/user.go @@ -23,7 +23,7 @@ import ( var grpcUserNotFoundError = status.Errorf(codes.NotFound, "user doesn't exist") type UserService interface { - GetByID(ctx context.Context, id string) (user.User, error) + Get(ctx context.Context, idOrEmail string) (user.User, error) GetByIDs(ctx context.Context, userIDs []string) ([]user.User, error) GetByEmail(ctx context.Context, email string) (user.User, error) Create(ctx context.Context, user user.User) (user.User, error) @@ -165,7 +165,7 @@ func (h Handler) CreateMetadataKey(ctx context.Context, request *shieldv1beta1.C func (h Handler) GetUser(ctx context.Context, request *shieldv1beta1.GetUserRequest) (*shieldv1beta1.GetUserResponse, error) { logger := grpczap.Extract(ctx) - fetchedUser, err := h.userService.GetByID(ctx, request.GetId()) + fetchedUser, err := h.userService.Get(ctx, request.GetId()) if err != nil { logger.Error(err.Error()) switch { diff --git a/internal/api/v1beta1/user_test.go b/internal/api/v1beta1/user_test.go index fc3579666..dd04750b6 100644 --- a/internal/api/v1beta1/user_test.go +++ b/internal/api/v1beta1/user_test.go @@ -302,7 +302,7 @@ func TestGetUser(t *testing.T) { { title: "should return not found error if user does not exist", setup: func(us *mocks.UserService) { - us.EXPECT().GetByID(mock.AnythingOfType("*context.emptyCtx"), randomID).Return(user.User{}, user.ErrNotExist) + us.EXPECT().Get(mock.AnythingOfType("*context.emptyCtx"), randomID).Return(user.User{}, user.ErrNotExist) }, req: &shieldv1beta1.GetUserRequest{ Id: randomID, @@ -313,7 +313,7 @@ func TestGetUser(t *testing.T) { { title: "should return not found error if user id is not uuid", setup: func(us *mocks.UserService) { - us.EXPECT().GetByID(mock.AnythingOfType("*context.emptyCtx"), "some-id").Return(user.User{}, user.ErrInvalidUUID) + us.EXPECT().Get(mock.AnythingOfType("*context.emptyCtx"), "some-id").Return(user.User{}, user.ErrInvalidUUID) }, req: &shieldv1beta1.GetUserRequest{ Id: "some-id", @@ -324,7 +324,7 @@ func TestGetUser(t *testing.T) { { title: "should return not found error if user id is invalid", setup: func(us *mocks.UserService) { - us.EXPECT().GetByID(mock.AnythingOfType("*context.emptyCtx"), "").Return(user.User{}, user.ErrInvalidID) + us.EXPECT().Get(mock.AnythingOfType("*context.emptyCtx"), "").Return(user.User{}, user.ErrInvalidID) }, req: &shieldv1beta1.GetUserRequest{}, want: nil, @@ -333,7 +333,7 @@ func TestGetUser(t *testing.T) { { title: "should return user if user service return nil error", setup: func(us *mocks.UserService) { - us.EXPECT().GetByID(mock.AnythingOfType("*context.emptyCtx"), randomID).Return( + us.EXPECT().Get(mock.AnythingOfType("*context.emptyCtx"), randomID).Return( user.User{ ID: randomID, Name: "some user", diff --git a/internal/proxy/hook/authz/mocks/relation_service.go b/internal/proxy/hook/authz/mocks/relation_service.go index da86ba102..9a298080a 100644 --- a/internal/proxy/hook/authz/mocks/relation_service.go +++ b/internal/proxy/hook/authz/mocks/relation_service.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.38.0. DO NOT EDIT. package mocks @@ -26,6 +26,10 @@ func (_m *RelationService) EXPECT() *RelationService_Expecter { func (_m *RelationService) Create(ctx context.Context, _a1 relation.RelationV2) (relation.RelationV2, error) { ret := _m.Called(ctx, _a1) + if len(ret) == 0 { + panic("no return value specified for Create") + } + var r0 relation.RelationV2 var r1 error if rf, ok := ret.Get(0).(func(context.Context, relation.RelationV2) (relation.RelationV2, error)); ok { diff --git a/internal/proxy/hook/authz/mocks/relation_transformer.go b/internal/proxy/hook/authz/mocks/relation_transformer.go index 46a2a72f9..4f7f80692 100644 --- a/internal/proxy/hook/authz/mocks/relation_transformer.go +++ b/internal/proxy/hook/authz/mocks/relation_transformer.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.38.0. DO NOT EDIT. package mocks @@ -26,6 +26,10 @@ func (_m *RelationTransformer) EXPECT() *RelationTransformer_Expecter { func (_m *RelationTransformer) TransformRelation(ctx context.Context, rlt relation.RelationV2) (relation.RelationV2, error) { ret := _m.Called(ctx, rlt) + if len(ret) == 0 { + panic("no return value specified for TransformRelation") + } + var r0 relation.RelationV2 var r1 error if rf, ok := ret.Get(0).(func(context.Context, relation.RelationV2) (relation.RelationV2, error)); ok { diff --git a/internal/proxy/hook/authz/mocks/resource_service.go b/internal/proxy/hook/authz/mocks/resource_service.go index 7965d6ac6..354521e28 100644 --- a/internal/proxy/hook/authz/mocks/resource_service.go +++ b/internal/proxy/hook/authz/mocks/resource_service.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.38.0. DO NOT EDIT. package mocks @@ -26,6 +26,10 @@ func (_m *ResourceService) EXPECT() *ResourceService_Expecter { func (_m *ResourceService) Create(ctx context.Context, _a1 resource.Resource) (resource.Resource, error) { ret := _m.Called(ctx, _a1) + if len(ret) == 0 { + panic("no return value specified for Create") + } + var r0 resource.Resource var r1 error if rf, ok := ret.Get(0).(func(context.Context, resource.Resource) (resource.Resource, error)); ok { diff --git a/test/e2e_test/smoke/api_test.go b/test/e2e_test/smoke/api_test.go new file mode 100644 index 000000000..bb91c102c --- /dev/null +++ b/test/e2e_test/smoke/api_test.go @@ -0,0 +1,87 @@ +package e2e_test + +import ( + "context" + "testing" + + "github.com/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" + "github.com/goto/shield/config" + shieldv1beta1 "github.com/goto/shield/proto/v1beta1" + "github.com/goto/shield/test/e2e_test/testbench" + "github.com/stretchr/testify/suite" + "google.golang.org/grpc/metadata" +) + +type EndToEndAPISmokeTestSuite struct { + suite.Suite + client shieldv1beta1.ShieldServiceClient + cancelClient func() + testBench *testbench.TestBench + appConfig *config.Shield + users []*shieldv1beta1.User +} + +func (s *EndToEndAPISmokeTestSuite) SetupTest() { + ctx := context.Background() + s.client, s.appConfig, s.cancelClient, _ = testbench.SetupTests(s.T()) + + // validate + uRes, err := s.client.ListUsers(ctx, &shieldv1beta1.ListUsersRequest{}) + s.Require().NoError(err) + s.Require().Equal(9, len(uRes.GetUsers())) + s.users = uRes.GetUsers() + + oRes, err := s.client.ListOrganizations(ctx, &shieldv1beta1.ListOrganizationsRequest{}) + s.Require().NoError(err) + s.Require().Equal(1, len(oRes.GetOrganizations())) + + pRes, err := s.client.ListProjects(ctx, &shieldv1beta1.ListProjectsRequest{}) + s.Require().NoError(err) + s.Require().Equal(1, len(pRes.GetProjects())) + + gRes, err := s.client.ListGroups(ctx, &shieldv1beta1.ListGroupsRequest{}) + s.Require().NoError(err) + s.Require().Equal(3, len(gRes.GetGroups())) +} + +func (s *EndToEndAPISmokeTestSuite) TearDownTest() { + s.cancelClient() + // Clean tests + err := s.testBench.CleanUp() + s.Require().NoError(err) +} + +func (s *EndToEndAPISmokeTestSuite) TestUserAPI() { + ctxOrgAdminAuth := metadata.NewOutgoingContext(context.Background(), metadata.New(map[string]string{ + testbench.IdentityHeader: testbench.OrgAdminEmail, + })) + + s.Run("1. get user with uuid should return a correct user detail", func() { + res, err := s.client.GetUser(ctxOrgAdminAuth, &shieldv1beta1.GetUserRequest{ + Id: s.users[0].GetId(), + }) + + s.Assert().Empty(cmp.Diff(s.users[0], res.GetUser(), + cmpopts.IgnoreUnexported(shieldv1beta1.User{}), + cmpopts.IgnoreFields(shieldv1beta1.User{}, "Metadata", "CreatedAt", "UpdatedAt"), + )) + s.Assert().NoError(err) + }) + + s.Run("2. get user with e-mail should return a correct user detail", func() { + res, err := s.client.GetUser(ctxOrgAdminAuth, &shieldv1beta1.GetUserRequest{ + Id: s.users[1].GetEmail(), + }) + + s.Assert().Empty(cmp.Diff(s.users[1], res.GetUser(), + cmpopts.IgnoreUnexported(shieldv1beta1.User{}), + cmpopts.IgnoreFields(shieldv1beta1.User{}, "Metadata", "CreatedAt", "UpdatedAt"), + )) + s.Assert().NoError(err) + }) +} + +func TestEndToEndAPISmokeTestSuite(t *testing.T) { + suite.Run(t, new(EndToEndAPISmokeTestSuite)) +}