2023-04-10 15:36:59 +00:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
2021-12-15 00:47:09 +00:00
|
|
|
//go:build ent
|
|
|
|
|
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2022-03-18 14:12:28 +00:00
|
|
|
"github.com/hashicorp/nomad/api/internal/testutil"
|
2023-01-01 18:57:26 +00:00
|
|
|
"github.com/shoenig/test/must"
|
2021-12-15 00:47:09 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestOperator_LicenseGet(t *testing.T) {
|
2022-03-17 13:34:57 +00:00
|
|
|
testutil.Parallel(t)
|
2023-01-01 18:57:26 +00:00
|
|
|
|
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)
|
2023-01-01 18:57:26 +00:00
|
|
|
must.NoError(t, err)
|
2021-12-15 00:47:09 +00:00
|
|
|
|
|
|
|
// Make unauthenticated request.
|
|
|
|
c.SetSecretID("")
|
|
|
|
_, _, err = operator.LicenseGet(nil)
|
2023-01-01 18:57:26 +00:00
|
|
|
must.ErrorContains(t, err, "403")
|
2021-12-15 00:47:09 +00:00
|
|
|
}
|