Skip to content

Commit

Permalink
Uses a string for License.UUID instead of uuid.UUID
Browse files Browse the repository at this point in the history
There are some case where the license UUID is a valid license but not a
valid UUID.

Fixes: elastic#11640
  • Loading branch information
ph committed Apr 4, 2019
1 parent 555a89a commit 0fe3b39
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
3 changes: 1 addition & 2 deletions x-pack/libbeat/licenser/elastic_fetcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"testing"
"time"

"github.com/gofrs/uuid"
"github.com/stretchr/testify/assert"

"github.com/elastic/beats/libbeat/outputs/elasticsearch"
Expand Down Expand Up @@ -133,7 +132,7 @@ func TestParseJSON(t *testing.T) {
return
}

id, _ := uuid.FromString("936183d8-f48c-4a3f-959a-a52aa2563279")
id := "936183d8-f48c-4a3f-959a-a52aa2563279"
assert.Equal(t, id, license.UUID)

assert.NotNil(t, license.Type)
Expand Down
4 changes: 1 addition & 3 deletions x-pack/libbeat/licenser/license.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ package licenser

import (
"time"

"github.com/gofrs/uuid"
)

// License represents the license of this beat, the license is fetched and returned from
Expand All @@ -27,7 +25,7 @@ import (
// mode is the license in operation. (effective license)
// status is the type installed is active or not.
type License struct {
UUID uuid.UUID `json:"uid"`
UUID string `json:"uid"`
Type LicenseType `json:"type"`
Mode LicenseType `json:"mode"`
Status State `json:"status"`
Expand Down
2 changes: 1 addition & 1 deletion x-pack/libbeat/licenser/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func mustUUIDV4() uuid.UUID {
// OSSLicense default license to use.
var (
OSSLicense = &License{
UUID: mustUUIDV4(),
UUID: mustUUIDV4().String(),
Type: OSS,
Mode: OSS,
Status: Active,
Expand Down
10 changes: 5 additions & 5 deletions x-pack/libbeat/licenser/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (m *mockFetcher) Close() {

func TestRetrieveLicense(t *testing.T) {
i := &License{
UUID: mustUUIDV4(),
UUID: mustUUIDV4().String(),
Type: Basic,
Mode: Basic,
Status: Active,
Expand Down Expand Up @@ -124,7 +124,7 @@ func TestRetrieveLicense(t *testing.T) {
}

i := &License{
UUID: mustUUIDV4(),
UUID: mustUUIDV4().String(),
Type: Platinum,
Mode: Platinum,
Status: Active,
Expand All @@ -144,7 +144,7 @@ func TestRetrieveLicense(t *testing.T) {

func TestWatcher(t *testing.T) {
i := &License{
UUID: mustUUIDV4(),
UUID: mustUUIDV4().String(),
Type: Basic,
Mode: Basic,
Status: Active,
Expand Down Expand Up @@ -246,7 +246,7 @@ func TestWatcher(t *testing.T) {
if c == 0 {
assert.Equal(t, Basic, license.Get())
mock.Insert(&License{
UUID: mustUUIDV4(),
UUID: mustUUIDV4().String(),
Type: Platinum,
Mode: Platinum,
Status: Active,
Expand Down Expand Up @@ -288,7 +288,7 @@ func TestWatcher(t *testing.T) {

func TestWaitForLicense(t *testing.T) {
i := &License{
UUID: mustUUIDV4(),
UUID: mustUUIDV4().String(),
Type: Basic,
Mode: Basic,
Status: Active,
Expand Down

0 comments on commit 0fe3b39

Please sign in to comment.