Skip to content

Commit

Permalink
upgrade api
Browse files Browse the repository at this point in the history
  • Loading branch information
zachmann committed May 27, 2024
1 parent b81a1c6 commit 2610377
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 4 additions & 7 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,18 @@ 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=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
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=
Expand Down
1 change: 1 addition & 0 deletions utils/profile/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions utils/profile/restrictions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions utils/profile/rotation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
8 changes: 8 additions & 0 deletions utils/profile/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
},
)
Expand Down Expand Up @@ -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"]}`),
Expand Down Expand Up @@ -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
}
},
)
Expand Down

0 comments on commit 2610377

Please sign in to comment.