4
0

regular_test.go 997 B

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