-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Testsuit): 🎉 first test(admin_login)
- Loading branch information
Showing
15 changed files
with
119 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
"conventionalCommits.scopes": [ | ||
"Frontend", | ||
"Backend", | ||
"Judger" | ||
"Judger", | ||
"Testsuit" | ||
] | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,15 @@ | ||
// use std::sync::Arc; | ||
use http_body::combinators::UnsyncBoxBody; | ||
use hyper::client::HttpConnector; | ||
use tonic_web::{GrpcWebCall, GrpcWebClientLayer, GrpcWebClientService}; | ||
|
||
// use crate::grpc::backend::token_set_client::TokenSetClient; | ||
// use hyper::{client::HttpConnector, Uri}; | ||
// use rustls::client::{DangerousClientConfig, ServerCertVerifier, ServerCertVerified}; | ||
// use rustls_pki_types::*; | ||
// use tokio_rustls::rustls::*; | ||
pub type Intercepter = GrpcWebClientService< | ||
hyper::Client<HttpConnector, GrpcWebCall<UnsyncBoxBody<hyper::body::Bytes, tonic::Status>>>, | ||
>; | ||
|
||
// #[derive(Debug)] | ||
// pub struct AllowAllVerifier; | ||
pub fn connection() -> Intercepter { | ||
let client = hyper::Client::builder().build_http(); | ||
|
||
// impl ServerCertVerifier for AllowAllVerifier { | ||
// fn supported_verify_schemes(&self) -> Vec<tokio_rustls::rustls::SignatureScheme> { | ||
// vec![tokio_rustls::rustls::SignatureScheme::RSA_PSS_SHA256] | ||
// } | ||
|
||
// fn verify_server_cert( | ||
// &self, | ||
// end_entity: &Certificate, | ||
// intermediates: &[Certificate], | ||
// server_name: &rustls::ServerName, | ||
// scts: &mut dyn Iterator<Item = &[u8]>, | ||
// ocsp_response: &[u8], | ||
// now: std::time::SystemTime, | ||
// ) -> Result<ServerCertVerified, Error> { | ||
// todo!() | ||
// } | ||
// } | ||
|
||
// fn tls_config() -> ClientConfig { | ||
// let verifier = Arc::new(AllowAllVerifier) as Arc<(dyn ServerCertVerifier + 'static)>; | ||
// let mut tls_config = ClientConfig::builder().with_safe_defaults().with_no_client_auth() | ||
// ; | ||
// // .with_custom_certificate_verifier(verifier) | ||
// // .with_no_client_auth(); | ||
// tls_config | ||
// } | ||
|
||
// pub struct Clients {} | ||
|
||
// async fn token_client() { | ||
// // let tls = tls_config(); | ||
|
||
// // let mut http = HttpConnector::new(); | ||
// // http.enforce_http(false); | ||
|
||
// // // We have to do some wrapping here to map the request type from | ||
// // // `https://example.com` -> `https://[::1]:50051` because `rustls` | ||
// // // doesn't accept ip's as `ServerName`. | ||
// // let connector = tower::ServiceBuilder::new() | ||
// // .layer_fn(move |s| { | ||
// // let tls = tls.clone(); | ||
|
||
// // hyper_rustls::HttpsConnectorBuilder::new() | ||
// // .with_tls_config(tls) | ||
// // .https_or_http() | ||
// // }) | ||
// // // Since our cert is signed with `example.com` but we actually want to connect | ||
// // // to a local server we will override the Uri passed from the `HttpsConnector` | ||
// // // and map it to the correct `Uri` that will connect us directly to the local server. | ||
// // .map_request(|_| Uri::from_static("https://[::1]:50051")) | ||
// // .service(http); | ||
// } | ||
tower::ServiceBuilder::new() | ||
.layer(GrpcWebClientLayer::new()) | ||
.service(client) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pub static SERVER: &str = "http://localhost:8081"; | ||
pub static ADMIN: &str = "admin"; | ||
pub static ADMIN_PWD: &str = "admin"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
// mod login; | ||
// use crate::{client::Clients, grpc::*}; | ||
mod login; | ||
use crate::{case::CaseRunner, user::login::AdminLogin}; | ||
|
||
// struct State { | ||
// token: Option<String>, | ||
// clients: Clients, | ||
// } | ||
#[derive(Default)] | ||
pub struct State { | ||
token: Option<String>, | ||
} | ||
|
||
// pub async fn run() {} | ||
pub async fn run() -> State { | ||
let mut user_runner = CaseRunner::<State>::default(); | ||
|
||
user_runner.add_case(AdminLogin); | ||
|
||
user_runner.run("user").await | ||
} |