Skip to content

jahkeup/testacme

Repository files navigation

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

Topics

Resources

License

LGPL-3.0, GPL-3.0 licenses found

Licenses found

LGPL-3.0
COPYING.LESSER
GPL-3.0
COPYING

Stars

Watchers

Forks