2021-05-05 05:06:05 +07:00
|
|
|
package handlers
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
2021-08-11 08:04:35 +07:00
|
|
|
"github.com/authelia/authelia/v4/internal/session"
|
2021-05-05 05:06:05 +07:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestShouldDetectIfConsentIsMissing(t *testing.T) {
|
|
|
|
var workflow *session.OIDCWorkflowSession
|
|
|
|
|
|
|
|
requestedScopes := []string{"openid", "profile"}
|
|
|
|
requestedAudience := []string{"https://authelia.com"}
|
|
|
|
|
|
|
|
assert.True(t, isConsentMissing(workflow, requestedScopes, requestedAudience))
|
|
|
|
|
|
|
|
workflow = &session.OIDCWorkflowSession{
|
|
|
|
GrantedScopes: []string{"openid", "profile"},
|
|
|
|
GrantedAudience: []string{"https://authelia.com"},
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.False(t, isConsentMissing(workflow, requestedScopes, requestedAudience))
|
|
|
|
|
|
|
|
requestedScopes = []string{"openid", "profile", "group"}
|
|
|
|
|
|
|
|
assert.True(t, isConsentMissing(workflow, requestedScopes, requestedAudience))
|
|
|
|
|
|
|
|
requestedScopes = []string{"openid", "profile"}
|
|
|
|
requestedAudience = []string{"https://not.authelia.com"}
|
|
|
|
assert.True(t, isConsentMissing(workflow, requestedScopes, requestedAudience))
|
|
|
|
}
|