@@ -18,6 +18,8 @@ import (
1818)
1919
2020func TestDecryptUserEmailWithThresholdSkipsBadShare (t * testing.T ) {
21+ allowAnyEmailDomain (t )
22+
2123 const email = "test@example.com"
2224
2325 shares , err := shamir .Encrypt (email , 5 , 4 )
@@ -45,6 +47,8 @@ func TestDecryptUserEmailWithThresholdSkipsBadShare(t *testing.T) {
4547}
4648
4749func TestDecryptUserEmailWithThreeOfFive (t * testing.T ) {
50+ allowAnyEmailDomain (t )
51+
4852 const email = "test@example.com"
4953
5054 shares , err := shamir .Encrypt (email , 5 , 3 )
@@ -87,15 +91,18 @@ func TestUpdateShamirPersistsFiveKeyLocalSQLite(t *testing.T) {
8791 oldDB := models .DB
8892 oldPublicKeys := models .ShamirPublicKeys
8993 oldShamirFeature := config .Config .ShamirFeature
94+ oldEmailWhitelist := config .Config .EmailWhitelist
9095 t .Cleanup (func () {
9196 models .DB = oldDB
9297 models .ShamirPublicKeys = oldPublicKeys
9398 config .Config .ShamirFeature = oldShamirFeature
99+ config .Config .EmailWhitelist = oldEmailWhitelist
94100 InitShamirStatus ()
95101 })
96102
97103 models .DB = db
98104 config .Config .ShamirFeature = true
105+ config .Config .EmailWhitelist = nil
99106
100107 publicKeys , privateKeyRings := generateTestKeySet (t , 7 )
101108 models .ShamirPublicKeys = publicKeys
@@ -217,15 +224,18 @@ func TestUpdateShamirInvalidShareDoesNotPanic(t *testing.T) {
217224 oldDB := models .DB
218225 oldPublicKeys := models .ShamirPublicKeys
219226 oldShamirFeature := config .Config .ShamirFeature
227+ oldEmailWhitelist := config .Config .EmailWhitelist
220228 t .Cleanup (func () {
221229 models .DB = oldDB
222230 models .ShamirPublicKeys = oldPublicKeys
223231 config .Config .ShamirFeature = oldShamirFeature
232+ config .Config .EmailWhitelist = oldEmailWhitelist
224233 InitShamirStatus ()
225234 })
226235
227236 models .DB = db
228237 config .Config .ShamirFeature = true
238+ config .Config .EmailWhitelist = nil
229239
230240 publicKeys , _ := generateTestKeySet (t , 5 )
231241 models .ShamirPublicKeys = publicKeys
@@ -297,15 +307,18 @@ func TestUpdateShamirPartialUpdateAllowedAtNinetyNinePercent(t *testing.T) {
297307 oldDB := models .DB
298308 oldPublicKeys := models .ShamirPublicKeys
299309 oldShamirFeature := config .Config .ShamirFeature
310+ oldEmailWhitelist := config .Config .EmailWhitelist
300311 t .Cleanup (func () {
301312 models .DB = oldDB
302313 models .ShamirPublicKeys = oldPublicKeys
303314 config .Config .ShamirFeature = oldShamirFeature
315+ config .Config .EmailWhitelist = oldEmailWhitelist
304316 InitShamirStatus ()
305317 })
306318
307319 models .DB = db
308320 config .Config .ShamirFeature = true
321+ config .Config .EmailWhitelist = nil
309322
310323 publicKeys , _ := generateTestKeySet (t , 5 )
311324 models .ShamirPublicKeys = publicKeys
@@ -430,6 +443,16 @@ func generateTestKeySet(t *testing.T, n int) ([]models.ShamirPublicKey, []*crypt
430443 return publicKeys , privateKeyRings
431444}
432445
446+ func allowAnyEmailDomain (t * testing.T ) {
447+ t .Helper ()
448+
449+ oldEmailWhitelist := config .Config .EmailWhitelist
450+ config .Config .EmailWhitelist = nil
451+ t .Cleanup (func () {
452+ config .Config .EmailWhitelist = oldEmailWhitelist
453+ })
454+ }
455+
433456func decryptTestShare (privateKeyRing * crypto.KeyRing , armoredPGPMessage string ) (shamir.Share , error ) {
434457 pgpMessage , err := crypto .NewPGPMessageFromArmored (armoredPGPMessage )
435458 if err != nil {
0 commit comments