Skip to content

Commit

Permalink
Remove get signup method (#232)
Browse files Browse the repository at this point in the history
  • Loading branch information
racevedoo authored Jul 15, 2024
1 parent 319804b commit 2a42d43
Show file tree
Hide file tree
Showing 9 changed files with 0 additions and 218 deletions.
32 changes: 0 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,22 +134,6 @@ try {
}
```

#### Getting a Signup

This method allows you to query the latest assessment for a given signup event, returning a `SignupAssessment`, containing the risk assessment and supporting evidence:

```java
IncogniaAPI api = new IncogniaAPI("client-id", "client-secret");
try {
UUID signupId = UUID.fromString("c9ac2803-c868-4b7a-8323-8a6b96298ebe");
SignupAssessment assessment = api.getSignupAssessment(signupId);
} catch (IncogniaAPIException e) {
//Some api error happened (invalid data, invalid credentials)
} catch (IncogniaException e) {
//Something unexpected happened
}
```

#### Registering Web Signup

This method registers a new web signup for the given session token, returning a `SignupAssessment`, containing the risk assessment and supporting evidence:
Expand Down Expand Up @@ -344,16 +328,6 @@ along with the `getPayload` method, which returns the api response payload, whic

If you have found a bug or if you have a feature request, please report them at this repository issues section.

### Publishing a new version

We use the [Gradle Nexus publish plugin](https://github.com/gradle-nexus/publish-plugin/) to publish artifacts to maven central.

To publish a new version to a staging repository, run:
```bash
./gradlew publishToSonatype closeSonatypeStagingRepository
```
If the version ends with `-SNAPSHOT`, it is published to the Sonatype snapshots repository.

## What is Incognia?

Incognia is a location identity platform for mobile apps that enables:
Expand All @@ -362,12 +336,6 @@ Incognia is a location identity platform for mobile apps that enables:
- Frictionless authentication
- Real-time transaction verification

## Create a Free Incognia Account

1. Go to [Incognia](https://www.incognia.com/) and click on "Sign Up For Free"
2. Create an Account
3. You're ready to integrate [Incognia SDK](https://docs.incognia.com/sdk/getting-started) and use [Incognia APIs](https://dash.incognia.com/api-reference)
## License

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
29 changes: 0 additions & 29 deletions src/main/java/com/incognia/api/IncogniaAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
import java.util.stream.Collectors;
import okhttp3.OkHttpClient;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -123,34 +122,6 @@ public SignupAssessment registerSignup(RegisterSignupRequest request) throws Inc
"api/v2/onboarding/signups", postSignupRequestBody, SignupAssessment.class);
}

/**
* Gets the latest assessment for a given signup. Check <a
* href="https://dash.incognia.com/api-reference#operation/signup-get">the docs</a><br>
* Example:
*
* <pre>{@code
* IncogniaAPI api = new IncogniaAPI("client-id", "client-secret", Region.BR);
* try {
* UUID signupId = UUID.fromString("c9ac2803-c868-4b7a-8323-8a6b96298ebe");
* SignupAssessment assessment = api.getSignupAssessment(signupId);
* } catch (IncogniaAPIException e) {
* //Some api error happened (invalid data, invalid credentials)
* } catch (IncogniaException e) {
* //Something unexpected happened
* }
* }</pre>
*
* @param signupId the signup id
* @return the latest assessment
* @throws IncogniaAPIException in case of api errors
* @throws IncogniaException in case of unexpected errors
*/
public SignupAssessment getSignupAssessment(UUID signupId) throws IncogniaException {
Asserts.assertNotNull(signupId, "signup id");
String path = String.format("api/v2/onboarding/signups/%s", signupId);
return tokenAwareNetworkingClient.doGet(path, SignupAssessment.class);
}

/**
* Registers a login to obtain a risk assessment. Check <a
* href="https://dash.incognia.com/api-reference#operation/transactions-post">the docs</a><br>
Expand Down
21 changes: 0 additions & 21 deletions src/main/java/com/incognia/api/clients/NetworkingClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,27 +92,6 @@ public <T> void doPost(
}
}

public <T> T doGet(String path, Class<T> responseType, Map<String, String> headers)
throws IncogniaException {
Request request =
new Builder()
.url(baseUrl.newBuilder().addPathSegments(path).build())
.get()
.headers(Headers.of(headers))
.build();
try (Response response = httpClient.newCall(request).execute()) {
return parseResponse(response, responseType);
} catch (IOException e) {
// TODO(rato): handle timeout
throw new IncogniaException("network call failed", e);
}
}

private <T> Request buildPostRequest(String path, T body, Map<String, String> headers)
throws IncogniaException {
return buildPostRequest(path, body, headers, Collections.emptyMap());
}

@NotNull
private <T> Request buildPostRequest(
String path, T body, Map<String, String> headers, Map<String, String> queryParameters)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,6 @@ public <T> void doPost(String path, T body, Map<String, String> queryParameters)
networkingClient.doPost(path, body, headers, queryParameters);
}

public <T> T doGet(String path, Class<T> responseType) throws IncogniaException {
refreshTokenIfNeeded();
Map<String, String> headers =
new HashMap<String, String>() {
{
put(USER_AGENT_HEADER, USER_AGENT_HEADER_CONTENT);
put(AUTHORIZATION_HEADER, buildAuthorizationHeader());
}
};
return networkingClient.doGet(path, responseType, headers);
}

private String buildAuthorizationHeader() {
return token.getTokenType() + " " + token.getAccessToken();
}
Expand Down
46 changes: 0 additions & 46 deletions src/test/java/com/incognia/api/IncogniaAPITest.java
Original file line number Diff line number Diff line change
Expand Up @@ -271,52 +271,6 @@ void testRegisterWebSignup_whenEmptySessionToken() {
.hasMessage("'session token' cannot be empty");
}

@Test
@DisplayName("should return the expected signup response")
@SneakyThrows
void testGetSignupAssessment_whenDataIsValid() {
String token = TokenCreationFixture.createToken();
UUID signupId = UUID.randomUUID();
TokenAwareDispatcher dispatcher = new TokenAwareDispatcher(token, CLIENT_ID, CLIENT_SECRET);
dispatcher.setExpectedSignupId(signupId);
mockServer.setDispatcher(dispatcher);
SignupAssessment signupAssessment = client.getSignupAssessment(signupId);
assertThat(signupAssessment)
.extracting("id", "requestId", "riskAssessment", "deviceId")
.containsExactly(
UUID.fromString("5e76a7ca-577c-4f47-a752-9e1e0cee9e49"),
UUID.fromString("8afc84a7-f1d4-488d-bd69-36d9a37168b7"),
Assessment.LOW_RISK,
"1df6d999-556d-42c3-8c63-357e5d08d95b");
Map<String, Object> locationServices = new HashMap<>();
locationServices.put("location_permission_enabled", true);
locationServices.put("location_sensors_enabled", true);
Map<String, Object> deviceIntegrity = new HashMap<>();
deviceIntegrity.put("probable_root", false);
deviceIntegrity.put("emulator", false);
deviceIntegrity.put("gps_spoofing", false);
deviceIntegrity.put("from_official_store", true);

Map<String, Object> expectedEvidence = new HashMap<>();
expectedEvidence.put("device_model", "Moto Z2 Play");
expectedEvidence.put("geocode_quality", "good");
expectedEvidence.put("address_quality", "good");
expectedEvidence.put("address_match", "street");
expectedEvidence.put("location_events_near_address", 38);
expectedEvidence.put("location_events_quantity", 288);
expectedEvidence.put("location_services", locationServices);
expectedEvidence.put("device_integrity", deviceIntegrity);

assertThat(signupAssessment.getEvidence()).containsExactlyInAnyOrderEntriesOf(expectedEvidence);

Reason expectedReason =
Reason.builder()
.code(ReasonCode.TRUSTED_LOCATION.getCode())
.source(ReasonSource.LOCAL.getSource())
.build();
assertThat(signupAssessment.getReasons()).containsExactly(expectedReason);
}

@ParameterizedTest
@ValueSource(booleans = {true})
@NullSource
Expand Down
23 changes: 0 additions & 23 deletions src/test/java/com/incognia/api/clients/NetworkingClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import com.incognia.fixtures.TestResponseBody;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import lombok.SneakyThrows;
import okhttp3.OkHttpClient;
import okhttp3.mockwebserver.Dispatcher;
Expand Down Expand Up @@ -63,28 +62,6 @@ public MockResponse dispatch(@NotNull RecordedRequest request) {
assertThat(response.getName()).isEqualTo("my awesome name");
}

@Test
@DisplayName("should get given url")
void testDoGet_whenSuccessfulResponse() throws IncogniaException {
mockServer.setDispatcher(
new Dispatcher() {
@SneakyThrows
@NotNull
@Override
public MockResponse dispatch(@NotNull RecordedRequest request) {
if ("/v2/testurl".equals(request.getPath()) && "GET".equals(request.getMethod())) {
return new MockResponse()
.setResponseCode(200)
.setBody("{\"name\": \"my awesome name\"}");
}
return new MockResponse().setResponseCode(404);
}
});
TestResponseBody response =
client.doGet("v2/testurl", TestResponseBody.class, Collections.emptyMap());
assertThat(response.getName()).isEqualTo("my awesome name");
}

@Test
@DisplayName("should throw incognia api exception with correct fields")
void testDoPost_whenInternalErrorResponse() {
Expand Down
12 changes: 0 additions & 12 deletions src/test/java/com/incognia/api/clients/TokenAwareDispatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,6 @@ public MockResponse dispatch(@NotNull RecordedRequest request) {
&& "POST".equals(request.getMethod())) {
return handlePostSignup(request);
}
if (("/api/v2/onboarding/signups/" + expectedSignupId).equals(request.getPath())
&& "GET".equals(request.getMethod())) {
return handleGetSignup(request);
}
if (("/api/v2/authentication/transactions?eval=true".equals(request.getPath())
|| ("/api/v2/authentication/transactions".equals(request.getPath()))
&& "POST".equals(request.getMethod()))) {
Expand Down Expand Up @@ -128,14 +124,6 @@ private MockResponse handlePostTransactionGivenFalseEval(RecordedRequest request
return new MockResponse().setResponseCode(200).setBody(response);
}

@NotNull
private MockResponse handleGetSignup(@NotNull RecordedRequest request) {
assertThat(request.getHeader("User-Agent")).isEqualTo(USER_AGENT_HEADER);
assertThat(request.getHeader("Authorization")).isEqualTo("Bearer " + token);
String response = ResourceUtils.getResourceFileAsString("get_onboarding_response.json");
return new MockResponse().setResponseCode(200).setBody(response);
}

@NotNull
private MockResponse handlePostSignup(@NotNull RecordedRequest request)
throws java.io.IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,6 @@ void testDoPost_whenNoTokenExistsYetAndCredentialsAreValid() throws IncogniaExce
assertThat(dispatcher.getTokenRequestCount()).isEqualTo(1);
}

@Test
@DisplayName("should call the api with the same valid token")
void testDoGet_whenNoTokenExistsYetAndCredentialsAreValid() throws IncogniaException {
String token = TokenCreationFixture.createToken();
TokenAwareDispatcher dispatcher = new TokenAwareDispatcher(token, CLIENT_ID, CLIENT_SECRET);
mockServer.setDispatcher(dispatcher);
for (int i = 0; i < 2; i++) {
TestResponseBody testResponseBody = client.doGet("api/v2/onboarding", TestResponseBody.class);
assertThat(testResponseBody.getName()).isEqualTo("my awesome name");
}
assertThat(dispatcher.getTokenRequestCount()).isEqualTo(1);
}

@Test
@DisplayName("should get a 401 error")
void testDoPost_whenNoTokenExistsYetAndCredentialsAreInvalid() {
Expand Down
30 changes: 0 additions & 30 deletions src/test/resources/get_onboarding_response.json

This file was deleted.

0 comments on commit 2a42d43

Please sign in to comment.