You've already forked authentication-service
mirror of
https://github.com/matrix-org/matrix-authentication-service.git
synced 2025-07-31 09:24:31 +03:00
graphql: Fix the createOauth2Session mutation not persisting the changes to the database
This commit is contained in:
@ -199,6 +199,8 @@ impl OAuth2SessionMutations {
|
|||||||
Some(refresh_token)
|
Some(refresh_token)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
repo.save().await?;
|
||||||
|
|
||||||
Ok(CreateOAuth2SessionPayload {
|
Ok(CreateOAuth2SessionPayload {
|
||||||
session,
|
session,
|
||||||
access_token: access_token.access_token,
|
access_token: access_token.access_token,
|
||||||
|
@ -16,7 +16,10 @@ use axum::http::Request;
|
|||||||
use hyper::StatusCode;
|
use hyper::StatusCode;
|
||||||
use mas_data_model::{AccessToken, Client, TokenType, User};
|
use mas_data_model::{AccessToken, Client, TokenType, User};
|
||||||
use mas_router::SimpleRoute;
|
use mas_router::SimpleRoute;
|
||||||
use mas_storage::{oauth2::OAuth2ClientRepository, RepositoryAccess};
|
use mas_storage::{
|
||||||
|
oauth2::{OAuth2AccessTokenRepository, OAuth2ClientRepository},
|
||||||
|
RepositoryAccess,
|
||||||
|
};
|
||||||
use oauth2_types::{
|
use oauth2_types::{
|
||||||
registration::ClientRegistrationResponse,
|
registration::ClientRegistrationResponse,
|
||||||
requests::AccessTokenResponse,
|
requests::AccessTokenResponse,
|
||||||
@ -551,4 +554,17 @@ async fn test_oauth2_client_credentials(pool: PgPool) {
|
|||||||
assert!(response.errors.is_empty(), "{:?}", response.errors);
|
assert!(response.errors.is_empty(), "{:?}", response.errors);
|
||||||
assert!(response.data["createOauth2Session"]["refreshToken"].is_null());
|
assert!(response.data["createOauth2Session"]["refreshToken"].is_null());
|
||||||
assert!(response.data["createOauth2Session"]["accessToken"].is_string());
|
assert!(response.data["createOauth2Session"]["accessToken"].is_string());
|
||||||
|
|
||||||
|
let token = response.data["createOauth2Session"]["accessToken"]
|
||||||
|
.as_str()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
// We should find this token in the database
|
||||||
|
let mut repo = state.repository().await.unwrap();
|
||||||
|
let token = repo
|
||||||
|
.oauth2_access_token()
|
||||||
|
.find_by_token(token)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
assert!(token.is_some());
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user