-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make 3PID binding tests use /account/3pid/bind ala MSC2290 (#703)
Synapse PR: matrix-org/synapse#6043 Changes the 3PID binding tests to use the new unstable /account/3pid/bind API endpoint, defined in MSC2290.
- Loading branch information
1 parent
cf86485
commit 626ce88
Showing
2 changed files
with
33 additions
and
24 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,3 +1,26 @@ | ||
sub bind_email_for_user { | ||
my ( $user, $address, $id_server, %params ) = @_; | ||
|
||
my $client_secret = join "", map { chr 40 + rand 86 } 1 .. 20; | ||
|
||
my $id_access_token = $id_server->get_access_token(); | ||
|
||
my $sid = $id_server->validate_identity( 'email', $address, $client_secret ); | ||
|
||
do_request_json_for( | ||
$user, | ||
method => "POST", | ||
uri => "/unstable/account/3pid/bind", | ||
content => { | ||
id_server => $id_server->name, | ||
id_access_token => $id_access_token, | ||
sid => $sid, | ||
client_secret => $client_secret, | ||
}, | ||
); | ||
} | ||
|
||
|
||
test "Can bind 3PID via home server", | ||
requires => [ $main::HTTP_CLIENT, local_user_fixture(), id_server_fixture() ], | ||
|
||
|
@@ -7,8 +30,8 @@ | |
my $medium = "email"; | ||
my $address = '[email protected]'; | ||
|
||
add_email_for_user( | ||
$user, $address, $id_server, bind => 1, | ||
bind_email_for_user( | ||
$user, $address, $id_server, | ||
)->then( sub { | ||
my $res = $id_server->lookup_identity( $medium, $address ); | ||
|
||
|
@@ -28,8 +51,8 @@ | |
my $medium = "email"; | ||
my $address = '[email protected]'; | ||
|
||
add_email_for_user( | ||
$user, $address, $id_server, bind => 1, | ||
bind_email_for_user( | ||
$user, $address, $id_server, | ||
)->then( sub { | ||
my $res = $id_server->lookup_identity( $medium, $address ); | ||
assert_eq( $res, $user->user_id ); | ||
|
@@ -91,8 +114,8 @@ | |
my $medium = "email"; | ||
my $address = '[email protected]'; | ||
|
||
add_email_for_user( | ||
$user, $address, $id_server, bind => 1, | ||
bind_email_for_user( | ||
$user, $address, $id_server, | ||
)->then( sub { | ||
my $res = $id_server->lookup_identity( $medium, $address ); | ||
assert_eq( $res, $user->user_id ); | ||
|
@@ -116,8 +139,8 @@ | |
my $medium = "email"; | ||
my $address = '[email protected]'; | ||
|
||
add_email_for_user( | ||
$user, $address, $id_server, bind => 1, | ||
bind_email_for_user( | ||
$user, $address, $id_server, | ||
)->then( sub { | ||
my $res = $id_server->lookup_identity( $medium, $address ); | ||
assert_eq( $res, $user->user_id ); | ||
|
@@ -149,8 +172,8 @@ | |
my $medium = "email"; | ||
my $address = '[email protected]'; | ||
|
||
add_email_for_user( | ||
$user, $address, $id_server, bind => 1, | ||
bind_email_for_user( | ||
$user, $address, $id_server, | ||
)->then( sub { | ||
my $res = $id_server->lookup_identity( $medium, $address ); | ||
assert_eq( $res, $user->user_id ); | ||
|