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

Update federatedSignIn to immediately contact service; refresh Google… #855

Merged
merged 1 commit into from
Apr 2, 2019
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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

## [Release 2.12.7](https://github.com/aws/aws-sdk-android/releases/tag/release_v2.12.7)

### Enhancements

* **AWS Mobile Client**
* Updated `federatedSignIn()` method to contact the service immediately to validate tokens. The `signIn()` method will also attempt to federated immediately when applicable. See [issue #800](https://github.com/aws-amplify/aws-sdk-android/issues/800)
* Fix Google or Facebook refresh when using the drop-in UI. See [issue #809](https://github.com/aws-amplify/aws-sdk-android/issues/809), [issue #700](https://github.com/aws-amplify/aws-sdk-android/issues/700)
* Annotated methods that are designed to be called from UI thread or from a background thread with @AnyThread and @WorkerThread, respectively.

### Bug Fixes

* **AWS Core**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ public class GoogleSignInProvider implements SignInProvider, SignInPermissionsHa

/**
* Constructor. Builds the Google Api Client.
* @param context context.
* @param configuration the AWS Configuration.
* @param activityContext context.
* @param awsConfig the AWS Configuration.
*/
@Override
public void initialize(@NonNull final Context activityContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.amazonaws.services.cognitoidentityprovider.AmazonCognitoIdentityProvider;
import com.amazonaws.services.cognitoidentityprovider.AmazonCognitoIdentityProviderClient;
import com.amazonaws.services.cognitoidentityprovider.model.AdminConfirmSignUpRequest;
import com.amazonaws.services.cognitoidentityprovider.model.AdminDeleteUserRequest;
import com.amazonaws.services.cognitoidentityprovider.model.AdminGetDeviceRequest;
import com.amazonaws.services.cognitoidentityprovider.model.AdminGetDeviceResult;
import com.amazonaws.services.cognitoidentityprovider.model.AttributeType;
Expand All @@ -34,6 +35,7 @@
import com.amazonaws.services.cognitoidentityprovider.model.ListUsersRequest;
import com.amazonaws.services.cognitoidentityprovider.model.ListUsersResult;
import com.amazonaws.services.cognitoidentityprovider.model.ResourceNotFoundException;
import com.amazonaws.services.cognitoidentityprovider.model.UserNotConfirmedException;
import com.amazonaws.services.cognitoidentityprovider.model.UserType;
import com.amazonaws.services.cognitoidentityprovider.model.UsernameExistsException;

Expand Down Expand Up @@ -137,16 +139,29 @@ public static void deleteAllUsers(final String userpoolId) {
// This user is saved to test the identity id permanence
continue;
}
try {
Log.d(TAG, "deleteAllUsers: " + user.getUsername());
AWSMobileClient.getInstance().signIn(user.getUsername(), PASSWORD, null);
DeleteUserRequest deleteUserRequest = new DeleteUserRequest()
.withAccessToken(AWSMobileClient.getInstance().getTokens().getAccessToken().getTokenString());
getUserpoolLL().deleteUser(deleteUserRequest);
AWSMobileClient.getInstance().signOut();
} catch (Exception e) {
Log.e(TAG, "deleteAllUsers: Some error trying to delete user", e);
}
boolean retryConfirmSignUp = false;
do {
try {
Log.d(TAG, "deleteAllUsers: " + user.getUsername());
getUserpoolLL().adminDeleteUser(new AdminDeleteUserRequest().withUsername(user.getUsername()).withUserPoolId(userpoolId));
} catch (UserNotConfirmedException e) {
if (!retryConfirmSignUp) {
AdminConfirmSignUpRequest adminConfirmSignUpRequest = new AdminConfirmSignUpRequest();
adminConfirmSignUpRequest.withUsername(user.getUsername()).withUserPoolId(userpoolId);
getUserpoolLL().adminConfirmSignUp(adminConfirmSignUpRequest);
retryConfirmSignUp = true;
try {
Thread.sleep(10);
} catch (InterruptedException e1) {
e1.printStackTrace();
}
} else {
retryConfirmSignUp = false;
}
} catch (Exception e) {
Log.e(TAG, "deleteAllUsers: Some error trying to delete user", e);
}
} while (retryConfirmSignUp);
}
} while (listUsersResult.getPaginationToken() != null);
}
Expand Down Expand Up @@ -428,8 +443,12 @@ public void testSignInWrongPassword() throws Exception {
}

@Test
public void testFederate() {

public void testFederatedSignInFail() {
try {
auth.federatedSignIn(IdentityProvider.GOOGLE.toString(), "fakeToken");
} catch (Exception e) {
assertEquals("Error in federating the token.", e.getMessage());
}
}

// Changing a password tends to have a rate limit that exceeds test timeout
Expand Down
Loading