From 26103774a5aa031968507a9d9426a3e5767c2a91 Mon Sep 17 00:00:00 2001 From: zachmann Date: Mon, 27 May 2024 17:59:44 +0200 Subject: [PATCH] upgrade api --- go.mod | 2 +- go.sum | 11 ++++------- utils/profile/profile.go | 1 + utils/profile/restrictions.go | 1 + utils/profile/rotation.go | 1 + utils/profile/template_test.go | 8 ++++++++ 6 files changed, 16 insertions(+), 8 deletions(-) diff --git a/go.mod b/go.mod index d686462..7291c33 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/go-resty/resty/v2 v2.13.1 github.com/golang-jwt/jwt v3.2.2+incompatible github.com/jinzhu/copier v0.4.0 - github.com/oidc-mytoken/api v0.9.1 + github.com/oidc-mytoken/api v0.11.2-0.20240426092102-fa4d583a79ad github.com/pkg/errors v0.9.1 github.com/sirupsen/logrus v1.9.3 github.com/valyala/fasthttp v1.54.0 diff --git a/go.sum b/go.sum index 6a5a9ed..2389ccc 100644 --- a/go.sum +++ b/go.sum @@ -22,8 +22,8 @@ github.com/jinzhu/copier v0.4.0 h1:w3ciUoD19shMCRargcpm0cm91ytaBhDvuRpz1ODO/U8= github.com/jinzhu/copier v0.4.0/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg= github.com/klauspost/compress v1.17.7 h1:ehO88t2UGzQK66LMdE8tibEd1ErmzZjNEqWkjLAKQQg= github.com/klauspost/compress v1.17.7/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= -github.com/oidc-mytoken/api v0.9.1 h1:Hmv+KaGyxiodf92mXjELFeZOa9tBsQnUyEoBAFQNls8= -github.com/oidc-mytoken/api v0.9.1/go.mod h1:DBIlUbaIgGlf607VZx8zFC97VR3WNN0kaMVO1AqyTdE= +github.com/oidc-mytoken/api v0.11.2-0.20240426092102-fa4d583a79ad h1:jFJqhdX7BqiL4y9yURp48roCVv3p8n18c1J188T6Jz8= +github.com/oidc-mytoken/api v0.11.2-0.20240426092102-fa4d583a79ad/go.mod h1:4QwDXesKKEzbTmH2vENYCVcmdb5/gbDPg3DOm9HQLdg= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -31,12 +31,9 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= 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.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasthttp v1.54.0 h1:cCL+ZZR3z3HPLMVfEYVUMtJqVaui0+gu7Lx63unHwS0= diff --git a/utils/profile/profile.go b/utils/profile/profile.go index d1ae32e..57aa8a1 100644 --- a/utils/profile/profile.go +++ b/utils/profile/profile.go @@ -57,6 +57,7 @@ func (p Parser) ParseProfile(content []byte) (api.GeneralMytokenRequest, error) return pj.GeneralMytokenRequest, err } } + pj.IncludedProfiles = nil pj.GeneralMytokenRequest.Rotation, err = p.ParseRotationTemplate([]byte(pj.Rotation)) if err != nil { return pj.GeneralMytokenRequest, err diff --git a/utils/profile/restrictions.go b/utils/profile/restrictions.go index 3a5511a..b39b207 100644 --- a/utils/profile/restrictions.go +++ b/utils/profile/restrictions.go @@ -45,6 +45,7 @@ func (p Parser) ParseRestrictionsTemplate(content []byte) (api.Restrictions, err } finalRestrs := make(api.Restrictions, 0) for _, r := range restr { + r.IncludedProfiles = nil if !reflect.DeepEqual(r, timerestriction.APIRestriction{}) { ar := api.Restriction(r) finalRestrs = append(finalRestrs, &ar) diff --git a/utils/profile/rotation.go b/utils/profile/rotation.go index 4ec87e6..24fac83 100644 --- a/utils/profile/rotation.go +++ b/utils/profile/rotation.go @@ -33,5 +33,6 @@ func (p Parser) ParseRotationTemplate(content []byte) (*api.Rotation, error) { return nil, nil } err = errors.WithStack(json.Unmarshal(content, &rot)) + rot.IncludedProfiles = nil return &rot, err } diff --git a/utils/profile/template_test.go b/utils/profile/template_test.go index 3d43b01..b50ebc2 100644 --- a/utils/profile/template_test.go +++ b/utils/profile/template_test.go @@ -711,6 +711,7 @@ func TestProfileParser_ParseProfile(t *testing.T) { } if !reflect.DeepEqual(got, tt.want) { t.Errorf("ParseProfile() got = %+v, want %+v", got, tt.want) + return } }, ) @@ -838,6 +839,12 @@ func TestProfileParser_ParseRestrictionsTemplate(t *testing.T) { want: exampleRestrictions, wantErr: false, }, + { + name: "single include string in object without @", + content: []byte(`{"include":"example"}`), + want: exampleRestrictions, + wantErr: false, + }, { name: "single include in object without @", content: []byte(`{"include":["example"]}`), @@ -867,6 +874,7 @@ func TestProfileParser_ParseRestrictionsTemplate(t *testing.T) { } if !reflect.DeepEqual(got, tt.want) { t.Errorf("ParseRestrictionsTemplate() got = %+v, want %+v", got, tt.want) + return } }, )