Skip to content

Commit

Permalink
BugFix: 500 Server error when upgrade and service restart with data i…
Browse files Browse the repository at this point in the history
…n DB

- return NONE for get effective trust level api if the trustlevel caches
  empty (restart case)

Issue-ID: CPS-2409

Change-Id: I72a755ca6ba5d4a78f5458a235c0d1f43aaa8d53
Signed-off-by: halil.cakal <halil.cakal@est.tech>
  • Loading branch information
halil-cakal committed Sep 25, 2024
1 parent 2dbf148 commit fe846d2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public void updateCmHandleTrustLevel(final String cmHandleId,
*/
public TrustLevel getEffectiveTrustLevel(final String cmHandleId) {
final TrustLevel dmiTrustLevel = TrustLevel.COMPLETE; // TODO: CPS-2375
final TrustLevel cmHandleTrustLevel = trustLevelPerCmHandle.get(cmHandleId);
final TrustLevel cmHandleTrustLevel = trustLevelPerCmHandle.getOrDefault(cmHandleId, TrustLevel.NONE);
return dmiTrustLevel.getEffectiveTrustLevel(cmHandleTrustLevel);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ class TrustLevelManagerSpec extends Specification {
assert effectiveTrustLevel == TrustLevel.NONE
}

def 'Select effective trust level when the trust level caches are empty (restart case)'() {
expect: 'effective trust level is NONE when cm-1 does not exist in the cache'
assert objectUnderTest.getEffectiveTrustLevel('ch-1') == TrustLevel.NONE
}
def 'CmHandle trust level removed'() {
given: 'a cm handle'
trustLevelPerCmHandle.put('ch-1', TrustLevel.COMPLETE)
Expand Down

0 comments on commit fe846d2

Please sign in to comment.