mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-10 12:46:46 +00:00
test: empty auth update channel in tests
This commit is contained in:
committed by
Michal Horejsek
parent
8f15041d8f
commit
7d30459417
12
pkg/pmapi/clientmanager_test.go
Normal file
12
pkg/pmapi/clientmanager_test.go
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
package pmapi
|
||||||
|
|
||||||
|
func newTestClientManager(cfg *ClientConfig) *ClientManager {
|
||||||
|
cm := NewClientManager(cfg)
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
for range cm.authUpdates {
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
return cm
|
||||||
|
}
|
||||||
@ -654,7 +654,7 @@ var testCardsCleartext = []Card{
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestClient_Encrypt(t *testing.T) {
|
func TestClient_Encrypt(t *testing.T) {
|
||||||
c := newTestClient(NewClientManager(testClientConfig))
|
c := newTestClient(newTestClientManager(testClientConfig))
|
||||||
c.kr = testPrivateKeyRing
|
c.kr = testPrivateKeyRing
|
||||||
|
|
||||||
cardEncrypted, err := c.EncryptAndSignCards(testCardsCleartext)
|
cardEncrypted, err := c.EncryptAndSignCards(testCardsCleartext)
|
||||||
@ -668,7 +668,7 @@ func TestClient_Encrypt(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestClient_Decrypt(t *testing.T) {
|
func TestClient_Decrypt(t *testing.T) {
|
||||||
c := newTestClient(NewClientManager(testClientConfig))
|
c := newTestClient(newTestClientManager(testClientConfig))
|
||||||
c.kr = testPrivateKeyRing
|
c.kr = testPrivateKeyRing
|
||||||
|
|
||||||
cardCleartext, err := c.DecryptAndVerifyCards(testCardsEncrypted)
|
cardCleartext, err := c.DecryptAndVerifyCards(testCardsEncrypted)
|
||||||
|
|||||||
@ -39,7 +39,7 @@ func setTestDialerWithPinning(cm *ClientManager) (*int, *DialerWithPinning) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestTLSPinValid(t *testing.T) {
|
func TestTLSPinValid(t *testing.T) {
|
||||||
cm := NewClientManager(testLiveConfig)
|
cm := newTestClientManager(testLiveConfig)
|
||||||
cm.host = liveAPI
|
cm.host = liveAPI
|
||||||
rootScheme = "https"
|
rootScheme = "https"
|
||||||
called, _ := setTestDialerWithPinning(cm)
|
called, _ := setTestDialerWithPinning(cm)
|
||||||
@ -52,7 +52,7 @@ func TestTLSPinValid(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestTLSPinBackup(t *testing.T) {
|
func TestTLSPinBackup(t *testing.T) {
|
||||||
cm := NewClientManager(testLiveConfig)
|
cm := newTestClientManager(testLiveConfig)
|
||||||
cm.host = liveAPI
|
cm.host = liveAPI
|
||||||
called, p := setTestDialerWithPinning(cm)
|
called, p := setTestDialerWithPinning(cm)
|
||||||
p.report.KnownPins[1] = p.report.KnownPins[0]
|
p.report.KnownPins[1] = p.report.KnownPins[0]
|
||||||
@ -67,7 +67,7 @@ func TestTLSPinBackup(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func _TestTLSPinNoMatch(t *testing.T) { // nolint[unused]
|
func _TestTLSPinNoMatch(t *testing.T) { // nolint[unused]
|
||||||
cm := NewClientManager(testLiveConfig)
|
cm := newTestClientManager(testLiveConfig)
|
||||||
cm.host = liveAPI
|
cm.host = liveAPI
|
||||||
|
|
||||||
called, p := setTestDialerWithPinning(cm)
|
called, p := setTestDialerWithPinning(cm)
|
||||||
@ -89,7 +89,7 @@ func _TestTLSPinNoMatch(t *testing.T) { // nolint[unused]
|
|||||||
}
|
}
|
||||||
|
|
||||||
func _TestTLSPinInvalid(t *testing.T) { // nolint[unused]
|
func _TestTLSPinInvalid(t *testing.T) { // nolint[unused]
|
||||||
cm := NewClientManager(testLiveConfig)
|
cm := newTestClientManager(testLiveConfig)
|
||||||
|
|
||||||
ts := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
ts := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
writeJSONResponsefromFile(t, w, "/auth/info/post_response.json", 0)
|
writeJSONResponsefromFile(t, w, "/auth/info/post_response.json", 0)
|
||||||
@ -112,14 +112,14 @@ func _TestTLSPinInvalid(t *testing.T) { // nolint[unused]
|
|||||||
}
|
}
|
||||||
|
|
||||||
func _TestTLSSignedCertWrongPublicKey(t *testing.T) { // nolint[unused]
|
func _TestTLSSignedCertWrongPublicKey(t *testing.T) { // nolint[unused]
|
||||||
cm := NewClientManager(testLiveConfig)
|
cm := newTestClientManager(testLiveConfig)
|
||||||
_, dialer := setTestDialerWithPinning(cm)
|
_, dialer := setTestDialerWithPinning(cm)
|
||||||
_, err := dialer.dialAndCheckFingerprints("tcp", "rsa4096.badssl.com:443")
|
_, err := dialer.dialAndCheckFingerprints("tcp", "rsa4096.badssl.com:443")
|
||||||
Assert(t, err != nil, "expected dial to fail because of wrong public key: ", err.Error())
|
Assert(t, err != nil, "expected dial to fail because of wrong public key: ", err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
func _TestTLSSignedCertTrustedPublicKey(t *testing.T) { // nolint[unused]
|
func _TestTLSSignedCertTrustedPublicKey(t *testing.T) { // nolint[unused]
|
||||||
cm := NewClientManager(testLiveConfig)
|
cm := newTestClientManager(testLiveConfig)
|
||||||
_, dialer := setTestDialerWithPinning(cm)
|
_, dialer := setTestDialerWithPinning(cm)
|
||||||
dialer.report.KnownPins = append(dialer.report.KnownPins, `pin-sha256="W8/42Z0ffufwnHIOSndT+eVzBJSC0E8uTIC8O6mEliQ="`)
|
dialer.report.KnownPins = append(dialer.report.KnownPins, `pin-sha256="W8/42Z0ffufwnHIOSndT+eVzBJSC0E8uTIC8O6mEliQ="`)
|
||||||
_, err := dialer.dialAndCheckFingerprints("tcp", "rsa4096.badssl.com:443")
|
_, err := dialer.dialAndCheckFingerprints("tcp", "rsa4096.badssl.com:443")
|
||||||
@ -127,7 +127,7 @@ func _TestTLSSignedCertTrustedPublicKey(t *testing.T) { // nolint[unused]
|
|||||||
}
|
}
|
||||||
|
|
||||||
func _TestTLSSelfSignedCertTrustedPublicKey(t *testing.T) { // nolint[unused]
|
func _TestTLSSelfSignedCertTrustedPublicKey(t *testing.T) { // nolint[unused]
|
||||||
cm := NewClientManager(testLiveConfig)
|
cm := newTestClientManager(testLiveConfig)
|
||||||
_, dialer := setTestDialerWithPinning(cm)
|
_, dialer := setTestDialerWithPinning(cm)
|
||||||
dialer.report.KnownPins = append(dialer.report.KnownPins, `pin-sha256="9SLklscvzMYj8f+52lp5ze/hY0CFHyLSPQzSpYYIBm8="`)
|
dialer.report.KnownPins = append(dialer.report.KnownPins, `pin-sha256="9SLklscvzMYj8f+52lp5ze/hY0CFHyLSPQzSpYYIBm8="`)
|
||||||
_, err := dialer.dialAndCheckFingerprints("tcp", "self-signed.badssl.com:443")
|
_, err := dialer.dialAndCheckFingerprints("tcp", "self-signed.badssl.com:443")
|
||||||
|
|||||||
@ -122,7 +122,7 @@ func TestProxyProvider_UseProxy(t *testing.T) {
|
|||||||
blockAPI()
|
blockAPI()
|
||||||
defer unblockAPI()
|
defer unblockAPI()
|
||||||
|
|
||||||
cm := NewClientManager(testClientConfig)
|
cm := newTestClientManager(testClientConfig)
|
||||||
|
|
||||||
proxy := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}))
|
proxy := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}))
|
||||||
defer proxy.Close()
|
defer proxy.Close()
|
||||||
@ -141,7 +141,7 @@ func TestProxyProvider_UseProxy_MultipleTimes(t *testing.T) {
|
|||||||
blockAPI()
|
blockAPI()
|
||||||
defer unblockAPI()
|
defer unblockAPI()
|
||||||
|
|
||||||
cm := NewClientManager(testClientConfig)
|
cm := newTestClientManager(testClientConfig)
|
||||||
|
|
||||||
proxy1 := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}))
|
proxy1 := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}))
|
||||||
defer proxy1.Close()
|
defer proxy1.Close()
|
||||||
@ -182,7 +182,7 @@ func TestProxyProvider_UseProxy_RevertAfterTime(t *testing.T) {
|
|||||||
blockAPI()
|
blockAPI()
|
||||||
defer unblockAPI()
|
defer unblockAPI()
|
||||||
|
|
||||||
cm := NewClientManager(testClientConfig)
|
cm := newTestClientManager(testClientConfig)
|
||||||
|
|
||||||
proxy := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}))
|
proxy := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}))
|
||||||
defer proxy.Close()
|
defer proxy.Close()
|
||||||
@ -205,7 +205,7 @@ func TestProxyProvider_UseProxy_RevertIfProxyStopsWorkingAndOriginalAPIIsReachab
|
|||||||
blockAPI()
|
blockAPI()
|
||||||
defer unblockAPI()
|
defer unblockAPI()
|
||||||
|
|
||||||
cm := NewClientManager(testClientConfig)
|
cm := newTestClientManager(testClientConfig)
|
||||||
|
|
||||||
proxy := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}))
|
proxy := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}))
|
||||||
defer proxy.Close()
|
defer proxy.Close()
|
||||||
@ -235,7 +235,7 @@ func TestProxyProvider_UseProxy_FindSecondAlternativeIfFirstFailsAndAPIIsStillBl
|
|||||||
blockAPI()
|
blockAPI()
|
||||||
defer unblockAPI()
|
defer unblockAPI()
|
||||||
|
|
||||||
cm := NewClientManager(testClientConfig)
|
cm := newTestClientManager(testClientConfig)
|
||||||
|
|
||||||
proxy1 := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}))
|
proxy1 := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}))
|
||||||
defer proxy1.Close()
|
defer proxy1.Close()
|
||||||
|
|||||||
@ -79,7 +79,7 @@ func newTestServer(h http.Handler) (*httptest.Server, *client) {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
cm := NewClientManager(testClientConfig)
|
cm := newTestClientManager(testClientConfig)
|
||||||
cm.host = serverURL.Host
|
cm.host = serverURL.Host
|
||||||
cm.scheme = serverURL.Scheme
|
cm.scheme = serverURL.Scheme
|
||||||
|
|
||||||
@ -122,7 +122,7 @@ func newTestServerCallbacks(tb testing.TB, callbacks ...func(testing.TB, http.Re
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cm := NewClientManager(testClientConfig)
|
cm := newTestClientManager(testClientConfig)
|
||||||
cm.host = serverURL.Host
|
cm.host = serverURL.Host
|
||||||
cm.scheme = serverURL.Scheme
|
cm.scheme = serverURL.Scheme
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user