mirror of
https://github.com/pomerium/pomerium.git
synced 2025-04-29 18:36:30 +02:00
core/ui: fix cycle in profile data (#5168)
This commit is contained in:
parent
968e3358a3
commit
fd086bd06b
2 changed files with 38 additions and 5 deletions
|
@ -59,11 +59,7 @@ func (data UserInfoData) profileJSON() map[string]any {
|
||||||
}
|
}
|
||||||
|
|
||||||
m := map[string]any{}
|
m := map[string]any{}
|
||||||
claims := make(map[string]any)
|
m["claims"] = data.Profile.GetClaims().AsMap()
|
||||||
for k, v := range data.Profile.GetClaims().AsMap() {
|
|
||||||
claims[k] = v
|
|
||||||
}
|
|
||||||
m["claims"] = m
|
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
37
internal/handlers/userinfo_test.go
Normal file
37
internal/handlers/userinfo_test.go
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
package handlers_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"google.golang.org/protobuf/types/known/structpb"
|
||||||
|
|
||||||
|
"github.com/pomerium/pomerium/internal/handlers"
|
||||||
|
"github.com/pomerium/pomerium/pkg/grpc/identity"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestUserInfoData(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
claims, _ := structpb.NewStruct(map[string]any{
|
||||||
|
"TEST": "VALUE",
|
||||||
|
})
|
||||||
|
data := handlers.UserInfoData{Profile: &identity.Profile{Claims: claims}}
|
||||||
|
m := data.ToJSON()
|
||||||
|
bs, err := json.Marshal(m)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.JSONEq(t, `{
|
||||||
|
"csrfToken": "",
|
||||||
|
"isEnterprise": false,
|
||||||
|
"isImpersonated": false,
|
||||||
|
"profile": {
|
||||||
|
"claims": {"TEST":"VALUE"}
|
||||||
|
},
|
||||||
|
"session": null,
|
||||||
|
"user": null,
|
||||||
|
"webAuthnCreationOptions": null,
|
||||||
|
"webAuthnRequestOptions": null,
|
||||||
|
"webAuthnUrl": ""
|
||||||
|
}`, string(bs))
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue