Skip to content

Commit

Permalink
Add E2E tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mkay1375 committed Aug 20, 2024
1 parent d7518f1 commit 0ed8182
Show file tree
Hide file tree
Showing 8 changed files with 514 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/main/java/io/github/tap30/hiss/key/KeyHashGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public void generateAndLogHashes(Collection<Key> keys) {
}

/**
* @param keys
* @return map of key ID to key hash.
*/
public Map<String, String> generateHashes(Collection<Key> keys) {
Expand All @@ -44,12 +43,20 @@ public Map<String, String> generateHashes(Collection<Key> keys) {
}

/**
* @param keys
* @return invalid key IDs.
*/
public Set<String> validateKeyHashes(Collection<Key> keys) {
return keys.stream()
.filter(key -> StringUtils.hasText(key.getKeyHash()))
.filter(key -> {
if (StringUtils.hasText(key.getKeyHash())) {
return true;
} else {
logger.log(Level.WARNING,
"Key {0} does not have hash; supply it as soon as possible.",
key.getId());
return false;
}
})
.filter(key -> !verifyer.verify(key.getKey(), key.getKeyHash().getBytes(CHARSET)).verified)
.map(Key::getId)
.collect(Collectors.toSet());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.util.function.Supplier;

// Todo: improve doc

/**
* Sample Envs:
* <br>
Expand Down
Loading

0 comments on commit 0ed8182

Please sign in to comment.