1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-08-09 04:22:45 +03:00

Refactor the upstream link provider template logic

Also adds tests for new account registration through an upstream oauth2
provider
This commit is contained in:
Quentin Gliech
2023-11-13 12:29:01 +01:00
parent 9c94e11e68
commit 89420a2cfc
9 changed files with 560 additions and 153 deletions

View File

@@ -22,6 +22,7 @@ use axum::{
async_trait,
body::{Bytes, HttpBody},
extract::{FromRef, FromRequestParts},
response::{IntoResponse, IntoResponseParts},
};
use cookie_store::{CookieStore, RawCookie};
use futures_util::future::BoxFuture;
@@ -31,7 +32,9 @@ use hyper::{
Request, Response, StatusCode,
};
use mas_axum_utils::{
cookies::CookieManager, http_client_factory::HttpClientFactory, ErrorWrapper,
cookies::{CookieJar, CookieManager},
http_client_factory::HttpClientFactory,
ErrorWrapper,
};
use mas_i18n::Translator;
use mas_keystore::{Encrypter, JsonWebKey, JsonWebKeySet, Keystore, PrivateKey};
@@ -264,6 +267,11 @@ impl TestState {
_ => panic!("Unexpected status code: {}", response.status()),
}
}
/// Get an empty cookie jar
pub fn cookie_jar(&self) -> CookieJar {
self.cookie_manager.cookie_jar()
}
}
struct TestGraphQLState {
@@ -631,6 +639,11 @@ impl CookieHelper {
&url,
);
}
pub fn import(&self, res: impl IntoResponseParts) {
let response = (res, "").into_response();
self.save_cookies(&response);
}
}
impl<S> Layer<S> for CookieHelper {