46 lines
1.4 KiB
Go
46 lines
1.4 KiB
Go
package rpc
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
|
|
agentpb "git.ipao.vip/rogee/go-sip/gen/agent"
|
|
)
|
|
|
|
func TestAgentControlServiceOnlyExposesApprovedMethods(t *testing.T) {
|
|
var got []string
|
|
for _, method := range agentpb.AgentControlService_ServiceDesc.Methods {
|
|
got = append(got, method.MethodName)
|
|
}
|
|
want := []string{
|
|
"GetAgentStatus", "ActivateAgent",
|
|
"ExecuteApproved", "ApplyApprovedTaskControl", "GetLoadedSIP",
|
|
"RequestRecordingUpload", "ReportCallEnded", "ReportCallResult",
|
|
}
|
|
if !reflect.DeepEqual(got, want) {
|
|
t.Fatalf("Agent gRPC method surface = %v, want %v", got, want)
|
|
}
|
|
}
|
|
|
|
func TestAgentServerUsesLoadedSIPInsteadOfRetiredStaticArtifact(t *testing.T) {
|
|
options := reflect.TypeOf(ServerOptions{})
|
|
for _, name := range []string{"StaticArtifactRaw", "StaticArtifactExpected"} {
|
|
if _, exists := options.FieldByName(name); exists {
|
|
t.Fatalf("retired static artifact input %s remains on the Agent server", name)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestAgentServerHasNoRetiredBusinessMethods(t *testing.T) {
|
|
server := reflect.TypeOf(&Server{})
|
|
for _, name := range []string{
|
|
"GetBootstrap", "SetAdmissionState", "Execute", "ExecuteAuthorized",
|
|
"GetExecutionPermit", "ApplyTaskControl", "QueryExecution",
|
|
"ReportExecutionEvent", "RequestUpload", "CompleteUpload",
|
|
} {
|
|
if _, exists := server.MethodByName(name); exists {
|
|
t.Fatalf("retired Agent RPC method %s is still implemented", name)
|
|
}
|
|
}
|
|
}
|