2021-12-15 00:47:09 +00:00
|
|
|
//go:build ent
|
|
|
|
// +build ent
|
|
|
|
|
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2022-03-18 14:12:28 +00:00
|
|
|
"github.com/hashicorp/nomad/api/internal/testutil"
|
2021-12-15 00:47:09 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestOperator_LicenseGet(t *testing.T) {
|
2022-03-17 13:34:57 +00:00
|
|
|
testutil.Parallel(t)
|
2021-12-15 00:47:09 +00:00
|
|
|
c, s, _ := makeACLClient(t, nil, nil)
|
|
|
|
defer s.Stop()
|
|
|
|
|
|
|
|
operator := c.Operator()
|
|
|
|
|
|
|
|
// Make authenticated request.
|
|
|
|
_, _, err := operator.LicenseGet(nil)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
// Make unauthenticated request.
|
|
|
|
c.SetSecretID("")
|
|
|
|
_, _, err = operator.LicenseGet(nil)
|
|
|
|
require.Error(t, err)
|
|
|
|
require.Contains(t, err.Error(), "403")
|
|
|
|
}
|