Skip to content

Commit

Permalink
Issue #51 Updated to OPA 0.67.1 and Go 1.23.0, fix HexaBundleServer p…
Browse files Browse the repository at this point in the history
…ath issue

Signed-off-by: Phil Hunt <[email protected]>
  • Loading branch information
independentid committed Aug 20, 2024
1 parent bfc7d18 commit 3189463
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 122 deletions.
1 change: 1 addition & 0 deletions cmd/hexaBundleServer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ func (a *BundleApp) loadHandlers(jwtAuthorizer *oauth2support.ResourceJwtAuthori
return func(router *mux.Router) {
router.HandleFunc("/bundles/bundle.tar.gz", oauth2support.JwtAuthenticationHandler(a.download, jwtAuthorizer, []string{tokensupport.ScopeBundle, tokensupport.ScopeAdmin})).Methods("GET")
router.HandleFunc("/bundles", oauth2support.JwtAuthenticationHandler(a.upload, jwtAuthorizer, []string{tokensupport.ScopeBundle, tokensupport.ScopeAdmin})).Methods("POST")
router.HandleFunc("/bundles/bundle.tar.gz", oauth2support.JwtAuthenticationHandler(a.upload, jwtAuthorizer, []string{tokensupport.ScopeBundle, tokensupport.ScopeAdmin})).Methods("POST")
router.HandleFunc("/reset", oauth2support.JwtAuthenticationHandler(a.reset, jwtAuthorizer, []string{tokensupport.ScopeAdmin})).Methods("GET")
}
}
Expand Down
13 changes: 13 additions & 0 deletions cmd/hexaBundleServer/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,23 @@ func TestUpload(t *testing.T) {
_, _ = formFile.Write(buffer.Bytes())
_ = writer.Close()

// test to /bundles
contentType := writer.FormDataContentType()
response, _ := client.Post(fmt.Sprintf("https://%s/bundles", app.Addr), contentType, buf)
assert.Equal(t, http.StatusCreated, response.StatusCode)

// repeat test to /bundles/bundle.tar.gz (sdk uses this)
buf = new(bytes.Buffer)
writer = multipart.NewWriter(buf)
_ = compressionsupport.Gzip(&buffer, tar)
formFile, _ = writer.CreateFormFile("bundle", "bundle.tar.gz")
_, _ = formFile.Write(buffer.Bytes())
_ = writer.Close()
contentType = writer.FormDataContentType()

response2, _ := client.Post(fmt.Sprintf("https://%s/bundles/bundle.tar.gz", app.Addr), contentType, buf)
assert.Equal(t, http.StatusCreated, response2.StatusCode)

_, _ = client.Get(fmt.Sprintf("http://%s/reset", app.Addr))
websupport.Stop(app)
}
Expand Down
80 changes: 40 additions & 40 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
module github.com/hexa-org/policy-opa

go 1.22
go 1.23

toolchain go1.22.5
toolchain go1.23.0

require (
github.com/golang-jwt/jwt/v5 v5.2.1
github.com/gorilla/mux v1.8.1
github.com/hexa-org/policy-mapper v0.6.15
github.com/open-policy-agent/opa v0.67.0
github.com/open-policy-agent/opa v0.67.1
github.com/stretchr/testify v1.9.0
github.com/tidwall/gjson v1.17.1
golang.org/x/net v0.27.0
github.com/tidwall/gjson v1.17.3
golang.org/x/net v0.28.0
)

require (
cloud.google.com/go/auth v0.7.2 // indirect
cloud.google.com/go/auth/oauth2adapt v0.2.3 // indirect
cloud.google.com/go/auth v0.9.0 // indirect
cloud.google.com/go/auth/oauth2adapt v0.2.4 // indirect
cloud.google.com/go/compute/metadata v0.5.0 // indirect
github.com/AdaLogics/go-fuzz-headers v0.0.0-20240716105424-66b64c4bb379 // indirect
github.com/AdaLogics/go-fuzz-headers v0.0.0-20240806141605-e8a1dd7889d6 // indirect
github.com/MicahParks/jwkset v0.5.18 // indirect
github.com/MicahParks/keyfunc/v3 v3.3.3 // indirect
github.com/Microsoft/hcsshim v0.12.4 // indirect
github.com/OneOfOne/xxhash v1.2.8 // indirect
github.com/agnivade/levenshtein v1.1.1 // indirect
github.com/alexedwards/scs/v2 v2.8.0 // indirect
github.com/aws/aws-sdk-go-v2 v1.30.3 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.3 // indirect
github.com/aws/aws-sdk-go-v2/config v1.27.27 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.17.27 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.11 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.15 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.15 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.0 // indirect
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.15 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.3 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.3.17 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.17 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.17.15 // indirect
github.com/aws/aws-sdk-go-v2/service/s3 v1.58.2 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.22.4 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.26.4 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.30.3 // indirect
github.com/aws/smithy-go v1.20.3 // indirect
github.com/aws/aws-sdk-go-v2 v1.30.4 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.4 // indirect
github.com/aws/aws-sdk-go-v2/config v1.27.28 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.17.28 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.12 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.16 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.16 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 // indirect
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.16 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.4 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.3.18 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.18 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.17.16 // indirect
github.com/aws/aws-sdk-go-v2/service/s3 v1.60.0 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.22.5 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.26.5 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.30.4 // indirect
github.com/aws/smithy-go v1.20.4 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bytecodealliance/wasmtime-go/v3 v3.0.2 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
Expand All @@ -61,7 +61,7 @@ require (
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.5 // indirect
github.com/go-ini/ini v1.67.0 // indirect
github.com/go-jose/go-jose/v4 v4.0.3 // indirect
github.com/go-jose/go-jose/v4 v4.0.4 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-playground/locales v0.14.1 // indirect
Expand All @@ -78,7 +78,7 @@ require (
github.com/google/s2a-go v0.1.8 // indirect
github.com/google/uuid v1.6.0
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.21.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hhsnopek/etag v0.0.0-20171206181245-aea95f647346 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
Expand All @@ -96,7 +96,7 @@ require (
github.com/peterh/liner v1.2.2 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.19.1 // indirect
github.com/prometheus/client_golang v1.20.1 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.55.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
Expand All @@ -108,7 +108,7 @@ require (
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/cast v1.7.0 // indirect
github.com/spf13/cobra v1.8.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.19.0 // indirect
Expand All @@ -131,16 +131,16 @@ require (
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
go.uber.org/automaxprocs v1.5.3 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.25.0 // indirect
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56
golang.org/x/oauth2 v0.21.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/time v0.5.0 // indirect
google.golang.org/api v0.189.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240725223205-93522f1f2a9f // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240725223205-93522f1f2a9f // indirect
golang.org/x/crypto v0.26.0 // indirect
golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa
golang.org/x/oauth2 v0.22.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.24.0 // indirect
golang.org/x/text v0.17.0 // indirect
golang.org/x/time v0.6.0 // indirect
google.golang.org/api v0.193.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240820151423-278611b39280 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240820151423-278611b39280 // indirect
google.golang.org/grpc v1.65.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
Expand Down
Loading

0 comments on commit 3189463

Please sign in to comment.