@@ -30,7 +30,7 @@ func paImpl(t *testing.T) *AuthorityImpl {
30
30
return pa
31
31
}
32
32
33
- func TestWellFormedDomainNames (t * testing.T ) {
33
+ func TestWellFormedIdentifiers (t * testing.T ) {
34
34
testCases := []struct {
35
35
domain string
36
36
err error
@@ -110,7 +110,7 @@ func TestWellFormedDomainNames(t *testing.T) {
110
110
111
111
// Test syntax errors
112
112
for _ , tc := range testCases {
113
- err := WellFormedDomainNames ([]string { tc .domain })
113
+ err := WellFormedIdentifiers ([]identifier. ACMEIdentifier { identifier . NewDNS ( tc .domain ) })
114
114
if tc .err == nil {
115
115
test .AssertNil (t , err , fmt .Sprintf ("Unexpected error for domain %q, got %s" , tc .domain , err ))
116
116
} else {
@@ -120,6 +120,12 @@ func TestWellFormedDomainNames(t *testing.T) {
120
120
test .AssertContains (t , berr .Error (), tc .err .Error ())
121
121
}
122
122
}
123
+
124
+ err := WellFormedIdentifiers ([]identifier.ACMEIdentifier {identifier .NewIP (netip .MustParseAddr ("9.9.9.9" ))})
125
+ test .AssertError (t , err , "Expected error for IP, but got none" )
126
+ var berr * berrors.BoulderError
127
+ test .AssertErrorWraps (t , err , & berr )
128
+ test .AssertContains (t , berr .Error (), errUnsupportedIdent .Error ())
123
129
}
124
130
125
131
func TestWillingToIssue (t * testing.T ) {
@@ -177,19 +183,22 @@ func TestWillingToIssue(t *testing.T) {
177
183
test .AssertNotError (t , err , "Couldn't load rules" )
178
184
179
185
// Invalid encoding
180
- err = pa .WillingToIssue ([]string { "www.xn--m.com" })
186
+ err = pa .WillingToIssue ([]identifier. ACMEIdentifier { identifier . NewDNS ( "www.xn--m.com" ) })
181
187
test .AssertError (t , err , "WillingToIssue didn't fail on a malformed IDN" )
188
+ // Invalid identifier type
189
+ err = pa .WillingToIssue ([]identifier.ACMEIdentifier {identifier .NewIP (netip .MustParseAddr ("1.1.1.1" ))})
190
+ test .AssertError (t , err , "WillingToIssue didn't fail on an IP address" )
182
191
// Valid encoding
183
- err = pa .WillingToIssue ([]string { "www.xn--mnich-kva.com" })
192
+ err = pa .WillingToIssue ([]identifier. ACMEIdentifier { identifier . NewDNS ( "www.xn--mnich-kva.com" ) })
184
193
test .AssertNotError (t , err , "WillingToIssue failed on a properly formed IDN" )
185
194
// IDN TLD
186
- err = pa .WillingToIssue ([]string { "xn--example--3bhk5a.xn--p1ai" })
195
+ err = pa .WillingToIssue ([]identifier. ACMEIdentifier { identifier . NewDNS ( "xn--example--3bhk5a.xn--p1ai" ) })
187
196
test .AssertNotError (t , err , "WillingToIssue failed on a properly formed domain with IDN TLD" )
188
197
features .Reset ()
189
198
190
199
// Test expected blocked domains
191
200
for _ , domain := range shouldBeBlocked {
192
- err := pa .WillingToIssue ([]string { domain })
201
+ err := pa .WillingToIssue ([]identifier. ACMEIdentifier { identifier . NewDNS ( domain ) })
193
202
test .AssertError (t , err , "domain was not correctly forbidden" )
194
203
var berr * berrors.BoulderError
195
204
test .AssertErrorWraps (t , err , & berr )
@@ -198,7 +207,7 @@ func TestWillingToIssue(t *testing.T) {
198
207
199
208
// Test acceptance of good names
200
209
for _ , domain := range shouldBeAccepted {
201
- err := pa .WillingToIssue ([]string { domain })
210
+ err := pa .WillingToIssue ([]identifier. ACMEIdentifier { identifier . NewDNS ( domain ) })
202
211
test .AssertNotError (t , err , "domain was incorrectly forbidden" )
203
212
}
204
213
}
@@ -284,7 +293,7 @@ func TestWillingToIssue_Wildcards(t *testing.T) {
284
293
285
294
for _ , tc := range testCases {
286
295
t .Run (tc .Name , func (t * testing.T ) {
287
- err := pa .WillingToIssue ([]string { tc .Domain })
296
+ err := pa .WillingToIssue ([]identifier. ACMEIdentifier { identifier . NewDNS ( tc .Domain ) })
288
297
if tc .ExpectedErr == nil {
289
298
test .AssertNil (t , err , fmt .Sprintf ("Unexpected error for domain %q, got %s" , tc .Domain , err ))
290
299
} else {
@@ -319,12 +328,12 @@ func TestWillingToIssue_SubErrors(t *testing.T) {
319
328
test .AssertNotError (t , err , "Couldn't load policy contents from file" )
320
329
321
330
// Test multiple malformed domains and one banned domain; only the malformed ones will generate errors
322
- err = pa .WillingToIssue ([]string {
323
- "perfectly-fine.com" , // fine
324
- "letsdecrypt_org" , // malformed
325
- "example.comm" , // malformed
326
- "letsdecrypt.org" , // banned
327
- "also-perfectly-fine.com" , // fine
331
+ err = pa .WillingToIssue ([]identifier. ACMEIdentifier {
332
+ identifier . NewDNS ( "perfectly-fine.com" ) , // fine
333
+ identifier . NewDNS ( "letsdecrypt_org" ) , // malformed
334
+ identifier . NewDNS ( "example.comm" ) , // malformed
335
+ identifier . NewDNS ( "letsdecrypt.org" ) , // banned
336
+ identifier . NewDNS ( "also-perfectly-fine.com" ) , // fine
328
337
})
329
338
test .AssertDeepEquals (t , err ,
330
339
& berrors.BoulderError {
@@ -349,11 +358,11 @@ func TestWillingToIssue_SubErrors(t *testing.T) {
349
358
})
350
359
351
360
// Test multiple banned domains.
352
- err = pa .WillingToIssue ([]string {
353
- "perfectly-fine.com" , // fine
354
- "letsdecrypt.org" , // banned
355
- "example.com" , // banned
356
- "also-perfectly-fine.com" , // fine
361
+ err = pa .WillingToIssue ([]identifier. ACMEIdentifier {
362
+ identifier . NewDNS ( "perfectly-fine.com" ) , // fine
363
+ identifier . NewDNS ( "letsdecrypt.org" ) , // banned
364
+ identifier . NewDNS ( "example.com" ) , // banned
365
+ identifier . NewDNS ( "also-perfectly-fine.com" ) , // fine
357
366
})
358
367
test .AssertError (t , err , "Expected err from WillingToIssueWildcards" )
359
368
@@ -380,7 +389,7 @@ func TestWillingToIssue_SubErrors(t *testing.T) {
380
389
})
381
390
382
391
// Test willing to issue with only *one* bad identifier.
383
- err = pa .WillingToIssue ([]string { "letsdecrypt.org" })
392
+ err = pa .WillingToIssue ([]identifier. ACMEIdentifier { identifier . NewDNS ( "letsdecrypt.org" ) })
384
393
test .AssertDeepEquals (t , err ,
385
394
& berrors.BoulderError {
386
395
Type : berrors .RejectedIdentifier ,
0 commit comments