4
0

windows_test.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. //go:build !go1.23
  2. package sceptest
  3. import (
  4. "crypto/x509"
  5. "net/http"
  6. "sync"
  7. "testing"
  8. "github.com/stretchr/testify/assert"
  9. "github.com/stretchr/testify/require"
  10. )
  11. func TestIssuesCertificateToEmulatedWindowsClient(t *testing.T) {
  12. c := newTestCA(t, "Step E2E | SCEP Regular w/ Windows Client")
  13. var wg sync.WaitGroup
  14. wg.Add(1)
  15. go func() {
  16. defer wg.Done()
  17. err := c.run()
  18. require.ErrorIs(t, err, http.ErrServerClosed)
  19. }()
  20. // instantiate a client for the CA running at the random address
  21. caClient := newCAClient(t, c.caURL, c.rootFilepath)
  22. requireHealthyCA(t, caClient)
  23. scepClient := createSCEPClient(t, c.caURL, c.root)
  24. cert, err := scepClient.requestCertificateEmulatingWindowsClient(t, "test.localhost", []string{"test.localhost"}, x509.ParseCertificate)
  25. require.NoError(t, err)
  26. require.NotNil(t, cert)
  27. assert.Equal(t, "test.localhost", cert.Subject.CommonName)
  28. assert.Equal(t, "Step E2E | SCEP Regular w/ Windows Client Intermediate CA", cert.Issuer.CommonName)
  29. // done testing; stop and wait for the server to quit
  30. err = c.stop()
  31. require.NoError(t, err)
  32. wg.Wait()
  33. }