mirror of
https://github.com/nais/wonderwall.git
synced 2026-08-23 21:16:14 +00:00
We no longer expect nor accept tokens with old acr values during validation as ID-porten no longer issues tokens with these values. This also removes backward compatibility in cases where configured values targeted the new ID-porten while using old ID-porten. We still maintain an internal mapping from old values to new values for forward compatibilty when using old values provided in the login parameter and the `openid.acr-values` flag.
39 lines
1.3 KiB
Go
39 lines
1.3 KiB
Go
package acr
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestValidateAcr(t *testing.T) {
|
|
for _, tt := range []struct {
|
|
name string
|
|
expected string
|
|
actual string
|
|
wantErr bool
|
|
}{
|
|
{"no mapping found, not equal", "some-value", "some-other-value", true},
|
|
{"no mapping found, expected equals actual", "some-value", "some-value", false},
|
|
{"Level3, higher acr accepted", "Level3", "idporten-loa-high", false},
|
|
{"Level3, no matching value", "Level3", "Level2", true},
|
|
{"Level3 -> idporten-loa-substantial", "Level3", "idporten-loa-substantial", false},
|
|
{"idporten-loa-substantial", "idporten-loa-substantial", "idporten-loa-substantial", false},
|
|
{"idporten-loa-substantial, higher acr accepted", "idporten-loa-substantial", "idporten-loa-high", false},
|
|
{"Level4, lower acr not accepted", "Level4", "idporten-loa-substantial", true},
|
|
{"Level4, no matching value", "Level4", "Level5", true},
|
|
{"Level4 -> idporten-loa-high", "Level4", "idporten-loa-high", false},
|
|
{"idporten-loa-high", "idporten-loa-high", "idporten-loa-high", false},
|
|
{"idporten-loa-high, lower acr not accepted", "idporten-loa-high", "idporten-loa-substantial", true},
|
|
} {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
err := Validate(tt.expected, tt.actual)
|
|
if tt.wantErr {
|
|
assert.Error(t, err)
|
|
} else {
|
|
assert.NoError(t, err)
|
|
}
|
|
})
|
|
}
|
|
}
|