mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-07 23:44:53 -04:00
refactor(sdk): Expose directly the URI of MatrixMockServer
Since there are several places that use it. Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
This commit is contained in:
committed by
Ivan Enderlin
parent
7fb3d216f6
commit
577a8feb12
@@ -174,8 +174,7 @@ async fn test_high_level_login_cancellation() -> anyhow::Result<()> {
|
||||
|
||||
assert_eq!(oauth.client_id().map(|id| id.as_str()), Some("test_client_id"));
|
||||
|
||||
check_authorization_url(&authorization_data, &oauth, &server.server().uri(), None, None, None)
|
||||
.await;
|
||||
check_authorization_url(&authorization_data, &oauth, &server.uri(), None, None, None).await;
|
||||
|
||||
// When completing login with a cancellation callback.
|
||||
redirect_uri.set_query(Some(&format!(
|
||||
@@ -206,8 +205,7 @@ async fn test_high_level_login_invalid_state() -> anyhow::Result<()> {
|
||||
|
||||
assert_eq!(oauth.client_id().map(|id| id.as_str()), Some("test_client_id"));
|
||||
|
||||
check_authorization_url(&authorization_data, &oauth, &server.server().uri(), None, None, None)
|
||||
.await;
|
||||
check_authorization_url(&authorization_data, &oauth, &server.uri(), None, None, None).await;
|
||||
|
||||
// When completing login with an old/tampered state.
|
||||
redirect_uri.set_query(Some("code=42&state=imposter_alert"));
|
||||
@@ -228,7 +226,7 @@ async fn test_high_level_login_invalid_state() -> anyhow::Result<()> {
|
||||
#[async_test]
|
||||
async fn test_login_url() -> anyhow::Result<()> {
|
||||
let server = MatrixMockServer::new().await;
|
||||
let server_uri = server.server().uri();
|
||||
let server_uri = server.uri();
|
||||
|
||||
let oauth_server = server.oauth();
|
||||
oauth_server.mock_server_metadata().ok().expect(3).mount().await;
|
||||
@@ -509,7 +507,7 @@ async fn test_oauth_session() -> anyhow::Result<()> {
|
||||
#[async_test]
|
||||
async fn test_insecure_clients() -> anyhow::Result<()> {
|
||||
let server = MatrixMockServer::new().await;
|
||||
let server_url = server.server().uri();
|
||||
let server_url = server.uri();
|
||||
|
||||
server.mock_well_known().ok().expect(1..).named("well_known").mount().await;
|
||||
server.mock_versions().ok().expect(1..).named("versions").mount().await;
|
||||
|
||||
@@ -188,6 +188,11 @@ impl MatrixMockServer {
|
||||
&self.server
|
||||
}
|
||||
|
||||
/// Return the URI of this server.
|
||||
pub fn uri(&self) -> String {
|
||||
self.server.uri()
|
||||
}
|
||||
|
||||
/// Get an `OAuthMockServer` that uses the same mock server as this one.
|
||||
pub fn oauth(&self) -> oauth::OAuthMockServer<'_> {
|
||||
oauth::OAuthMockServer::new(self)
|
||||
|
||||
@@ -69,7 +69,7 @@ impl<'a> OAuthMockServer<'a> {
|
||||
|
||||
/// Get the mock OAuth 2.0 server metadata.
|
||||
pub fn server_metadata(&self) -> AuthorizationServerMetadata {
|
||||
MockServerMetadataBuilder::new(&self.server.server().uri())
|
||||
MockServerMetadataBuilder::new(&self.server.uri())
|
||||
.build()
|
||||
.deserialize()
|
||||
.expect("mock OAuth 2.0 server metadata should deserialize successfully")
|
||||
|
||||
@@ -153,7 +153,7 @@ async fn test_reset_oauth() {
|
||||
assert_let!(CrossSigningResetAuthType::OAuth(oauth_info) = reset_handle.auth_type());
|
||||
assert_eq!(
|
||||
oauth_info.approval_url.as_str(),
|
||||
format!("{}/account/?action=org.matrix.cross_signing_reset", server.server().uri())
|
||||
format!("{}/account/?action=org.matrix.cross_signing_reset", server.uri())
|
||||
);
|
||||
|
||||
// Then it retries until it succeeds.
|
||||
|
||||
Reference in New Issue
Block a user