Files
Trong Huu Nguyen 1906024da0 feat(openid/acr): remove old values and backward compatibility for new idporten
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.
2024-06-27 12:34:16 +02:00

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)
}
})
}
}