Search in sources :

Example 1 with RestApiRequest

use of tech.pegasys.teku.infrastructure.restapi.endpoints.RestApiRequest in project teku by ConsenSys.

the class GetKeysTest method shouldListEmpytValidatorKeys.

@Test
void shouldListEmpytValidatorKeys() throws Exception {
    final List<Validator> activeValidatorList = Collections.emptyList();
    when(keyManager.getActiveValidatorKeys()).thenReturn(activeValidatorList);
    final GetKeys endpoint = new GetKeys(keyManager);
    final RestApiRequest request = mock(RestApiRequest.class);
    endpoint.handle(request);
    verify(request).respondOk(activeValidatorList);
}
Also used : RestApiRequest(tech.pegasys.teku.infrastructure.restapi.endpoints.RestApiRequest) Validator(tech.pegasys.teku.validator.client.Validator) Test(org.junit.jupiter.api.Test)

Example 2 with RestApiRequest

use of tech.pegasys.teku.infrastructure.restapi.endpoints.RestApiRequest in project teku by ConsenSys.

the class GetRemoteKeysTest method shouldListEmptyValidatorKeys.

@Test
void shouldListEmptyValidatorKeys() throws Exception {
    final List<ExternalValidator> activeRemoteValidatorList = Collections.emptyList();
    when(keyManager.getActiveRemoteValidatorKeys()).thenReturn(activeRemoteValidatorList);
    final GetRemoteKeys endpoint = new GetRemoteKeys(keyManager);
    final RestApiRequest request = mock(RestApiRequest.class);
    endpoint.handle(request);
    verify(request).respondOk(Collections.emptyList());
}
Also used : ExternalValidator(tech.pegasys.teku.validator.client.restapi.apis.schema.ExternalValidator) RestApiRequest(tech.pegasys.teku.infrastructure.restapi.endpoints.RestApiRequest) Test(org.junit.jupiter.api.Test)

Example 3 with RestApiRequest

use of tech.pegasys.teku.infrastructure.restapi.endpoints.RestApiRequest in project teku by ConsenSys.

the class GetRemoteKeysTest method shouldListValidatorKeys.

@Test
void shouldListValidatorKeys() throws Exception {
    final List<ExternalValidator> activeRemoteValidatorList = getValidatorList().stream().map(val -> new ExternalValidator(val.getPublicKey(), val.getSigner().getSigningServiceUrl(), val.isReadOnly())).collect(Collectors.toList());
    when(keyManager.getActiveRemoteValidatorKeys()).thenReturn(activeRemoteValidatorList);
    final GetRemoteKeys endpoint = new GetRemoteKeys(keyManager);
    final RestApiRequest request = mock(RestApiRequest.class);
    endpoint.handle(request);
    verify(request).respondOk(activeRemoteValidatorList);
}
Also used : Arrays(java.util.Arrays) RestApiRequest(tech.pegasys.teku.infrastructure.restapi.endpoints.RestApiRequest) ExternalValidator(tech.pegasys.teku.validator.client.restapi.apis.schema.ExternalValidator) ActiveKeyManager(tech.pegasys.teku.validator.client.ActiveKeyManager) Mockito.when(org.mockito.Mockito.when) NO_OP_REMOTE_SIGNER(tech.pegasys.teku.core.signatures.NoOpRemoteSigner.NO_OP_REMOTE_SIGNER) BLSKeyPair(tech.pegasys.teku.bls.BLSKeyPair) Collectors(java.util.stream.Collectors) Mockito.verify(org.mockito.Mockito.verify) Test(org.junit.jupiter.api.Test) List(java.util.List) BLSTestUtil(tech.pegasys.teku.bls.BLSTestUtil) Optional(java.util.Optional) Collections(java.util.Collections) Mockito.mock(org.mockito.Mockito.mock) Validator(tech.pegasys.teku.validator.client.Validator) ExternalValidator(tech.pegasys.teku.validator.client.restapi.apis.schema.ExternalValidator) RestApiRequest(tech.pegasys.teku.infrastructure.restapi.endpoints.RestApiRequest) Test(org.junit.jupiter.api.Test)

Example 4 with RestApiRequest

use of tech.pegasys.teku.infrastructure.restapi.endpoints.RestApiRequest in project teku by ConsenSys.

the class GetKeysTest method shouldListValidatorKeys.

@Test
void shouldListValidatorKeys() throws Exception {
    final List<Validator> activeValidatorList = getValidatorList();
    when(keyManager.getActiveValidatorKeys()).thenReturn(activeValidatorList);
    final GetKeys endpoint = new GetKeys(keyManager);
    final RestApiRequest request = mock(RestApiRequest.class);
    endpoint.handle(request);
    verify(request).respondOk(activeValidatorList);
}
Also used : RestApiRequest(tech.pegasys.teku.infrastructure.restapi.endpoints.RestApiRequest) Validator(tech.pegasys.teku.validator.client.Validator) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)4 RestApiRequest (tech.pegasys.teku.infrastructure.restapi.endpoints.RestApiRequest)4 Validator (tech.pegasys.teku.validator.client.Validator)3 ExternalValidator (tech.pegasys.teku.validator.client.restapi.apis.schema.ExternalValidator)2 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 List (java.util.List)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 Mockito.mock (org.mockito.Mockito.mock)1 Mockito.verify (org.mockito.Mockito.verify)1 Mockito.when (org.mockito.Mockito.when)1 BLSKeyPair (tech.pegasys.teku.bls.BLSKeyPair)1 BLSTestUtil (tech.pegasys.teku.bls.BLSTestUtil)1 NO_OP_REMOTE_SIGNER (tech.pegasys.teku.core.signatures.NoOpRemoteSigner.NO_OP_REMOTE_SIGNER)1 ActiveKeyManager (tech.pegasys.teku.validator.client.ActiveKeyManager)1