github.com/zmap/zlint@v1.1.0/lints/lint_dnsname_hyphen_in_sld_test.go (about)

     1  package lints
     2  
     3  /*
     4   * ZLint Copyright 2018 Regents of the University of Michigan
     5   *
     6   * Licensed under the Apache License, Version 2.0 (the "License"); you may not
     7   * use this file except in compliance with the License. You may obtain a copy
     8   * of the License at http://www.apache.org/licenses/LICENSE-2.0
     9   *
    10   * Unless required by applicable law or agreed to in writing, software
    11   * distributed under the License is distributed on an "AS IS" BASIS,
    12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
    13   * implied. See the License for the specific language governing
    14   * permissions and limitations under the License.
    15   */
    16  
    17  import "testing"
    18  
    19  func TestDNSNameHyphenBeginningSLD(t *testing.T) {
    20  	inputPath := "../testlint/testCerts/dnsNameHyphenBeginningSLD.pem"
    21  	expected := Error
    22  	out := Lints["e_dnsname_hyphen_in_sld"].Execute(ReadCertificate(inputPath))
    23  	if out.Status != expected {
    24  		t.Errorf("%s: expected %s, got %s", inputPath, expected, out.Status)
    25  	}
    26  }
    27  
    28  func TestDNSNameHyphenEndingSLD(t *testing.T) {
    29  	inputPath := "../testlint/testCerts/dnsNameHyphenEndingSLD.pem"
    30  	expected := Error
    31  	out := Lints["e_dnsname_hyphen_in_sld"].Execute(ReadCertificate(inputPath))
    32  	if out.Status != expected {
    33  		t.Errorf("%s: expected %s, got %s", inputPath, expected, out.Status)
    34  	}
    35  }
    36  
    37  func TestDNSNameNoHyphenInSLD(t *testing.T) {
    38  	inputPath := "../testlint/testCerts/dnsNameWildcardCorrect.pem"
    39  	expected := Pass
    40  	out := Lints["e_dnsname_hyphen_in_sld"].Execute(ReadCertificate(inputPath))
    41  	if out.Status != expected {
    42  		t.Errorf("%s: expected %s, got %s", inputPath, expected, out.Status)
    43  	}
    44  }
    45  
    46  func TestDNSNamePrivatePublicSuffixNoHyphenInSLD(t *testing.T) {
    47  	inputPath := "../testlint/testCerts/dnsNamePrivatePublicSuffix.pem"
    48  	expected := Pass
    49  	out := Lints["e_dnsname_hyphen_in_sld"].Execute(ReadCertificate(inputPath))
    50  	if out.Status != expected {
    51  		t.Errorf("%s: expected %s, got %s", inputPath, expected, out.Status)
    52  	}
    53  }