diff --git a/licensing/license_manager.go b/licensing/license_manager.go index 01e648f4..4bf6604c 100644 --- a/licensing/license_manager.go +++ b/licensing/license_manager.go @@ -316,7 +316,7 @@ func startPillarMonitor() { contents := ` # Copyright Security Onion Solutions LLC and/or licensed to Security Onion Solutions LLC under one # or more contributor license agreements. Licensed under the Elastic License 2.0 as shown at -# https://securityonion.net/license; you may not use this file except in compliance with +# https://securityonion.net/license; you may not use this file except in compliance with # the Elastic License 2.0. # Note: Per the Elastic License 2.0, the second limitation states: @@ -325,7 +325,7 @@ func startPillarMonitor() { # in the software, and you may not remove or obscure any functionality in the # software that is protected by the license key." -# This file is generated by Security Onion and contains a list of license-enabled features. +# This file is generated by Security Onion and contains a list of license-enabled features. ` features := ListEnabledFeatures() if manager.status == LICENSE_STATUS_ACTIVE { diff --git a/licensing/license_manager_test.go b/licensing/license_manager_test.go index bd4bdb8e..1283a2b1 100644 --- a/licensing/license_manager_test.go +++ b/licensing/license_manager_test.go @@ -18,11 +18,17 @@ import ( "testing" "time" - "github.com/stretchr/testify/assert" + "github.com/tj/assert" ) const EXPIRED_KEY = ` H4sIAIvZnGMAA22QR4+bUBSF9/kVFlvPBExz2ZlqijHVNo6yeMaPYsOjPWMgyn8PMyNFihTpLm75zjnS/UXAOIYRzjpIbAiaohfv1Ef5FLX5rAvxRsC+yhqAsxJ9MfR/GASKDwcftnhmZhFELZy9z6yDP1MO7izw5JlmzWz3IAWirx2sSZHdJj4GD/hOUYtpzr9UHy7KtP3rYsBhusYQ4GcDW2Lz4+cb8WxhM7WLKbe8wa+uLaOgySd1inHVbkiyLQv4SmEDv2eoA/mU90bcAAb/UgCVeIK+VzmI4ES0WYI+oyYm8VBxAEZUFbKlp2ugz6t9n15kiX0uligc+es1jf3A7HldUAoctnhtxZ6f7R3+Rc5tOdqqcM5J/F0UyZJh4raOdcNTa6EEyoq+CXR0PloieilIUFlTgwa748r0chJZj2TdmAq3owZi3iFFk4vzx9mUGV41U1N3yLA/GEnCN+tdLa3uAR1zwn6MEh+EmDxefX9VulSjqi6F08hfcQLfYGNXnWxMFpwkKY3h6bJp8bs2z/zRfvCZEu7z3VDh8HRzoOMPa/51S8ho6LrBw7KZgu3qkq7KVGeHu+1Q9LZXkzJDJwaLnnwKpJAbnfkQstcyAlq0ho++q5YLDw11nES0xj+3NmfgvLhYC7rXKFGO927oPHg7oql6MNvDqxMWYxPuBkg/K+Uum/bxnGT90mwjrvZD4+yJmly1Llo+rsGZdZugo307jKf/FbdR950Vr1BHnRrlZMwsACQml/XKq8J5iV5HxgF7sub6Xueyvk7Gfo2Km1AuVZYsWNOv0FEtB4H1WJW/ayfh1S0ZZiB+f/sDb9bxLiEDAAA= ` +func awaitPillarMonitor() { + for pillarMonitorCount == 0 { + time.Sleep(50 * time.Millisecond) + } +} + func teardown() { awaitPillarMonitor() os.Remove(pillarFilename) @@ -259,12 +265,6 @@ func TestValidateDataUrl(tester *testing.T) { assert.False(tester, ValidateDataUrl("bar")) } -func awaitPillarMonitor() { - for pillarMonitorCount == 0 { - time.Sleep(50 * time.Millisecond) - } -} - func TestPillarMonitor(tester *testing.T) { defer setup()() @@ -283,19 +283,18 @@ features: } func TestPillarMonitorAllFeatures(tester *testing.T) { - Test("", 0, 0, "", "") + defer setup()() - pillarFilename = "/tmp/soc_test_pillar_monitor.sls" + Test("", 0, 0, "", "") - os.Remove(pillarFilename) - startPillarMonitor() - assert.Equal(tester, manager.status, LICENSE_STATUS_ACTIVE) + awaitPillarMonitor() + assert.Equal(tester, LICENSE_STATUS_ACTIVE, manager.status) contents, _ := os.ReadFile(pillarFilename) expected := ` # Copyright Security Onion Solutions LLC and/or licensed to Security Onion Solutions LLC under one # or more contributor license agreements. Licensed under the Elastic License 2.0 as shown at -# https://securityonion.net/license; you may not use this file except in compliance with +# https://securityonion.net/license; you may not use this file except in compliance with # the Elastic License 2.0. # Note: Per the Elastic License 2.0, the second limitation states: @@ -304,7 +303,7 @@ func TestPillarMonitorAllFeatures(tester *testing.T) { # in the software, and you may not remove or obscure any functionality in the # software that is protected by the license key." -# This file is generated by Security Onion and contains a list of license-enabled features. +# This file is generated by Security Onion and contains a list of license-enabled features. features: - fips - oidc @@ -322,7 +321,6 @@ func TestPillarMonitor_Fail(tester *testing.T) { Init("") - assert.Equal(tester, manager.status, LICENSE_STATUS_UNPROVISIONED) awaitPillarMonitor() - assert.Equal(tester, manager.status, LICENSE_STATUS_INVALID) + assert.Equal(tester, LICENSE_STATUS_INVALID, manager.status) }