Docker template generator
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

lego_test.go 1.2KB

123456789101112131415161718192021222324252627282930
  1. package main
  2. import "testing"
  3. func Test_domainsMatch(t *testing.T) {
  4. type args struct {
  5. domains1 []string
  6. domains2 []string
  7. }
  8. tests := []struct {
  9. name string
  10. args args
  11. want bool
  12. }{
  13. {"separate single domains", args{[]string{"example.com"}, []string{"example.org"}}, false},
  14. {"matching single domains", args{[]string{"example.com"}, []string{"example.com"}}, true},
  15. {"matching subject missing sans", args{[]string{"example.com", "example.org"}, []string{"example.com"}}, false},
  16. {"matching subject extra sans", args{[]string{"example.com"}, []string{"example.com", "example.org"}}, false},
  17. {"matching subject different sans", args{[]string{"example.com", "example.org"}, []string{"example.com", "example.net"}}, false},
  18. {"mismatched subject and san", args{[]string{"example.org", "example.com"}, []string{"example.com", "example.org"}}, false},
  19. {"reordered sans", args{[]string{"example.org", "example.com", "example.net"}, []string{"example.org", "example.net", "example.com"}}, true},
  20. }
  21. for _, tt := range tests {
  22. t.Run(tt.name, func(t *testing.T) {
  23. if got := domainsMatch(tt.args.domains1, tt.args.domains2); got != tt.want {
  24. t.Errorf("domainsMatch() = %v, want %v", got, tt.want)
  25. }
  26. })
  27. }
  28. }