(t *testing.T, address, target, expectedAuthority string, dialer func(context.Context, string) (net.Conn, error))
| 62 | } |
| 63 | |
| 64 | func runUnixTest(t *testing.T, address, target, expectedAuthority string, dialer func(context.Context, string) (net.Conn, error)) { |
| 65 | if !strings.HasPrefix(target, "unix-abstract:") { |
| 66 | if err := os.RemoveAll(address); err != nil { |
| 67 | t.Fatalf("Error removing socket file %v: %v\n", address, err) |
| 68 | } |
| 69 | } |
| 70 | ss := &stubserver.StubServer{ |
| 71 | EmptyCallF: func(ctx context.Context, _ *testpb.Empty) (*testpb.Empty, error) { |
| 72 | return authorityChecker(ctx, expectedAuthority) |
| 73 | }, |
| 74 | Network: "unix", |
| 75 | Address: address, |
| 76 | Target: target, |
| 77 | } |
| 78 | opts := []grpc.DialOption{} |
| 79 | if dialer != nil { |
| 80 | opts = append(opts, grpc.WithContextDialer(dialer)) |
| 81 | } |
| 82 | if err := ss.Start(nil, opts...); err != nil { |
| 83 | t.Fatalf("Error starting endpoint server: %v", err) |
| 84 | } |
| 85 | defer ss.Stop() |
| 86 | ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout) |
| 87 | defer cancel() |
| 88 | _, err := ss.Client.EmptyCall(ctx, &testpb.Empty{}) |
| 89 | if err != nil { |
| 90 | t.Errorf("us.client.EmptyCall(_, _) = _, %v; want _, nil", err) |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | type authorityTest struct { |
| 95 | name string |
no test coverage detected