Add mock target for testing greeter
This commit is contained in:
parent
adb691704e
commit
ef69fe83bf
2 changed files with 19 additions and 8 deletions
|
|
@ -1,11 +1,21 @@
|
|||
use greetd_ipc::{codec::SyncCodec, AuthMessageType, ErrorType, Request, Response};
|
||||
use std::io;
|
||||
use std::{env, fs, io, thread};
|
||||
use tokio::net::UnixListener;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
let listener = UnixListener::bind("socket").unwrap();
|
||||
println!("listening");
|
||||
let greetd_sock = env::current_dir().unwrap().join("socket");
|
||||
if greetd_sock.exists() {
|
||||
fs::remove_file(&greetd_sock).unwrap();
|
||||
}
|
||||
|
||||
let listener = UnixListener::bind(&greetd_sock).unwrap();
|
||||
println!("listening at {:?}", greetd_sock);
|
||||
|
||||
env::set_var("GREETD_SOCK", &greetd_sock);
|
||||
thread::spawn(|| {
|
||||
cosmic_greeter::greeter::main();
|
||||
});
|
||||
|
||||
loop {
|
||||
let (socket, _addr) = listener.accept().await.unwrap();
|
||||
|
|
@ -38,7 +48,7 @@ async fn main() {
|
|||
let response = match request {
|
||||
Request::CreateSession { .. } => Response::AuthMessage {
|
||||
auth_message_type: AuthMessageType::Secret,
|
||||
auth_message: "Password:".to_string(),
|
||||
auth_message: "MOCKING:".to_string(),
|
||||
},
|
||||
Request::PostAuthMessageResponse { response } => {
|
||||
match response.as_ref().map(|x| x.as_str()) {
|
||||
|
|
@ -50,10 +60,7 @@ async fn main() {
|
|||
}
|
||||
}
|
||||
Request::StartSession { .. } => Response::Success,
|
||||
_ => {
|
||||
println!("unhandled request");
|
||||
break;
|
||||
}
|
||||
Request::CancelSession => Response::Success,
|
||||
};
|
||||
|
||||
let mut bytes = Vec::with_capacity(4096);
|
||||
|
|
|
|||
4
justfile
4
justfile
|
|
@ -55,6 +55,10 @@ check *args:
|
|||
# Runs a clippy check with JSON message format
|
||||
check-json: (check '--message-format=json')
|
||||
|
||||
mock:
|
||||
cargo build --release --example server
|
||||
cosmic-comp target/release/examples/server
|
||||
|
||||
# Run with debug logs
|
||||
run *args:
|
||||
env RUST_LOG=debug RUST_BACKTRACE=full cargo run --release {{args}}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue