Added test for endpoint
@@ -268,8 +268,8 @@ mod test {
test, App,
};
use async_trait::async_trait;
- use std::sync::Arc;
use std::collections::HashMap;
+ use std::sync::Arc;
use tornado_engine_api_dto::auth::Auth;
use tornado_engine_api_dto::auth_v2::{AuthHeaderV2, Authorization};
use tornado_engine_api_dto::config::FilterDto;
@@ -634,4 +634,41 @@ mod test {
assert_eq!(StatusCode::OK, response.status());
Ok(())
}
+
+ #[actix_rt::test]
+ async fn v2_endpoint_get_tree_info_return_status_code_ok() -> Result<(), ApiError> {
+ // Arrange
+ let mut srv =
+ test::init_service(App::new().service(build_config_v2_endpoints(ApiDataV2 {
+ auth: test_auth_service_v2(),
+ api: ConfigApi::new(TestApiHandler {}, Arc::new(ConfigManager {})),
+ })))
+ .await;
+
+ // Act
+ let request = test::TestRequest::get()
+ .insert_header((
+ header::AUTHORIZATION,
+ AuthServiceV2::auth_to_token_header(&AuthHeaderV2 {
+ user: "admin".to_string(),
+
+ auths: HashMap::from([(
+ "auth1".to_owned(),
+ Authorization {
+ path: vec!["root".to_owned()],
+ roles: vec!["view".to_owned()],
+ },
+ )]),
+ preferences: None,
+ })?,
+ ))
+ .uri("/config/active/tree/info/auth1")
+ .to_request();
+
+ let response = test::call_service(&mut srv, request).await;
+
+ // Assert
+ assert_eq!(StatusCode::OK, response.status());
+ Ok(())
+ }
}
