Beispiel #1
0
 def get_missing_key_entry(cls, entry: AuditLogEntry) -> Optional[str]:
     return (get_first_missing_key(inp_dict=entry.payload,
                                   keys=["metadata", "tableDataRead"])
             or get_first_missing_key(
                 inp_dict=entry.payload,
                 keys=["authenticationInfo", "principalEmail"])
             or get_first_missing_key(inp_dict=entry.payload,
                                      keys=["resourceName"]))
def test_get_missing_key():
    assert get_first_missing_key({}, [""]) == ""
    assert get_first_missing_key({"a": 1}, ["a"]) is None
    assert get_first_missing_key({"a": {"b": 1}}, ["a", "b"]) is None
    assert get_first_missing_key({"a": {"b": 1}}, ["a", "c"]) == "c"
    assert get_first_missing_key({"a": ["b", "c", "d"]}, ["a", "c"]) == "c"
Beispiel #3
0
 def get_missing_key_entry_v2(entry: AuditLogEntry) -> Optional[str]:
     return get_first_missing_key(inp_dict=entry.payload,
                                  keys=["metadata", "jobChange", "job"])
Beispiel #4
0
 def get_missing_key_entry(entry: AuditLogEntry) -> Optional[str]:
     return get_first_missing_key(
         inp_dict=entry.payload,
         keys=["serviceData", "jobCompletedEvent", "job"])