pomerium/internal/identity/claims_test.go
Caleb Doxsey 153e438eb6
authorize: implement allowed_idp_claims (#1542)
* add arbitrary claims to session

* add support for maps

* update flattened claims

* fix eol

* fix trailing whitespace

* fix tests
2020-10-23 14:05:37 -06:00

28 lines
434 B
Go

package identity
import (
"encoding/json"
"testing"
"github.com/stretchr/testify/assert"
)
func TestClaims_Flatten(t *testing.T) {
var claims Claims
_ = json.Unmarshal([]byte(`
{
"a": {
"aa": {
"aaa": 12345
},
"ab": [1, 2, 3, 4, 5]
}
}
`), &claims)
flattened := claims.Flatten()
assert.Equal(t, FlattenedClaims{
"a.aa.aaa": {12345.0},
"a.ab": {1.0, 2.0, 3.0, 4.0, 5.0},
}, flattened)
}