Skip to content

Commit

Permalink
review: optimise get_sha_algorithm_by_checksum_length and update CHAN…
Browse files Browse the repository at this point in the history
…GELOG.md
  • Loading branch information
PhilippKilian authored and liske committed Sep 28, 2023
1 parent 34b7025 commit b510c91
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ Changes:
- recordFullDurationMedia (v2.6.9)
- disabledFeaturesExclude(2.6.9)
- userdata-bbb_hide_presentation_on_join
- move configuration of checksum hash function from `ClusterGroups` to `Clusters`
- move configuration of checksum hash function from `ClusterGroups` to `Clusters`
- bump dependencies

## 3.0.7 - 2023-06-02

Expand Down
9 changes: 3 additions & 6 deletions b3lb/rest/classes/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ def check_checksum(self) -> bool:
endpoint_string = f"{self.endpoint}{self.get_query_string()}"

for secret in [self.secret.secret, self.secret.secret2]:
if get_checksum(algorithm, f"{endpoint_string}{secret}") == self.checksum:
if get_checksum(algorithm(), f"{endpoint_string}{secret}") == self.checksum:
return True
return False

Expand Down Expand Up @@ -471,13 +471,10 @@ def get_secret_metrics(self) -> str:
def get_sha_algorithm(sha: str) -> Union[HASH, None]:
if sha not in settings.B3LB_ALLOWED_SHA_ALGORITHMS or sha not in Cluster.SHA_BY_STRING:
return None
return Cluster.SHA_BY_STRING.get(sha)()
return Cluster.SHA_BY_STRING.get(sha)

def get_sha_algorithm_by_checksum_length(self) -> Union[HASH, None]:
check_length = len(self.checksum)
if check_length not in Cluster.SHA_BY_LENGTH:
return self.get_sha_algorithm("")
return Cluster.SHA_BY_LENGTH.get(check_length)()
return Cluster.SHA_BY_LENGTH.get(len(self.checksum))

def get_sha_algorithm_by_parameter(self) -> Union[HASH, None]:
return self.get_sha_algorithm(self.parameters.get("checksumHash", ""))
Expand Down

0 comments on commit b510c91

Please sign in to comment.