github.com/letsencrypt/boulder@v0.20251208.0/crl/idp/idp_test.go (about)

     1  package idp
     2  
     3  import (
     4  	"encoding/hex"
     5  	"testing"
     6  
     7  	"github.com/letsencrypt/boulder/test"
     8  )
     9  
    10  func TestMakeUserCertsExt(t *testing.T) {
    11  	t.Parallel()
    12  	dehex := func(s string) []byte { r, _ := hex.DecodeString(s); return r }
    13  	tests := []struct {
    14  		name string
    15  		urls []string
    16  		want []byte
    17  	}{
    18  		{
    19  			name: "one (real) url",
    20  			urls: []string{"http://prod.c.lencr.org/20506757847264211/126.crl"},
    21  			want: dehex("303AA035A0338631687474703A2F2F70726F642E632E6C656E63722E6F72672F32303530363735373834373236343231312F3132362E63726C8101FF"),
    22  		},
    23  		{
    24  			name: "two urls",
    25  			urls: []string{"http://old.style/12345678/90.crl", "http://new.style/90.crl"},
    26  			want: dehex("3042A03DA03B8620687474703A2F2F6F6C642E7374796C652F31323334353637382F39302E63726C8617687474703A2F2F6E65772E7374796C652F39302E63726C8101FF"),
    27  		},
    28  	}
    29  	for _, tc := range tests {
    30  		t.Run(tc.name, func(t *testing.T) {
    31  			t.Parallel()
    32  			got, err := MakeUserCertsExt(tc.urls)
    33  			test.AssertNotError(t, err, "should never fail to marshal asn1 to bytes")
    34  			test.AssertDeepEquals(t, got.Id, idpOID)
    35  			test.AssertEquals(t, got.Critical, true)
    36  			test.AssertDeepEquals(t, got.Value, tc.want)
    37  		})
    38  	}
    39  }