-
-
Notifications
You must be signed in to change notification settings - Fork 622
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
232 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,47 @@ | ||
package web | ||
|
||
import ( | ||
"context" | ||
"crypto/tls" | ||
"strings" | ||
"testing" | ||
"time" | ||
|
||
"github.com/getfider/fider/app/models/query" | ||
"github.com/getfider/fider/app/pkg/bus" | ||
"github.com/getfider/fider/app/services/blob/fs" | ||
|
||
. "github.com/getfider/fider/app/pkg/assert" | ||
) | ||
|
||
func Test_UseAutoCert(t *testing.T) { | ||
func mockIsCNAMEAvailable(ctx context.Context, q *query.IsCNAMEAvailable) error { | ||
if q.CNAME == "ideas.app.com" || q.CNAME == "feedback.mysite.com" { | ||
q.Result = false | ||
} else { | ||
q.Result = true | ||
} | ||
return nil | ||
} | ||
|
||
func TestUseAutoCert_WhenCNAMEAreRegistered(t *testing.T) { | ||
RegisterT(t) | ||
bus.Init(fs.Service{}) | ||
bus.AddHandler(mockIsCNAMEAvailable) | ||
|
||
manager, err := NewCertificateManager("", "") | ||
Expect(err).IsNil() | ||
|
||
invalidServerNames := []string{"ideas.app.com", "feedback.mysite.com"} | ||
invalidServerNames := []string{"ideas.app.com", "FEEDBACK.mysite.COM"} | ||
|
||
for _, serverName := range invalidServerNames { | ||
cert, err := manager.GetCertificate(&tls.ClientHelloInfo{ | ||
ServerName: serverName, | ||
}) | ||
Expect(err.Error()).ContainsSubstring(`acme/autocert: unable to satisfy`) | ||
Expect(err.Error()).ContainsSubstring(`for domain "` + serverName + `": no viable challenge type found`) | ||
Expect(err.Error()).ContainsSubstring(`for domain "` + strings.ToLower(serverName) + `": no viable challenge type found`) | ||
Expect(cert).IsNil() | ||
} | ||
|
||
// GetCertificate starts a fire and forget go routine to delete items from cache, give it 2sec to complete it | ||
time.Sleep(2*time.Second) | ||
time.Sleep(2 * time.Second) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,22 @@ | ||
-----BEGIN CERTIFICATE----- | ||
MIICzzCCAbegAwIBAgIJAOfxz5w/17rGMA0GCSqGSIb3DQEBBQUAMBgxFjAUBgNV | ||
BAMTDS5kZXYuZmlkZXIuaW8wHhcNMjEwNjE0MTYyOTMwWhcNMzEwNjEyMTYyOTMw | ||
WjAYMRYwFAYDVQQDEw0uZGV2LmZpZGVyLmlvMIIBIjANBgkqhkiG9w0BAQEFAAOC | ||
AQ8AMIIBCgKCAQEA7ip+VpaIFYGV+7ga9YLctBg8SkPDzItDZPV0JSnMhVvh6rKC | ||
wYlNOY4XLXHzwdsgZY8Fdbm9SFbvlKSecjd+iYU71NiIr79hZVXZRcDbp1ztOLOU | ||
ekx8jqfJnHYJP3kyM34Jl3QkwR07kMCsPTBSSDsxT+i1tSMPpe5qcDta7VRayFrE | ||
o8YO30wDiQqt5/2JmHxeHHC991Z0/ebjul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N1w | ||
quNrlGFT1d6eMFWFufRVMZV6EnOOSCD21u8GM5CobnC/rqM4gNB2KHc5dgdERMP7 | ||
uFw3Y6bPEeBzLv+9+QrMGmWf7//7kLdk6o7shWjkzgRig+bepvcOaafVL8hqaA+z | ||
BqIrxfEQnV30Tnr2jxNAEd3cSt1RgGF3as+VNQb12yBXATzgU4DhAgMBAAGjgZ4w | ||
gZswHQYDVR0OBBYEFI7FJZddSC7hu8COWlb/ZOzptR7IMB8GA1UdIwQYMBaAFI7F | ||
JZddSC7hu8COWlb/ZOzptR7IMA4GA1UdDwEB/wQEAwIFoDAgBgNVHSUBAf8EFjAU | ||
BggrBgEFBQcDAQYIKwYBBQUHAwIwJwYDVR0RBCAwHoIOKi5kZXYuZmlkZXIuaW+C | ||
DGRldi5maWRlci5pbzANBgkqhkiG9w0BAQsFAAOCAQEAYlWqm+rM/h0lCjXGjY0u | ||
HMRm84qequBDUO6pv3eE1qsf1Qc8XeziimDlKf6yrWe0cHmTVXHVOrH1uVo+e9UW | ||
L0t3rSCNH9jrSYwYx/TYqJXlvDMjnkdrzne6UcQR26H39q0oYzk/XfCFRwM1kAfF | ||
riuNU3hbCmrNKyhO3lkRyTVczUnbc0Yb1PtT6bLepZ0CVtYDb5El4N9IGIjLfPGY | ||
C4UG1JdJy33PAyticxFBsK14ios15Gp2po8G0sp6GP+3RM3ChoS38HDlKyqE0Pq9 | ||
v4pw//KbFfCghxFYTupJJRbTYoU8U7Lh0Ou4SGQScuqK5jqBdk5LgmPIDNbv+2fQ | ||
9g== | ||
-----END CERTIFICATE----- |
Oops, something went wrong.