package tv.pluto.utils;

import static tv.pluto.utils.PropertiesHolder.setPropertiesPath;

import com.plutotv.test.lib.security.CryptoSecrets;
import java.util.Properties;
import lombok.experimental.UtilityClass;

@UtilityClass
public class DbPropertiesHolder {

  private static final Properties DB_PROPERTIES_PATH = setPropertiesPath("db.properties");

  private static String getDecryptedDbPassword() {
    String encryptedDbPassword =
        DB_PROPERTIES_PATH.getProperty(Route.getEnvironment() + "_DB_PASSWORD");

    return CryptoSecrets.decryptString(encryptedDbPassword);
  }

  public static String getDbName() {
    return DB_PROPERTIES_PATH.getProperty(Route.getEnvironment() + "_DB_NAME");
  }

  public static String getDbUri() {
    return DB_PROPERTIES_PATH
        .getProperty(Route.getEnvironment() + "_DB_URI")
        .replace("***", getDecryptedDbPassword());
  }
}
