fix: related issues in interpreter_user_alter.rs
@@ -17,6 +17,7 @@ use common_exception::Result;
use common_meta_types::AuthInfo;
use common_meta_types::PasswordHashMethod;
use common_meta_types::UserInfo;
+use common_meta_types::UserOptionFlag;
use databend_query::interpreters::*;
use databend_query::sessions::TableContext;
use databend_query::sql::*;
@@ -66,35 +67,44 @@ async fn test_alter_user_interpreter() -> Result<()> {
);
}
- // ref: https://github.com/datafuselabs/databend/issues/6896
- // {
- // let new_password = "new_password";
- // let test_query = format!(
- // "ALTER USER '{}'@'{}' WITH TENANTSETTING IDENTIFIED BY '{}'",
- // name, hostname, new_password
- // );
- // let (plan, _, _) = planner.plan_sql(&test_query).await?;
- // let executor = InterpreterFactoryV2::get(ctx.clone(), &plan)?;
- // assert_eq!(executor.name(), "AlterUserInterpreter");
- // executor.execute(None).await?;
- // let user_info = user_mgr.get_user(tenant, user_info.identity()).await?;
- // assert!(user_info.has_option_flag(UserOptionFlag::TenantSetting));
- // assert_eq!(
- // user_info.auth_info.get_password_type(),
- // Some(PasswordHashMethod::Sha256)
- // );
- // }
+ {
+ let test_query = format!("ALTER USER '{}'@'{}' WITH TENANTSETTING", name, hostname);
- // ref: https://github.com/datafuselabs/databend/issues/6897
- // {
- // let test_query = format!("ALTER USER '{}'@'{}' WITH NOTENANTSETTING", name, hostname);
- // let (plan, _, _) = planner.plan_sql(&test_query).await?;
- // let executor = InterpreterFactoryV2::get(ctx.clone(), &plan)?;
- // assert_eq!(executor.name(), "AlterUserInterpreter");
- // executor.execute(None).await?;
- // let user_info = user_mgr.get_user(tenant, user_info.identity()).await?;
- // assert!(!user_info.has_option_flag(UserOptionFlag::TenantSetting));
- // }
+ let (plan, _, _) = planner.plan_sql(&test_query).await?;
+ let executor = InterpreterFactoryV2::get(ctx.clone(), &plan)?;
+ assert_eq!(executor.name(), "AlterUserInterpreter");
+ let mut stream = executor.execute().await?;
+ while let Some(_block) = stream.next().await {}
+ let new_user = user_mgr.get_user(tenant, user_info.identity()).await?;
+ assert!(
+ new_user
+ .option
+ .has_option_flag(UserOptionFlag::TenantSetting)
+ );
+ }
+
+ {
+ let test_query = format!(
+ "ALTER USER '{}'@'{}' IDENTIFIED BY '123' WITH NOTENANTSETTING",
+ name, hostname
+ );
+
+ let (plan, _, _) = planner.plan_sql(&test_query).await?;
+ let executor = InterpreterFactoryV2::get(ctx.clone(), &plan)?;
+ assert_eq!(executor.name(), "AlterUserInterpreter");
+ let mut stream = executor.execute().await?;
+ while let Some(_block) = stream.next().await {}
+ let new_user = user_mgr.get_user(tenant, user_info.identity()).await?;
+ assert!(
+ !new_user
+ .option
+ .has_option_flag(UserOptionFlag::TenantSetting)
+ );
+ assert_eq!(
+ user_info.auth_info.get_password_type(),
+ Some(PasswordHashMethod::Sha256)
+ );
+ }
Ok(())
}
