@@ -88,6 +88,43 @@ class AWSSecretsManagerSettings(BaseSettings):
8888 assert settings ['SqlServerUser' ] == 'test-user'
8989 assert settings ['SqlServer' ]['Password' ] == 'test-password'
9090
91+ @mock_aws
92+ def test_secret_manager_case_insensitive_success (self ) -> None :
93+ """Test secret manager getitem case insensitive success."""
94+
95+ class SqlServer (BaseModel ):
96+ password : str = Field (..., alias = 'Password' )
97+
98+ class AWSSecretsManagerSettings (BaseSettings ):
99+ """AWSSecretsManager settings."""
100+
101+ sql_server_user : str
102+ sql_server : SqlServer
103+
104+ @classmethod
105+ def settings_customise_sources (
106+ cls ,
107+ settings_cls : type [BaseSettings ],
108+ init_settings : PydanticBaseSettingsSource ,
109+ env_settings : PydanticBaseSettingsSource ,
110+ dotenv_settings : PydanticBaseSettingsSource ,
111+ file_secret_settings : PydanticBaseSettingsSource ,
112+ ) -> tuple [PydanticBaseSettingsSource , ...]:
113+ return (AWSSecretsManagerSettingsSource (settings_cls , 'test-secret' , case_sensitive = False ),)
114+
115+ secret_data = {
116+ 'SQL_SERVER_USER' : 'test-user' ,
117+ 'SQL_SERVER--PASSWORD' : 'test-password' ,
118+ }
119+
120+ client = boto3 .client ('secretsmanager' )
121+ client .create_secret (Name = 'test-secret' , SecretString = json .dumps (secret_data ))
122+
123+ settings = AWSSecretsManagerSettings () # type: ignore
124+
125+ assert settings .sql_server_user == 'test-user'
126+ assert settings .sql_server .password == 'test-password'
127+
91128 @mock_aws
92129 def test_aws_secrets_manager_settings_source (self ) -> None :
93130 """Test AWSSecretsManagerSettingsSource."""
0 commit comments