// TestPKIXName validates building a pkix.Name structure from a
// CertificateRequest.
TestPKIXName validates building a pkix.Name structure from a
CertificateRequest.
// TestPKIXName validates building a pkix . Name structure from a // CertificateRequest .
func TestPKIXName(t *testing.T) {
	var cr = &CertificateRequest{
		CN: "Test Common Name",
		Names: []Name{
			{
				C:  "US",
				ST: "California",
				L:  "San Francisco",
				O:  "CloudFlare, Inc.",
				OU: "Systems Engineering",
			},
			{
				C:  "GB",
				ST: "London",
				L:  "London",
				O:  "CloudFlare, Inc",
				OU: "Systems Engineering",
			},
		},
		Hosts:      []string{"cloudflare.com", "www.cloudflare.com"},
		KeyRequest: NewKeyRequest(),
	}
	name, err := cr.Name()
	if err != nil {
		t.Fatalf("Error getting name: %s", err.Error())
	}
	if len(name.Country) != 2 {
		t.Fatal("Expected two countries in SubjInfo.")
	} else if len(name.Province) != 2 {
		t.Fatal("Expected two states in SubjInfo.")
	} else if len(name.Locality) != 2 {
		t.Fatal("Expected two localities in SubjInfo.")
	} else if len(name.Country) != 2 {
		t.Fatal("Expected two countries in SubjInfo.")
	} else if len(name.Organization) != 2 {
		t.Fatal("Expected two organization in SubjInfo.")
	} else if len(name.OrganizationalUnit) != 2 {
		t.Fatal("Expected two organizational units in SubjInfo.")
	}
}
func TestPKIXName ( t * testing . T ) { var cr = & CertificateRequest { CN : " " , Names : [ ] Name { { C : " " , ST : " " , L : " " , O : " " , OU : " " , } , { C : " " , ST : " " , L : " " , O : " " , OU : " " , } , } , Hosts : [ ] string { " " , " " } , KeyRequest : NewKeyRequest ( ) , } name , err := cr . Name ( ) if err != nil { t . Fatalf ( " " , err . Error ( ) ) } if len ( name . Country ) != 2 { t . Fatal ( " " ) } else if len ( name . Province ) != 2 { t . Fatal ( " " ) } else if len ( name . Locality ) != 2 { t . Fatal ( " " ) } else if len ( name . Country ) != 2 { t . Fatal ( " " ) } else if len ( name . Organization ) != 2 { t . Fatal ( " " ) } else if len ( name . OrganizationalUnit ) != 2 { t . Fatal ( " " ) } }
TestPKIXName validates building a pkix.Name structure from a
CertificateRequest.
TestPKIXName validates building a pkix . Name structure from a CertificateRequest .