Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(all): Remove ignored tests #2867

Merged
merged 6 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,10 @@
import org.json.JSONObject;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;

import java.util.Collections;

import static androidx.test.core.app.ApplicationProvider.getApplicationContext;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

Expand Down Expand Up @@ -134,53 +130,6 @@ public void getRequestWithApiKey() throws JSONException, ApiException {
);
}

/**
* Test whether we can make api Rest call in IAM as auth type.
* @throws ApiException On failure to obtain a valid response from API endpoint
*/
@Test
@Ignore("Relies on an AWS account which is no longer active. Resources need to be regenerated.")
public void getRequestWithIAM() throws ApiException {
final RestOptions options = RestOptions.builder()
.addPath("/items")
.addQueryParameters(Collections.singletonMap("key", "value"))
.build();
final RestResponse response = api.get("iamAuthApi", options);
assertNotNull("Should return non-null data", response.getData());
assertTrue("Response should be successful", response.getCode().isSuccessful());
}

/**
* Test whether we can make POST request with empty body and IAM as auth type.
* @throws ApiException On failure to obtain a valid response from API endpoint
*/
@Test
@Ignore("fix in dev-preview")
public void postRequestEmptyBodyWithIAM() throws ApiException {
final RestOptions options = RestOptions.builder()
.addPath("/items")
.addBody("".getBytes())
.build();
final RestResponse response = api.post("iamAuthApi", options);
assertNotNull("Should return non-null data", response.getData());
assertTrue("Response should be successful", response.getCode().isSuccessful());
}

/**
* Test whether we can get failed response for access denied.
* @throws ApiException On failure to obtain a valid response from API endpoint
*/
@Test
@Ignore("Relies on an AWS account which is no longer active. Resources need to be regenerated.")
public void getRequestWithIAMFailedAccess() throws ApiException {
final RestOptions options = RestOptions.builder()
.addPath("/invalidPath")
.build();
final RestResponse response = api.get("iamAuthApi", options);
assertNotNull("Should return non-null data", response.getData());
assertFalse("Response should be unsuccessful", response.getCode().isSuccessful());
}

/**
* Reset all the static fields.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
import com.amplifyframework.api.ApiException;
import com.amplifyframework.api.aws.auth.DummyCredentialsProvider;
import com.amplifyframework.api.aws.sigv4.CognitoUserPoolsAuthProvider;
import com.amplifyframework.api.events.ApiChannelEventName;
import com.amplifyframework.api.events.ApiEndpointStatusChangeEvent;
import com.amplifyframework.api.graphql.GraphQLRequest;
import com.amplifyframework.api.graphql.GraphQLResponse;
import com.amplifyframework.api.graphql.PaginatedResult;
Expand All @@ -31,11 +29,8 @@
import com.amplifyframework.api.graphql.model.ModelPagination;
import com.amplifyframework.api.graphql.model.ModelQuery;
import com.amplifyframework.core.Consumer;
import com.amplifyframework.hub.HubChannel;
import com.amplifyframework.hub.HubEvent;
import com.amplifyframework.testmodels.commentsblog.BlogOwner;
import com.amplifyframework.testutils.Await;
import com.amplifyframework.testutils.HubAccumulator;
import com.amplifyframework.testutils.Latch;
import com.amplifyframework.testutils.Resources;
import com.amplifyframework.testutils.random.RandomString;
Expand All @@ -45,7 +40,6 @@
import org.json.JSONObject;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
Expand Down Expand Up @@ -233,51 +227,6 @@ public void graphQlPaginatedQueryRendersExpectedResponse() throws ApiException {
assertNotNull(actualResponse.getData().getRequestForNextResult());
}

/**
* It should be possible to perform a successful call to
* {@link AWSApiPlugin#mutate(GraphQLRequest, Consumer, Consumer)}.
* When the server returns a valid response, then the mutate methods should
* emit content via their value consumer.
* @throws ApiException If call to mutate(...) itself emits such an exception
* @throws JSONException On failure to arrange response JSON
*/
@Test
@Ignore("fix")
public void graphQlMutationGetsResponse() throws JSONException, ApiException {
HubAccumulator networkStatusObserver =
HubAccumulator.create(HubChannel.API, ApiChannelEventName.API_ENDPOINT_STATUS_CHANGED, 1)
.start();
// Arrange a response from the "server"
String expectedName = RandomString.string();
webServer.enqueue(new MockResponse().setBody(new JSONObject()
.put("data", new JSONObject()
.put("createBlogOwner", new JSONObject()
.put("name", expectedName)
)
)
.toString()
));

// Try to perform a mutation.
BlogOwner tony = BlogOwner.builder()
.name(expectedName)
.build();
GraphQLResponse<BlogOwner> actualResponse =
Await.<GraphQLResponse<BlogOwner>, ApiException>result(((onResult, onError) ->
plugin.mutate(ModelMutation.create(tony), onResult, onError)
));

// Assert that the expected response was received
assertEquals(expectedName, actualResponse.getData().getName());

// Verify that the expected hub event fired.
HubEvent<?> event = networkStatusObserver.awaitFirst();
assertNotNull(event);
assertTrue(event.getData() instanceof ApiEndpointStatusChangeEvent);
ApiEndpointStatusChangeEvent eventData = (ApiEndpointStatusChangeEvent) event.getData();
assertEquals(ApiEndpointStatusChangeEvent.ApiEndpointStatus.REACHABLE, eventData.getCurrentStatus());
}

/**
* When the server returns a client error code in response to calling
* {@link AWSApiPlugin#mutate(GraphQLRequest, Consumer, Consumer)}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import androidx.test.core.app.ApplicationProvider
import com.amplifyframework.AmplifyException
import com.amplifyframework.api.aws.AWSApiPlugin
import com.amplifyframework.api.rest.RestOptions
import com.amplifyframework.auth.AuthProvider
import com.amplifyframework.auth.AuthUserAttribute
import com.amplifyframework.auth.AuthUserAttributeKey
import com.amplifyframework.auth.cognito.options.AWSCognitoAuthSignInOptions
Expand All @@ -44,7 +43,6 @@ import org.junit.Assert.assertTrue
import org.junit.Assert.fail
import org.junit.Before
import org.junit.BeforeClass
import org.junit.Ignore
import org.junit.Test

class AuthCanaryTest {
Expand Down Expand Up @@ -137,19 +135,6 @@ class AuthCanaryTest {
assertTrue(latch.await(TIMEOUT_S, TimeUnit.SECONDS))
}

@Test
@Ignore("Sending sign up confirmation code is disabled in the user pool.")
fun resendSignUpCode() {
signUpUser(tempUsername, tempPassword)
val latch = CountDownLatch(1)
Amplify.Auth.resendSignUpCode(
tempUsername,
{ latch.countDown() },
{ fail("Failed to confirm sign up: $it") }
)
assertTrue(latch.await(TIMEOUT_S, TimeUnit.SECONDS))
}

@Test
fun signIn() {
val latch = CountDownLatch(1)
Expand All @@ -170,14 +155,6 @@ class AuthCanaryTest {
assertTrue(latch.await(TIMEOUT_S, TimeUnit.SECONDS))
}

@Test
@Ignore("Test will require UI. Implementation is TODO.")
fun signInWithWebUI() { }

@Test
@Ignore("Test will require UI. Implementation is TODO.")
fun signInWithSocialWebUi() { }

// Test requires confirmation code, testing onError call
@Test
fun confirmSignIn() {
Expand Down Expand Up @@ -215,7 +192,6 @@ class AuthCanaryTest {
}

@Test
@Ignore("Test fails with missing device key error. Ignoring test pending investigation.")
fun rememberDevice() {
signInUser(username, password)
val latch = CountDownLatch(1)
Expand All @@ -227,7 +203,6 @@ class AuthCanaryTest {
}

@Test
@Ignore("Test fails with missing device key error. Ignoring test pending investigation.")
fun forgetDevice() {
signInUser(username, password)
val latch = CountDownLatch(1)
Expand All @@ -249,21 +224,6 @@ class AuthCanaryTest {
assertTrue(latch.await(TIMEOUT_S, TimeUnit.SECONDS))
}

@Test
@Ignore("Test requires a temporary user with a confirmed email.")
fun resetPassword() {
signUpUser(tempUsername, tempPassword)
confirmTemporaryUserSignUp(tempUsername)
signInUser(tempUsername, tempPassword)
val latch = CountDownLatch(1)
Amplify.Auth.resetPassword(
tempUsername,
{ latch.countDown() },
{ fail("Reset password failed: $it") }
)
assertTrue(latch.await(TIMEOUT_S, TimeUnit.SECONDS))
}

// Test requires confirmation code, testing onError call
@Test
fun confirmResetPassword() {
Expand Down Expand Up @@ -345,19 +305,6 @@ class AuthCanaryTest {
assertTrue(latch.await(TIMEOUT_S, TimeUnit.SECONDS))
}

@Test
@Ignore("Test fails when run too frequently due to resend confirmation code limit exceeded.")
fun resendUserAttributeConfirmationCode() {
signInUser(username, password)
val latch = CountDownLatch(1)
Amplify.Auth.resendUserAttributeConfirmationCode(
AuthUserAttributeKey.email(),
{ latch.countDown() },
{ fail("Failed to resend code: $it") }
)
assertTrue(latch.await(TIMEOUT_S, TimeUnit.SECONDS))
}

@Test
fun getCurrentUser() {
signInUser(username, password)
Expand Down Expand Up @@ -438,32 +385,6 @@ class AuthCanaryTest {
assertTrue(latch.await(TIMEOUT_S, TimeUnit.SECONDS))
}

@Test
@Ignore("OAuth flows not set up.")
fun testFederateToIdentityPool() {
signInUser(username, password)
val latch = CountDownLatch(1)
auth.federateToIdentityPool(
"YOUR_TOKEN",
AuthProvider.facebook(),
{ latch.countDown() },
{ fail("Failed to federate to Identity Pool: $it") }
)
assertTrue(latch.await(TIMEOUT_S, TimeUnit.SECONDS))
}

@Test
@Ignore("OAuth flows not set up.")
fun testClearFederateToIdentityPool() {
signInUser(username, password)
val latch = CountDownLatch(1)
auth.clearFederationToIdentityPool(
{ latch.countDown() },
{ fail("Failed to clear federation: $it") }
)
assertTrue(latch.await(TIMEOUT_S, TimeUnit.SECONDS))
}

private fun signUpUser(user: String, pass: String) {
val latch = CountDownLatch(1)
val options = AuthSignUpOptions.builder()
Expand Down
Loading
Loading