1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-07-29 22:01:14 +03:00

graphql: Fix the createOauth2Session mutation not persisting the changes to the database

This commit is contained in:
Quentin Gliech
2023-09-12 11:16:48 +02:00
parent 9c97a0c37a
commit 789040d22f
2 changed files with 19 additions and 1 deletions

View File

@ -16,7 +16,10 @@ use axum::http::Request;
use hyper::StatusCode;
use mas_data_model::{AccessToken, Client, TokenType, User};
use mas_router::SimpleRoute;
use mas_storage::{oauth2::OAuth2ClientRepository, RepositoryAccess};
use mas_storage::{
oauth2::{OAuth2AccessTokenRepository, OAuth2ClientRepository},
RepositoryAccess,
};
use oauth2_types::{
registration::ClientRegistrationResponse,
requests::AccessTokenResponse,
@ -551,4 +554,17 @@ async fn test_oauth2_client_credentials(pool: PgPool) {
assert!(response.errors.is_empty(), "{:?}", response.errors);
assert!(response.data["createOauth2Session"]["refreshToken"].is_null());
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());
}