Add secure automatic agent updates
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
@@ -27,6 +28,31 @@ func TestAgentEnrollmentTokenIsSingleUse(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCurrentAgentUpdateManifestMatchesExecutable(t *testing.T) {
|
||||
manifest, path, err := currentAgentUpdate()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if manifest.URL != "/api/agent/binary" || len(manifest.SHA256) != 64 {
|
||||
t.Fatalf("unexpected manifest: %#v", manifest)
|
||||
}
|
||||
if _, err = os.Stat(path); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAgentOnlyInstallsNewerVersion(t *testing.T) {
|
||||
if !newerAgentVersion("v0.14.0", "v0.13.0") {
|
||||
t.Fatal("new version was not detected")
|
||||
}
|
||||
if newerAgentVersion("v0.12.0", "v0.13.0") {
|
||||
t.Fatal("downgrade was allowed")
|
||||
}
|
||||
if newerAgentVersion("v0.13.0", "v0.13.0") {
|
||||
t.Fatal("same version was offered")
|
||||
}
|
||||
}
|
||||
|
||||
func TestAgentReportAuthenticationAndOfflineState(t *testing.T) {
|
||||
store, err := openStore(":memory:")
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user