Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
coverage:
status:
project:
default:
informational: true
patch:
default:
informational: true
9 changes: 9 additions & 0 deletions driver/src/database/redis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ pub struct RedisDatabase {
}

impl RedisDatabase {
/// Creates a dummy instance with an unreachable URL. For tests that never actually access Redis.
pub fn new_noop() -> error_stack::Result<RedisDatabase, KernelError> {
let config = Config::from_url("redis://invalid");
let pool = config
.create_pool(Some(Runtime::Tokio1))
.change_context_lazy(|| KernelError::Internal)?;
Ok(Self { pool })
}

pub fn new() -> error_stack::Result<RedisDatabase, KernelError> {
let url = if let Some(env) = env(REDIS_URL)? {
env
Expand Down
27 changes: 26 additions & 1 deletion server/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,31 @@ impl Handler {
}
}

#[cfg(test)]
impl Handler {
async fn init_for_oauth2_test(
hydra_admin_url: String,
kratos_public_url: String,
keto_read_url: String,
keto_write_url: String,
) -> error_stack::Result<Self, KernelError> {
let pgpool = PostgresDatabase::new().await?;
let redis = RedisDatabase::new_noop()?;
Ok(Self {
pgpool,
redis,
password_provider: FilePasswordProvider::new(),
raw_key_generator: Rsa2048RawGenerator,
key_encryptor: Argon2Encryptor::default(),
signer: Rsa2048Signer,
verifier: Rsa2048Verifier,
hydra_admin_client: HydraAdminClient::new(hydra_admin_url),
kratos_client: KratosClient::new(kratos_public_url),
keto_client: KetoClient::new(keto_read_url, keto_write_url),
})
}
}

#[cfg(test)]
impl AppModule {
pub(crate) async fn new_for_oauth2_test(
Expand All @@ -302,7 +327,7 @@ impl AppModule {
let keto_write_url =
dotenvy::var("KETO_WRITE_URL").unwrap_or_else(|_| "http://localhost:4467".to_string());
let handler = Arc::new(
Handler::init_with_urls(
Handler::init_for_oauth2_test(
hydra_admin_url,
kratos_public_url,
keto_read_url,
Expand Down
Loading