CredentialRepositoryV1ToV2Adapter.java

1
package com.yubico.webauthn;
2
3
import com.yubico.webauthn.data.ByteArray;
4
import java.util.Collections;
5
import java.util.Optional;
6
import java.util.Set;
7
import lombok.AllArgsConstructor;
8
9
@AllArgsConstructor
10
class CredentialRepositoryV1ToV2Adapter
11
    implements CredentialRepositoryV2<RegisteredCredential>, UsernameRepository {
12
13
  private final CredentialRepository inner;
14
15
  @Override
16
  public Set<? extends ToPublicKeyCredentialDescriptor> getCredentialDescriptorsForUserHandle(
17
      ByteArray userHandle) {
18 1 1. getCredentialDescriptorsForUserHandle : replaced return value with Collections.emptySet for com/yubico/webauthn/CredentialRepositoryV1ToV2Adapter::getCredentialDescriptorsForUserHandle → NO_COVERAGE
    return inner
19
        .getUsernameForUserHandle(userHandle)
20
        .map(inner::getCredentialIdsForUsername)
21
        .orElseGet(Collections::emptySet);
22
  }
23
24
  @Override
25
  public Optional<RegisteredCredential> lookup(ByteArray credentialId, ByteArray userHandle) {
26 1 1. lookup : replaced return value with Optional.empty for com/yubico/webauthn/CredentialRepositoryV1ToV2Adapter::lookup → KILLED
    return inner.lookup(credentialId, userHandle);
27
  }
28
29
  @Override
30
  public boolean credentialIdExists(ByteArray credentialId) {
31 2 1. credentialIdExists : replaced boolean return with true for com/yubico/webauthn/CredentialRepositoryV1ToV2Adapter::credentialIdExists → KILLED
2. credentialIdExists : negated conditional → KILLED
    return !inner.lookupAll(credentialId).isEmpty();
32
  }
33
34
  @Override
35
  public Optional<ByteArray> getUserHandleForUsername(String username) {
36 1 1. getUserHandleForUsername : replaced return value with Optional.empty for com/yubico/webauthn/CredentialRepositoryV1ToV2Adapter::getUserHandleForUsername → KILLED
    return inner.getUserHandleForUsername(username);
37
  }
38
39
  @Override
40
  public Optional<String> getUsernameForUserHandle(ByteArray userHandle) {
41 1 1. getUsernameForUserHandle : replaced return value with Optional.empty for com/yubico/webauthn/CredentialRepositoryV1ToV2Adapter::getUsernameForUserHandle → KILLED
    return inner.getUsernameForUserHandle(userHandle);
42
  }
43
}

Mutations

18

1.1
Location : getCredentialDescriptorsForUserHandle
Killed by : none
replaced return value with Collections.emptySet for com/yubico/webauthn/CredentialRepositoryV1ToV2Adapter::getCredentialDescriptorsForUserHandle → NO_COVERAGE

26

1.1
Location : lookup
Killed by : com.yubico.webauthn.RelyingPartyUserIdentificationSpec
replaced return value with Optional.empty for com/yubico/webauthn/CredentialRepositoryV1ToV2Adapter::lookup → KILLED

31

1.1
Location : credentialIdExists
Killed by : com.yubico.webauthn.RelyingPartyCeremoniesSpec
replaced boolean return with true for com/yubico/webauthn/CredentialRepositoryV1ToV2Adapter::credentialIdExists → KILLED

2.2
Location : credentialIdExists
Killed by : com.yubico.webauthn.RelyingPartyCeremoniesSpec
negated conditional → KILLED

36

1.1
Location : getUserHandleForUsername
Killed by : com.yubico.webauthn.RelyingPartyUserIdentificationSpec
replaced return value with Optional.empty for com/yubico/webauthn/CredentialRepositoryV1ToV2Adapter::getUserHandleForUsername → KILLED

41

1.1
Location : getUsernameForUserHandle
Killed by : com.yubico.webauthn.RelyingPartyUserIdentificationSpec
replaced return value with Optional.empty for com/yubico/webauthn/CredentialRepositoryV1ToV2Adapter::getUsernameForUserHandle → KILLED

Active mutators

Tests examined


Report generated by PIT 1.15.0