37 lines
935 B
Go
37 lines
935 B
Go
package rpc
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
agentpb "git.ipao.vip/rogee/go-sip/gen/agent"
|
|
|
|
"google.golang.org/grpc/codes"
|
|
"google.golang.org/grpc/status"
|
|
)
|
|
|
|
func TestRecordingServerRequiresConfiguredAuthority(t *testing.T) {
|
|
server := &RecordingServer{}
|
|
for _, call := range []struct {
|
|
name string
|
|
call func() error
|
|
}{
|
|
{"grant", func() error {
|
|
_, err := server.RequestRecordingUpload(context.Background(), &agentpb.RequestRecordingUploadRequest{})
|
|
return err
|
|
}},
|
|
{"end", func() error {
|
|
_, err := server.ReportCallEnded(context.Background(), &agentpb.ReportCallEndedRequest{})
|
|
return err
|
|
}},
|
|
{"result", func() error {
|
|
_, err := server.ReportCallResult(context.Background(), &agentpb.ReportCallResultRequest{})
|
|
return err
|
|
}},
|
|
} {
|
|
if err := call.call(); status.Code(err) != codes.FailedPrecondition {
|
|
t.Fatalf("%s without original D authority was not rejected: %v", call.name, err)
|
|
}
|
|
}
|
|
}
|