feat: Add the option to generate a trial license during setup (#5110)

This allows users to generate a 30 day free license during setup to
test out Enterprise features.
This commit is contained in:
Kyle Carberry
2022-11-16 17:09:49 -06:00
committed by GitHub
parent b6703b11c6
commit fb9ca7b830
29 changed files with 332 additions and 79 deletions

View File

@ -49,10 +49,9 @@ func TestFirstUser(t *testing.T) {
defer cancel()
_, err := client.CreateFirstUser(ctx, codersdk.CreateFirstUserRequest{
Email: "some@email.com",
Username: "exampleuser",
Password: "password",
OrganizationName: "someorg",
Email: "some@email.com",
Username: "exampleuser",
Password: "password",
})
var apiErr *codersdk.Error
require.ErrorAs(t, err, &apiErr)
@ -65,6 +64,30 @@ func TestFirstUser(t *testing.T) {
_ = coderdtest.CreateFirstUser(t, client)
})
t.Run("Trial", func(t *testing.T) {
t.Parallel()
called := make(chan struct{})
client := coderdtest.New(t, &coderdtest.Options{
TrialGenerator: func(ctx context.Context, s string) error {
close(called)
return nil
},
})
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
defer cancel()
req := codersdk.CreateFirstUserRequest{
Email: "testuser@coder.com",
Username: "testuser",
Password: "testpass",
Trial: true,
}
_, err := client.CreateFirstUser(ctx, req)
require.NoError(t, err)
<-called
})
t.Run("LastSeenAt", func(t *testing.T) {
t.Parallel()
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
@ -192,10 +215,9 @@ func TestPostLogin(t *testing.T) {
defer cancel()
req := codersdk.CreateFirstUserRequest{
Email: "testuser@coder.com",
Username: "testuser",
Password: "testpass",
OrganizationName: "testorg",
Email: "testuser@coder.com",
Username: "testuser",
Password: "testpass",
}
_, err := client.CreateFirstUser(ctx, req)
require.NoError(t, err)
@ -249,10 +271,9 @@ func TestPostLogin(t *testing.T) {
defer cancel()
req := codersdk.CreateFirstUserRequest{
Email: "testuser@coder.com",
Username: "testuser",
Password: "testpass",
OrganizationName: "testorg",
Email: "testuser@coder.com",
Username: "testuser",
Password: "testpass",
}
_, err := client.CreateFirstUser(ctx, req)
require.NoError(t, err)