...

Source file src/github.com/letsencrypt/boulder/sa/satest/satest.go

Documentation: github.com/letsencrypt/boulder/sa/satest

     1  package satest
     2  
     3  import (
     4  	"context"
     5  	"net"
     6  	"testing"
     7  	"time"
     8  
     9  	"github.com/letsencrypt/boulder/core"
    10  	corepb "github.com/letsencrypt/boulder/core/proto"
    11  	sapb "github.com/letsencrypt/boulder/sa/proto"
    12  	"google.golang.org/protobuf/types/known/timestamppb"
    13  )
    14  
    15  // CreateWorkingRegistration inserts a new, correct Registration into
    16  // SA using GoodKey under the hood. This is used by various non-SA tests
    17  // to initialize the a registration for the test to reference.
    18  func CreateWorkingRegistration(t *testing.T, sa sapb.StorageAuthorityClient) *corepb.Registration {
    19  	created := time.Date(2003, 5, 10, 0, 0, 0, 0, time.UTC)
    20  	initialIP, _ := net.ParseIP("88.77.66.11").MarshalText()
    21  	reg, err := sa.NewRegistration(context.Background(), &corepb.Registration{
    22  		Key: []byte(`{
    23      "kty": "RSA",
    24      "n": "n4EPtAOCc9AlkeQHPzHStgAbgs7bTZLwUBZdR8_KuKPEHLd4rHVTeT-O-XV2jRojdNhxJWTDvNd7nqQ0VEiZQHz_AJmSCpMaJMRBSFKrKb2wqVwGU_NsYOYL-QtiWN2lbzcEe6XC0dApr5ydQLrHqkHHig3RBordaZ6Aj-oBHqFEHYpPe7Tpe-OfVfHd1E6cS6M1FZcD1NNLYD5lFHpPI9bTwJlsde3uhGqC0ZCuEHg8lhzwOHrtIQbS0FVbb9k3-tVTU4fg_3L_vniUFAKwuCLqKnS2BYwdq_mzSnbLY7h_qixoR7jig3__kRhuaxwUkRz5iaiQkqgc5gHdrNP5zw",
    25      "e": "AQAB"
    26  }`),
    27  		Contact:     []string{"mailto:foo@example.com"},
    28  		InitialIP:   initialIP,
    29  		CreatedAtNS: created.UnixNano(),
    30  		CreatedAt:   timestamppb.New(created),
    31  		Status:      string(core.StatusValid),
    32  	})
    33  	if err != nil {
    34  		t.Fatalf("Unable to create new registration: %s", err)
    35  	}
    36  	return reg
    37  }
    38  

View as plain text