mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
35 lines
1.3 KiB
Go
35 lines
1.3 KiB
Go
|
package oidc
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
|
||
|
"github.com/stretchr/testify/assert"
|
||
|
|
||
|
"github.com/authelia/authelia/internal/authentication"
|
||
|
"github.com/authelia/authelia/internal/authorization"
|
||
|
)
|
||
|
|
||
|
func TestIsAuthenticationLevelSufficient(t *testing.T) {
|
||
|
c := InternalClient{}
|
||
|
|
||
|
c.Policy = authorization.Bypass
|
||
|
assert.True(t, c.IsAuthenticationLevelSufficient(authentication.NotAuthenticated))
|
||
|
assert.True(t, c.IsAuthenticationLevelSufficient(authentication.OneFactor))
|
||
|
assert.True(t, c.IsAuthenticationLevelSufficient(authentication.TwoFactor))
|
||
|
|
||
|
c.Policy = authorization.OneFactor
|
||
|
assert.False(t, c.IsAuthenticationLevelSufficient(authentication.NotAuthenticated))
|
||
|
assert.True(t, c.IsAuthenticationLevelSufficient(authentication.OneFactor))
|
||
|
assert.True(t, c.IsAuthenticationLevelSufficient(authentication.TwoFactor))
|
||
|
|
||
|
c.Policy = authorization.TwoFactor
|
||
|
assert.False(t, c.IsAuthenticationLevelSufficient(authentication.NotAuthenticated))
|
||
|
assert.False(t, c.IsAuthenticationLevelSufficient(authentication.OneFactor))
|
||
|
assert.True(t, c.IsAuthenticationLevelSufficient(authentication.TwoFactor))
|
||
|
|
||
|
c.Policy = authorization.Denied
|
||
|
assert.False(t, c.IsAuthenticationLevelSufficient(authentication.NotAuthenticated))
|
||
|
assert.False(t, c.IsAuthenticationLevelSufficient(authentication.OneFactor))
|
||
|
assert.False(t, c.IsAuthenticationLevelSufficient(authentication.TwoFactor))
|
||
|
}
|