diff --git a/README.md b/README.md index d07fec8..3ff7ba4 100644 --- a/README.md +++ b/README.md @@ -4,14 +4,19 @@ https://github.com/amidaware/tacticalrmm #### building the agent - linux ``` env CGO_ENABLED=0 GOOS= GOARCH= go build -ldflags "-s -w -X 'main.version=v2.0.4'" -example: env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w -X 'main.version=v2.0.4' -o build/output/rmmagent" +example: env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w -X 'main.version=v2.0.4'" -o build/output/rmmagent +``` + +#### building the agent - macos +``` +env GOOS=darwin GOARCH=amd64 go build -ldflags "-s -w -X 'main.version=v2.0.4'" -o build/output/rmmagent ``` #### building the agent - windows ``` go install github.com/josephspurrier/goversioninfo/cmd/goversioninfo go generate -$env:CGO_ENABLED="0";$env:GOOS="windows";$env:GOARCH="amd64"; go build -ldflags "-s -w -X 'main.version=v2.0.4' -o build/output/tacticalrmm.exe" +$env:CGO_ENABLED="0";$env:GOOS="windows";$env:GOARCH="amd64"; go build -ldflags "-s -w -X 'main.version=v2.0.4'" -o build/output/tacticalrmm.exe ``` ### tests diff --git a/agent/agent_test.go b/agent/agent_test.go index d8b745e..2362dff 100644 --- a/agent/agent_test.go +++ b/agent/agent_test.go @@ -17,4 +17,25 @@ func TestAgentId(t *testing.T) { } else { t.Logf("AgentID: %s", a.AgentID) } -} \ No newline at end of file +} + +func TestSystemRebootRequired(t *testing.T) { + a := New(lg, version) + result, err := a.SystemRebootRequired() + if err != nil { + t.Error(err) + } + + t.Logf("Result: %t", result) +} + +func TestLoggedOnUser(t *testing.T) { + a := New(lg, version) + result := a.LoggedOnUser() + if result == "" { + t.Errorf("Could not get logged on user.") + } + + t.Logf("Result: %s", result) +} + diff --git a/agent/install_test.go b/agent/install_test.go index 66325ba..0111c32 100644 --- a/agent/install_test.go +++ b/agent/install_test.go @@ -1,68 +1,62 @@ package agent import ( - "testing" "github.com/sirupsen/logrus" "github.com/spf13/viper" + "testing" ) - - func TestInstall(t *testing.T) { testTable := []struct { - name string + name string expectedError error - version string + version string + log logrus.Logger }{ { - name: "Install", + name: "Install", expectedError: nil, - version: "2.0.4", + version: "2.0.4", + log: *logrus.New(), }, { - name: "Install Error", + name: "Install Error", expectedError: nil, - version: "bad ver", + version: "bad ver", + log: *logrus.New(), }, } for _, tt := range testTable { t.Run(tt.name, func(t *testing.T) { - + a := New(&tt.log, tt.version) + + viper.SetConfigName("testargs.json") + viper.SetConfigType("json") + viper.AddConfigPath(".") + viper.ReadInConfig() + + installer := Installer{ + RMM: viper.GetString("api"), + ClientID: viper.GetInt("clientid"), + SiteID: viper.GetInt("siteid"), + Description: viper.GetString("description"), + AgentType: viper.GetString("agenttype"), + Power: viper.GetBool("power"), + RDP: viper.GetBool("rdp"), + Ping: viper.GetBool("ping"), + Token: viper.GetString("token"), + LocalMesh: viper.GetString("localmesh"), + Cert: viper.GetString("cert"), + Proxy: viper.GetString("proxy"), + Timeout: viper.GetDuration("timeout"), + Silent: viper.GetBool("silent"), + NoMesh: viper.GetBool("nomesh"), + MeshDir: viper.GetString("meshdir"), + MeshNodeID: viper.GetString("meshnodeid"), + } + + a.Install(&installer) }) } - - var ( - version = "2.0.4" - log = logrus.New() - ) - - a := New(log, version) - - viper.SetConfigName("testargs.json") - viper.SetConfigType("json") - viper.AddConfigPath(".") - viper.ReadInConfig() - - installer := Installer { - RMM: viper.GetString("api"), - ClientID: viper.GetInt("clientid"), - SiteID: viper.GetInt("siteid"), - Description: viper.GetString("description"), - AgentType: viper.GetString("agenttype"), - Power: viper.GetBool("power"), - RDP: viper.GetBool("rdp"), - Ping: viper.GetBool("ping"), - Token: viper.GetString("token"), - LocalMesh: viper.GetString("localmesh"), - Cert: viper.GetString("cert"), - Proxy: viper.GetString("proxy"), - Timeout: viper.GetDuration("timeout"), - Silent: viper.GetBool("silent"), - NoMesh: viper.GetBool("nomesh"), - MeshDir: viper.GetString("meshdir"), - MeshNodeID: viper.GetString("meshnodeid"), - } - - a.Install(&installer) }