Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
fd3dd9d
Adding the sync APIs for FirebaseAuth
hiranya911 Feb 22, 2018
ac3453b
Added more tests; Added sync APIs for FirebaseMessaging
hiranya911 Feb 22, 2018
ded167e
Removing Task references from database, iid and fcm APIs
hiranya911 Feb 22, 2018
765f209
Fixing a typo
hiranya911 Feb 26, 2018
01ce79e
Minor code clean up
hiranya911 Mar 1, 2018
3913688
Merged with master (auth unit test improvements)
hiranya911 Mar 2, 2018
d5ec1c3
Updated javadocs; Renamed internal helpers of FirebaseMessaging for c…
hiranya911 Mar 8, 2018
f8f33b4
Removed the deprecated FirebaseCredential API (#149)
hiranya911 Mar 9, 2018
27eddb6
Removing the Task API (#152)
hiranya911 Mar 12, 2018
edd825e
Dropping Support for App Engine Java 7 Runtime (#153)
hiranya911 Mar 20, 2018
559ce44
Removing Deprecated LogWrapper API (#154)
hiranya911 Mar 23, 2018
3979c02
Merged with master
hiranya911 Mar 29, 2018
ef036bb
merged with master
hiranya911 Apr 14, 2018
0523bf3
Initial code for the importUsers() API
hiranya911 Apr 18, 2018
0db88c5
Added documentation and more tests
hiranya911 Apr 19, 2018
fe3cc03
Added integration tests; Scrypt hash; more documentation
hiranya911 Apr 19, 2018
46e51ab
Added more tests
hiranya911 Apr 19, 2018
5ede505
Merge branch 'master' into v6
hiranya911 Apr 19, 2018
efc9016
updated test
hiranya911 Apr 24, 2018
dbc1492
Merged with master
hiranya911 May 3, 2018
0633d37
Merged with v6
hiranya911 May 4, 2018
2514703
Adding other hash types
hiranya911 May 4, 2018
ebe905c
Added the remaining hash algorithms
hiranya911 May 4, 2018
1182576
Renamed to ImportUserRecord
hiranya911 May 4, 2018
421a86c
Updated documentation
hiranya911 May 5, 2018
7b085df
Merged with master
hiranya911 May 8, 2018
501faf8
Some minor cleanup
hiranya911 May 8, 2018
dccc454
Updated documentation
hiranya911 May 11, 2018
a4cf116
Updated documentation; Made hash required in UserImportOptions; Other…
hiranya911 May 17, 2018
9130ab2
Renamed BasicHash to RepeatableHash; Made rounds range test configurable
hiranya911 May 22, 2018
3f30183
Added javadoc comment
hiranya911 May 22, 2018
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
Prev Previous commit
Next Next commit
Renamed to ImportUserRecord
  • Loading branch information
hiranya911 committed May 4, 2018
commit 1182576bb666430a5e2fe4e4ca2c075cd466a200
2 changes: 1 addition & 1 deletion src/main/java/com/google/firebase/auth/ErrorInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import java.util.List;

/**
* Represents an error encountered while importing a {@link UserImportRecord}.
* Represents an error encountered while importing an {@link ImportUserRecord}.
*/
public final class ErrorInfo {

Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/google/firebase/auth/FirebaseAuth.java
Original file line number Diff line number Diff line change
Expand Up @@ -854,26 +854,26 @@ protected Void execute() throws FirebaseAuthException {
};
}

public UserImportResult importUsers(List<UserImportRecord> users) throws FirebaseAuthException {
public UserImportResult importUsers(List<ImportUserRecord> users) throws FirebaseAuthException {
return importUsers(users, null);
}

public UserImportResult importUsers(List<UserImportRecord> users,
public UserImportResult importUsers(List<ImportUserRecord> users,
@Nullable UserImportOptions options) throws FirebaseAuthException {
return importUsersOp(users, options).call();
}

public ApiFuture<UserImportResult> importUsersAsync(List<UserImportRecord> users) {
public ApiFuture<UserImportResult> importUsersAsync(List<ImportUserRecord> users) {
return importUsersAsync(users, null);
}

public ApiFuture<UserImportResult> importUsersAsync(List<UserImportRecord> users,
public ApiFuture<UserImportResult> importUsersAsync(List<ImportUserRecord> users,
@Nullable UserImportOptions options) {
return importUsersOp(users, options).callAsync(firebaseApp);
}

private CallableOperation<UserImportResult, FirebaseAuthException> importUsersOp(
List<UserImportRecord> users, UserImportOptions options) {
List<ImportUserRecord> users, UserImportOptions options) {
checkNotDestroyed();
final UserImportRequest request = new UserImportRequest(users, options, jsonFactory);
return new CallableOperation<UserImportResult, FirebaseAuthException>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,15 +275,15 @@ static class UserImportRequest extends GenericJson {
@Key("users")
private final List<Map<String, Object>> users;

UserImportRequest(List<UserImportRecord> users, UserImportOptions options,
UserImportRequest(List<ImportUserRecord> users, UserImportOptions options,
JsonFactory jsonFactory) {
checkArgument(users != null && !users.isEmpty(), "users must not be null or empty");
checkArgument(users.size() <= FirebaseUserManager.MAX_IMPORT_USERS,
"users list must not contain more than %s items", FirebaseUserManager.MAX_IMPORT_USERS);

boolean hasPassword = false;
ImmutableList.Builder<Map<String, Object>> usersBuilder = ImmutableList.builder();
for (UserImportRecord user : users) {
for (ImportUserRecord user : users) {
if (user.hasPassword()) {
hasPassword = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@
* {@link FirebaseAuth#importUsersAsync(List, UserImportOptions)} API. Must contain at least a
* uid string.
*/
public final class UserImportRecord {
public final class ImportUserRecord {

private final Map<String, Object> properties;

private UserImportRecord(Map<String, Object> properties) {
private ImportUserRecord(Map<String, Object> properties) {
this.properties = ImmutableMap.copyOf(properties);
}

Expand All @@ -56,9 +56,9 @@ boolean hasPassword() {
}

/**
* Creates a new {@link UserImportRecord.Builder}.
* Creates a new {@link ImportUserRecord.Builder}.
*
* @return A {@link UserImportRecord.Builder} instance.
* @return A {@link ImportUserRecord.Builder} instance.
*/
public static Builder builder() {
return new Builder();
Expand Down Expand Up @@ -241,11 +241,11 @@ public Builder putAllCustomClaims(Map<String, Object> customClaims) {
}

/**
* Builds a new {@link UserImportRecord}.
* Builds a new {@link ImportUserRecord}.
*
* @return A non-null {@link UserImportRecord}.
* @return A non-null {@link ImportUserRecord}.
*/
public UserImportRecord build() {
public ImportUserRecord build() {
Map<String, Object> properties = new HashMap<>();
UserRecord.checkUid(uid);
properties.put("localId", uid);
Expand Down Expand Up @@ -293,7 +293,7 @@ public UserImportRecord build() {
if (disabled != null) {
properties.put("disabled", disabled);
}
return new UserImportRecord(properties);
return new ImportUserRecord(properties);
}
}
}
4 changes: 2 additions & 2 deletions src/main/java/com/google/firebase/auth/UserImportOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ private Builder() {}

/**
* Sets the algorithm used to hash user passwords. This is required
* when at least one of the {@link UserImportRecord} instances being imported has a password
* hash. See {@link UserImportRecord.Builder#setPasswordHash(byte[])}.
* when at least one of the {@link ImportUserRecord} instances being imported has a password
* hash. See {@link ImportUserRecord.Builder#setPasswordHash(byte[])}.
*
* @param hash A {@link UserImportHash}.
* @return This builder.
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/com/google/firebase/auth/FirebaseAuthIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ public void testImportUsers() throws Exception {
final String randomId = UUID.randomUUID().toString().replaceAll("-", "");
final String userEmail = ("test" + randomId.substring(0, 12) + "@example."
+ randomId.substring(12) + ".com").toLowerCase();
UserImportRecord user = UserImportRecord.builder()
ImportUserRecord user = ImportUserRecord.builder()
.setUid(randomId)
.setEmail(userEmail)
.build();
Expand All @@ -467,7 +467,7 @@ public void testImportUsersWithPassword() throws Exception {
+ randomId.substring(12) + ".com").toLowerCase();
final byte[] passwordHash = BaseEncoding.base64().decode(
"V358E8LdWJXAO7muq0CufVpEOXaj8aFiC7T/rcaGieN04q/ZPJ08WhJEHGjj9lz/2TT+/86N5VjVoc5DdBhBiw==");
UserImportRecord user = UserImportRecord.builder()
ImportUserRecord user = ImportUserRecord.builder()
.setUid(randomId)
.setEmail(userEmail)
.setPasswordHash(passwordHash)
Expand Down
36 changes: 16 additions & 20 deletions src/test/java/com/google/firebase/auth/FirebaseUserManagerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -255,14 +255,10 @@ public void testDeleteUser() throws Exception {
@Test
public void testImportUsers() throws Exception {
TestResponseInterceptor interceptor = initializeAppForUserManagement("{}");
UserImportRecord user1 = UserImportRecord.builder()
.setUid("user1")
.build();
UserImportRecord user2 = UserImportRecord.builder()
.setUid("user2")
.build();
ImportUserRecord user1 = ImportUserRecord.builder().setUid("user1").build();
ImportUserRecord user2 = ImportUserRecord.builder().setUid("user2").build();

List<UserImportRecord> users = ImmutableList.of(user1, user2);
List<ImportUserRecord> users = ImmutableList.of(user1, user2);
UserImportResult result = FirebaseAuth.getInstance().importUsersAsync(users, null).get();
checkRequestHeaders(interceptor);
assertEquals(2, result.getSuccessCount());
Expand All @@ -285,17 +281,17 @@ public void testImportUsers() throws Exception {
public void testImportUsersError() throws Exception {
TestResponseInterceptor interceptor = initializeAppForUserManagement(
TestUtils.loadResource("importUsersError.json"));
UserImportRecord user1 = UserImportRecord.builder()
ImportUserRecord user1 = ImportUserRecord.builder()
.setUid("user1")
.build();
UserImportRecord user2 = UserImportRecord.builder()
ImportUserRecord user2 = ImportUserRecord.builder()
.setUid("user2")
.build();
UserImportRecord user3 = UserImportRecord.builder()
ImportUserRecord user3 = ImportUserRecord.builder()
.setUid("user3")
.build();

List<UserImportRecord> users = ImmutableList.of(user1, user2, user3);
List<ImportUserRecord> users = ImmutableList.of(user1, user2, user3);
UserImportResult result = FirebaseAuth.getInstance().importUsersAsync(users, null).get();
checkRequestHeaders(interceptor);
assertEquals(1, result.getSuccessCount());
Expand Down Expand Up @@ -325,15 +321,15 @@ public void testImportUsersError() throws Exception {
@Test
public void testImportUsersWithHash() throws Exception {
TestResponseInterceptor interceptor = initializeAppForUserManagement("{}");
UserImportRecord user1 = UserImportRecord.builder()
ImportUserRecord user1 = ImportUserRecord.builder()
.setUid("user1")
.build();
UserImportRecord user2 = UserImportRecord.builder()
ImportUserRecord user2 = ImportUserRecord.builder()
.setUid("user2")
.setPasswordHash("password".getBytes())
.build();

List<UserImportRecord> users = ImmutableList.of(user1, user2);
List<ImportUserRecord> users = ImmutableList.of(user1, user2);
UserImportHash hash = new UserImportHash("MOCK_HASH") {
@Override
protected Map<String, Object> getOptions() {
Expand Down Expand Up @@ -365,15 +361,15 @@ protected Map<String, Object> getOptions() {
@Test
public void testImportUsersMissingHash() {
initializeAppForUserManagement();
UserImportRecord user1 = UserImportRecord.builder()
ImportUserRecord user1 = ImportUserRecord.builder()
.setUid("user1")
.build();
UserImportRecord user2 = UserImportRecord.builder()
ImportUserRecord user2 = ImportUserRecord.builder()
.setUid("user2")
.setPasswordHash("password".getBytes())
.build();

List<UserImportRecord> users = ImmutableList.of(user1, user2);
List<ImportUserRecord> users = ImmutableList.of(user1, user2);
try {
FirebaseAuth.getInstance().importUsersAsync(users);
fail("No error thrown for missing hash option");
Expand All @@ -386,7 +382,7 @@ public void testImportUsersMissingHash() {
public void testImportUsersEmptyList() {
initializeAppForUserManagement();
try {
FirebaseAuth.getInstance().importUsersAsync(ImmutableList.<UserImportRecord>of());
FirebaseAuth.getInstance().importUsersAsync(ImmutableList.<ImportUserRecord>of());
fail("No error thrown for empty user list");
} catch (IllegalArgumentException expected) {
// expected
Expand All @@ -396,9 +392,9 @@ public void testImportUsersEmptyList() {
@Test
public void testImportUsersLargeList() {
initializeAppForUserManagement();
ImmutableList.Builder<UserImportRecord> users = ImmutableList.builder();
ImmutableList.Builder<ImportUserRecord> users = ImmutableList.builder();
for (int i = 0; i < 1001; i++) {
users.add(UserImportRecord.builder().setUid("test" + i).build());
users.add(ImportUserRecord.builder().setUid("test" + i).build());
}
try {
FirebaseAuth.getInstance().importUsersAsync(users.build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@
import java.util.Map;
import org.junit.Test;

public class UserImportRecordTest {
public class ImportUserRecordTest {

private static final JsonFactory JSON_FACTORY = Utils.getDefaultJsonFactory();

@Test
public void testUidOnlyRecord() {
UserImportRecord record = UserImportRecord.builder()
ImportUserRecord record = ImportUserRecord.builder()
.setUid("testuid")
.build();
assertEquals(ImmutableMap.of("localId", "testuid"), record.getProperties(JSON_FACTORY));
Expand All @@ -56,7 +56,7 @@ public void testAllProperties() throws IOException {
.setUid("testuid")
.setProviderId("test.com")
.build();
UserImportRecord record = UserImportRecord.builder()
ImportUserRecord record = ImportUserRecord.builder()
.setUid("testuid")
.setEmail("[email protected]")
.setDisplayName("Test User")
Expand Down Expand Up @@ -100,30 +100,30 @@ public void testAllProperties() throws IOException {

@Test(expected = IllegalArgumentException.class)
public void testInvalidUid() {
UserImportRecord.builder()
ImportUserRecord.builder()
.setUid(Strings.repeat("a", 129))
.build();
}

@Test(expected = IllegalArgumentException.class)
public void testInvalidEmail() {
UserImportRecord.builder()
ImportUserRecord.builder()
.setUid("test")
.setEmail("not-an-email")
.build();
}

@Test(expected = IllegalArgumentException.class)
public void testInvalidPhotoUrl() {
UserImportRecord.builder()
ImportUserRecord.builder()
.setUid("test")
.setPhotoUrl("not a url")
.build();
}

@Test(expected = IllegalArgumentException.class)
public void testInvalidPhoneNumber() {
UserImportRecord.builder()
ImportUserRecord.builder()
.setUid("test")
.setPhoneNumber("not a phone number")
.build();
Expand All @@ -132,7 +132,7 @@ public void testInvalidPhoneNumber() {
@Test
public void testNullUserProvider() {
try {
UserImportRecord.builder()
ImportUserRecord.builder()
.setUid("test")
.addUserProvider(null).build();
fail("No error thrown for null provider");
Expand All @@ -143,7 +143,7 @@ public void testNullUserProvider() {
try {
List<UserProvider> providers = new ArrayList<>();
providers.add(null);
UserImportRecord.builder()
ImportUserRecord.builder()
.setUid("test")
.addAllUserProviders(providers).build();
fail("No error thrown for null provider");
Expand All @@ -155,7 +155,7 @@ public void testNullUserProvider() {
@Test
public void testNullOrEmptyCustomClaims() {
try {
UserImportRecord.builder()
ImportUserRecord.builder()
.setUid("test")
.putCustomClaim("foo", null).build();
fail("No error thrown for null claim value");
Expand All @@ -164,7 +164,7 @@ public void testNullOrEmptyCustomClaims() {
}

try {
UserImportRecord.builder()
ImportUserRecord.builder()
.setUid("test")
.putCustomClaim(null, "foo").build();
fail("No error thrown for null claim name");
Expand All @@ -173,7 +173,7 @@ public void testNullOrEmptyCustomClaims() {
}

try {
UserImportRecord.builder()
ImportUserRecord.builder()
.setUid("test")
.putCustomClaim("", "foo").build();
fail("No error thrown for empty claim name");
Expand All @@ -186,7 +186,7 @@ public void testNullOrEmptyCustomClaims() {
public void testReservedClaims() {
for (String key : FirebaseUserManager.RESERVED_CLAIMS) {
try {
UserImportRecord.builder()
ImportUserRecord.builder()
.setUid("test")
.putCustomClaim(key, "foo").build();
fail("No error thrown for reserved claim");
Expand All @@ -198,7 +198,7 @@ public void testReservedClaims() {

@Test
public void testLargeCustomClaims() {
UserImportRecord user = UserImportRecord.builder()
ImportUserRecord user = ImportUserRecord.builder()
.setUid("test")
.putCustomClaim("foo", Strings.repeat("a", 1000))
.build();
Expand Down