@@ -1283,85 +1283,79 @@ def test_resolve_value_from_config():
1283
1283
class TestLogSagemakerConfig (TestCase ):
1284
1284
1285
1285
def test_sensitive_info_masking (self ):
1286
- logger = logging .getLogger (' sagemaker.config' )
1286
+ logger = logging .getLogger (" sagemaker.config" )
1287
1287
logger .setLevel (logging .DEBUG )
1288
1288
1289
1289
stream_handler = logging .StreamHandler ()
1290
1290
logger .addHandler (stream_handler )
1291
1291
1292
1292
# source value is None
1293
- with self .assertLogs (logger , level = ' DEBUG' ) as log :
1293
+ with self .assertLogs (logger , level = " DEBUG" ) as log :
1294
1294
_log_sagemaker_config_single_substitution (
1295
- None ,
1296
- {"apiKey" : "topsecretkey" },
1297
- "config/path"
1295
+ None , {"apiKey" : "topsecretkey" }, "config/path"
1298
1296
)
1299
1297
1300
1298
self .assertIn ("config value that will be used = {'apiKey': '***'}" , log .output [0 ])
1301
1299
1302
1300
# source value is None and config_value == source_value
1303
- with self .assertLogs (logger , level = ' DEBUG' ) as log :
1301
+ with self .assertLogs (logger , level = " DEBUG" ) as log :
1304
1302
_log_sagemaker_config_single_substitution (
1305
- {"secretword" : "topsecretword" },
1306
- {"secretword" : "topsecretword" },
1307
- "config/path"
1303
+ {"secretword" : "topsecretword" }, {"secretword" : "topsecretword" }, "config/path"
1308
1304
)
1309
1305
1310
1306
self .assertIn ("Skipped value" , log .output [0 ])
1311
1307
self .assertIn ("source value that will be used = {'secretword': '***'}" , log .output [0 ])
1312
1308
self .assertIn ("config value = {'secretword': '***'}" , log .output [0 ])
1313
1309
1314
1310
# source value is not None and config_value != source_value
1315
- with self .assertLogs (logger , level = ' DEBUG' ) as log :
1311
+ with self .assertLogs (logger , level = " DEBUG" ) as log :
1316
1312
_log_sagemaker_config_single_substitution (
1317
- {"password" : "supersecretpassword" },
1318
- {"apiKey" : "topsecretkey" },
1319
- "config/path"
1313
+ {"password" : "supersecretpassword" }, {"apiKey" : "topsecretkey" }, "config/path"
1320
1314
)
1321
1315
1322
1316
self .assertIn ("Skipped value" , log .output [0 ])
1323
1317
self .assertIn ("source value that will be used = {'password': '***'}" , log .output [0 ])
1324
1318
self .assertIn ("config value = {'apiKey': '***'}" , log .output [0 ])
1325
1319
1326
1320
def test_non_sensitive_info_masking (self ):
1327
- logger = logging .getLogger (' sagemaker.config' )
1321
+ logger = logging .getLogger (" sagemaker.config" )
1328
1322
logger .setLevel (logging .DEBUG )
1329
1323
1330
1324
stream_handler = logging .StreamHandler ()
1331
1325
logger .addHandler (stream_handler )
1332
1326
1333
1327
# source value is None
1334
- with self .assertLogs (logger , level = ' DEBUG' ) as log :
1328
+ with self .assertLogs (logger , level = " DEBUG" ) as log :
1335
1329
_log_sagemaker_config_single_substitution (
1336
- None ,
1337
- {"username" : "randomvalue" },
1338
- "config/path"
1330
+ None , {"username" : "randomvalue" }, "config/path"
1339
1331
)
1340
1332
1341
1333
self .assertIn ("config value that will be used = {'username': 'randomvalue'}" , log .output [0 ])
1342
1334
1343
1335
# source value is not None and config_value == source_value
1344
- with self .assertLogs (logger , level = ' DEBUG' ) as log :
1336
+ with self .assertLogs (logger , level = " DEBUG" ) as log :
1345
1337
_log_sagemaker_config_single_substitution (
1346
1338
{"nonsensitivevalue" : "randomvalue" },
1347
1339
{"nonsensitivevalue" : "randomvalue" },
1348
- "config/path"
1340
+ "config/path" ,
1349
1341
)
1350
1342
1351
1343
self .assertIn ("Skipped value" , log .output [0 ])
1352
1344
self .assertIn ("source value that will be used = {'nonsensitivevalue': 'randomvalue'}" , log .output [0 ])
1353
1345
self .assertIn ("config value = {'nonsensitivevalue': 'randomvalue'}" , log .output [0 ])
1354
1346
1355
1347
# source value is not None and config_value != source_value
1356
- with self .assertLogs (logger , level = ' DEBUG' ) as log :
1348
+ with self .assertLogs (logger , level = " DEBUG" ) as log :
1357
1349
_log_sagemaker_config_single_substitution (
1358
1350
{"username" : "nonsensitiveinfo" },
1359
1351
{"configvalue" : "nonsensitivevalue" },
1360
- "config/path/non_sensitive"
1352
+ "config/path/non_sensitive" ,
1361
1353
)
1362
1354
1363
1355
self .assertIn ("Skipped value" , log .output [0 ])
1364
- self .assertIn ("source value that will be used = {'username': 'nonsensitiveinfo'}" , log .output [0 ])
1356
+ self .assertIn (
1357
+ "source value that will be used = {'username': 'nonsensitiveinfo'}" , log .output [0 ]
1358
+ )
1365
1359
self .assertIn ("config value = {'configvalue': 'nonsensitivevalue'}" , log .output [0 ])
1366
1360
1367
1361
0 commit comments