mirror of
https://github.com/grafana/grafana.git
synced 2025-07-30 00:31:40 +08:00
25 lines
621 B
Go
25 lines
621 B
Go
package resource
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/grafana/grafana/pkg/apimachinery/identity"
|
|
)
|
|
|
|
func TestIDTokenExtractor(t *testing.T) {
|
|
t.Run("should return an error when no claims found", func(t *testing.T) {
|
|
token, err := idTokenExtractor(context.Background())
|
|
assert.Error(t, err)
|
|
assert.Empty(t, token)
|
|
})
|
|
t.Run("should return an empty token when grafana identity is set", func(t *testing.T) {
|
|
ctx, _ := identity.WithServiceIdentity(context.Background(), 0)
|
|
token, err := idTokenExtractor(ctx)
|
|
assert.NoError(t, err)
|
|
assert.Empty(t, token)
|
|
})
|
|
}
|