jahkeup / testacme

ACME testing-oriented helper for functional & integration testing in Go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

testacme

testacme is a library enabling the use of ephemeral ACME integration & functional testing.

Usage

See test case here for an example ACME library obtaining a certificate using the tls-alpn-01 challenge.

Test authors can either use a shared instance or a test-scoped ACME instance:

func TestACMEFlow(t *testing.T) {
	pebble := testacme.NewPebble(testacme.NewTestingContext(t))

	user := testacme.ManagedUser(testacme.TestNamedEmail(t)).
		MustRegister(pebble)
	lego := testacme.LegoClient(pebble, user)
	cert, err := lego.Certificate.Obtain(certificate.ObtainRequest{
		Domains: []string{"some.fqdn.test."},
	})
	if err != nil {
		t.Fatalf("lego obtain: %v", err)
	}
	t.Logf("cert domain: %q", cert.Domain)

	// test continues to test renewal or something :)
}

Related projects

About

ACME testing-oriented helper for functional & integration testing in Go

License:GNU Lesser General Public License v3.0


Languages

Language:Go 99.5%Language:Makefile 0.5%