@@ -445,6 +445,8 @@ func TestAccountData(t *testing.T) {
445
445
func TestDevices (t * testing.T ) {
446
446
ctx := context .Background ()
447
447
448
+ dupeAccessToken := util .RandomString (8 )
449
+
448
450
displayName := "testing"
449
451
450
452
creationTests := []struct {
@@ -455,25 +457,43 @@ func TestDevices(t *testing.T) {
455
457
}{
456
458
{
457
459
name : "not a local user" ,
458
- inputData : & api.PerformDeviceCreationRequest {Localpart : "test1" , ServerName : "notlocal" },
460
+ inputData : & api.PerformDeviceCreationRequest {Localpart : "test1" , ServerName : "notlocal" , AccessTokenUniqueConstraintDisabled : true },
459
461
wantErr : true ,
460
462
},
461
463
{
462
464
name : "implicit local user" ,
463
- inputData : & api.PerformDeviceCreationRequest {Localpart : "test1" , AccessToken : util .RandomString (8 ), NoDeviceListUpdate : true , DeviceDisplayName : & displayName },
465
+ inputData : & api.PerformDeviceCreationRequest {Localpart : "test1" , AccessToken : util .RandomString (8 ), NoDeviceListUpdate : true , DeviceDisplayName : & displayName , AccessTokenUniqueConstraintDisabled : true },
464
466
},
465
467
{
466
468
name : "explicit local user" ,
467
- inputData : & api.PerformDeviceCreationRequest {Localpart : "test2" , ServerName : "test" , AccessToken : util .RandomString (8 ), NoDeviceListUpdate : true },
469
+ inputData : & api.PerformDeviceCreationRequest {Localpart : "test2" , ServerName : "test" , AccessToken : util .RandomString (8 ), NoDeviceListUpdate : true , AccessTokenUniqueConstraintDisabled : true },
468
470
},
469
471
{
470
472
name : "test3 second device" , // used to test deletion later
471
- inputData : & api.PerformDeviceCreationRequest {Localpart : "test3" , ServerName : "test" , AccessToken : util .RandomString (8 ), NoDeviceListUpdate : true },
473
+ inputData : & api.PerformDeviceCreationRequest {Localpart : "test3" , ServerName : "test" , AccessToken : util .RandomString (8 ), NoDeviceListUpdate : true , AccessTokenUniqueConstraintDisabled : true },
472
474
},
473
475
{
474
476
name : "test3 third device" , // used to test deletion later
475
477
wantNewDevID : true ,
476
- inputData : & api.PerformDeviceCreationRequest {Localpart : "test3" , ServerName : "test" , AccessToken : util .RandomString (8 ), NoDeviceListUpdate : true },
478
+ inputData : & api.PerformDeviceCreationRequest {Localpart : "test3" , ServerName : "test" , AccessToken : util .RandomString (8 ), NoDeviceListUpdate : true , AccessTokenUniqueConstraintDisabled : true },
479
+ },
480
+ {
481
+ name : "dupe token - ok (unique constraint enabled)" ,
482
+ inputData : & api.PerformDeviceCreationRequest {Localpart : "test3" , ServerName : "test" , AccessToken : dupeAccessToken , NoDeviceListUpdate : true , AccessTokenUniqueConstraintDisabled : false },
483
+ },
484
+ {
485
+ name : "dupe token - not ok (unique constraint enabled)" ,
486
+ inputData : & api.PerformDeviceCreationRequest {Localpart : "test3" , ServerName : "test" , AccessToken : dupeAccessToken , NoDeviceListUpdate : true , AccessTokenUniqueConstraintDisabled : false },
487
+ wantErr : true ,
488
+ },
489
+ {
490
+ name : "dupe token - ok (unique constraint disabled)" ,
491
+ inputData : & api.PerformDeviceCreationRequest {Localpart : "test3" , ServerName : "test" , AccessToken : dupeAccessToken , NoDeviceListUpdate : true , AccessTokenUniqueConstraintDisabled : true },
492
+ },
493
+ {
494
+ name : "dupe token - not ok (unique constraint disabled)" ,
495
+ inputData : & api.PerformDeviceCreationRequest {Localpart : "test3" , ServerName : "test" , AccessToken : dupeAccessToken , NoDeviceListUpdate : true , AccessTokenUniqueConstraintDisabled : true },
496
+ wantErr : true ,
477
497
},
478
498
}
479
499
0 commit comments