Skip to content

Commit

Permalink
remove redundant code
Browse files Browse the repository at this point in the history
Signed-off-by: WashingtonKK <[email protected]>
  • Loading branch information
WashingtonKK committed Dec 4, 2024
1 parent 28c7511 commit 70a8ac5
Showing 1 changed file with 0 additions and 70 deletions.
70 changes: 0 additions & 70 deletions internal/server/grpc/grpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,76 +171,6 @@ func TestServerStartWithMTLS(t *testing.T) {
assert.Contains(t, logContent, "TestServer service gRPC server listening at localhost:0 with TLS")
}

func TestServerStartWithmTLSFile(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())

cert, key, err := generateSelfSignedCert()
assert.NoError(t, err)

certFile, err := os.CreateTemp("", "cert*.pem")
assert.NoError(t, err)

keyFile, err := os.CreateTemp("", "key*.pem")
assert.NoError(t, err)

t.Cleanup(func() {
os.Remove(certFile.Name())
os.Remove(keyFile.Name())
})

_, err = certFile.Write(cert)
assert.NoError(t, err)

_, err = keyFile.Write(key)
assert.NoError(t, err)

err = certFile.Close()
assert.NoError(t, err)
err = keyFile.Close()
assert.NoError(t, err)

config := server.AgentConfig{
ServerConfig: server.ServerConfig{
BaseConfig: server.BaseConfig{
Host: "localhost",
Port: "0",
CertFile: certFile.Name(),
KeyFile: keyFile.Name(),
ServerCAFile: certFile.Name(),
ClientCAFile: certFile.Name(),
},
},
}

logBuffer := &ThreadSafeBuffer{}
logger := slog.New(slog.NewTextHandler(logBuffer, &slog.HandlerOptions{Level: slog.LevelDebug}))
qp := new(mocks.QuoteProvider)
authSvc := new(authmocks.Authenticator)

srv := New(ctx, cancel, "TestServer", config, func(srv *grpc.Server) {}, logger, qp, authSvc)

var wg sync.WaitGroup
wg.Add(1)

go func() {
wg.Done()
err := srv.Start()
assert.NoError(t, err)
}()

wg.Wait()

time.Sleep(200 * time.Millisecond)

cancel()

time.Sleep(200 * time.Millisecond)

logContent := logBuffer.String()
fmt.Println(logContent)
assert.Contains(t, logContent, "TestServer service gRPC server listening at localhost:0 with TLS")
}

func TestServerStop(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())

Expand Down

0 comments on commit 70a8ac5

Please sign in to comment.