mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-07-21 16:11:56 +00:00

* chore: move to latest appflowy collab version * chore: filter mapping * chore: remove mutex folder * chore: cleanup borrow checker issues * chore: fixed flowy user crate compilation errors * chore: removed parking lot crate * chore: adjusting non locking approach * chore: remove with folder method * chore: fix folder manager * chore: fixed workspace database compilation errors * chore: initialize database plugins * chore: fix locks in flowy core * chore: remove supabase * chore: async traits * chore: add mutexes in dart ffi * chore: post rebase fixes * chore: remove supabase dart code * chore: fix deadlock * chore: fix page_id is empty * chore: use data source to init collab * chore: fix user awareness test * chore: fix database deadlock * fix: initialize user awareness * chore: fix open workspace test * chore: fix import csv * chore: fix update row meta deadlock * chore: fix document size test * fix: timestamp set/get type convert * fix: calculation * chore: revert Arc to Rc * chore: attach plugin to database and database row * chore: async get row * chore: clippy * chore: fix tauri build * chore: clippy * fix: duplicate view deadlock * chore: fmt * chore: tauri build --------- Co-authored-by: nathan <nathan@appflowy.io>
94 lines
2.6 KiB
Rust
94 lines
2.6 KiB
Rust
use client_api::ClientConfiguration;
|
|
use semver::Version;
|
|
use std::collections::HashMap;
|
|
use std::sync::Arc;
|
|
|
|
use flowy_error::FlowyResult;
|
|
use uuid::Uuid;
|
|
|
|
use flowy_server::af_cloud::define::ServerUser;
|
|
use flowy_server::af_cloud::AppFlowyCloudServer;
|
|
use flowy_server_pub::af_cloud_config::AFCloudConfiguration;
|
|
|
|
use crate::setup_log;
|
|
|
|
/// To run the test, create a .env.ci file in the 'flowy-server' directory and set the following environment variables:
|
|
///
|
|
/// - `APPFLOWY_CLOUD_BASE_URL=http://localhost:8000`
|
|
/// - `APPFLOWY_CLOUD_WS_BASE_URL=ws://localhost:8000/ws`
|
|
/// - `APPFLOWY_CLOUD_GOTRUE_URL=http://localhost:9998`
|
|
///
|
|
/// - `GOTRUE_ADMIN_EMAIL=admin@example.com`
|
|
/// - `GOTRUE_ADMIN_PASSWORD=password`
|
|
pub fn get_af_cloud_config() -> Option<AFCloudConfiguration> {
|
|
dotenv::from_filename("./.env.ci").ok()?;
|
|
setup_log();
|
|
AFCloudConfiguration::from_env().ok()
|
|
}
|
|
|
|
pub fn af_cloud_server(config: AFCloudConfiguration) -> Arc<AppFlowyCloudServer> {
|
|
let fake_device_id = uuid::Uuid::new_v4().to_string();
|
|
Arc::new(AppFlowyCloudServer::new(
|
|
config,
|
|
true,
|
|
fake_device_id,
|
|
Version::new(0, 5, 8),
|
|
Arc::new(FakeServerUserImpl),
|
|
))
|
|
}
|
|
|
|
struct FakeServerUserImpl;
|
|
impl ServerUser for FakeServerUserImpl {
|
|
fn workspace_id(&self) -> FlowyResult<String> {
|
|
todo!()
|
|
}
|
|
}
|
|
|
|
pub async fn generate_sign_in_url(user_email: &str, config: &AFCloudConfiguration) -> String {
|
|
let client = client_api::Client::new(
|
|
&config.base_url,
|
|
&config.ws_base_url,
|
|
&config.gotrue_url,
|
|
"fake_device_id",
|
|
ClientConfiguration::default(),
|
|
"test",
|
|
);
|
|
let admin_email = std::env::var("GOTRUE_ADMIN_EMAIL").unwrap();
|
|
let admin_password = std::env::var("GOTRUE_ADMIN_PASSWORD").unwrap();
|
|
let admin_client = client_api::Client::new(
|
|
client.base_url(),
|
|
client.ws_addr(),
|
|
client.gotrue_url(),
|
|
"fake_device_id",
|
|
ClientConfiguration::default(),
|
|
&client.client_version.to_string(),
|
|
);
|
|
admin_client
|
|
.sign_in_password(&admin_email, &admin_password)
|
|
.await
|
|
.unwrap();
|
|
|
|
let action_link = admin_client
|
|
.generate_sign_in_action_link(user_email)
|
|
.await
|
|
.unwrap();
|
|
client.extract_sign_in_url(&action_link).await.unwrap()
|
|
}
|
|
|
|
pub async fn af_cloud_sign_up_param(
|
|
email: &str,
|
|
config: &AFCloudConfiguration,
|
|
) -> HashMap<String, String> {
|
|
let mut params = HashMap::new();
|
|
params.insert(
|
|
"sign_in_url".to_string(),
|
|
generate_sign_in_url(email, config).await,
|
|
);
|
|
params.insert("device_id".to_string(), Uuid::new_v4().to_string());
|
|
params
|
|
}
|
|
|
|
pub fn generate_test_email() -> String {
|
|
format!("{}@test.com", Uuid::new_v4())
|
|
}
|