Skip to content
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
12 changes: 12 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,13 @@
<configuration>
<source>1.7</source>
<target>1.7</target>
<annotationProcessorPaths>
<path>
<groupId>com.google.auto.value</groupId>
<artifactId>auto-value</artifactId>
<version>1.7</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -426,6 +433,11 @@
</dependency>

<!-- Utilities -->
<dependency>
<groupId>com.google.auto.value</groupId>
<artifactId>auto-value-annotations</artifactId>
<version>1.7</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
Expand Down
138 changes: 138 additions & 0 deletions src/main/java/com/google/firebase/auth/Tenant.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
/*
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.google.firebase.auth;

import com.google.api.client.util.Key;
import com.google.auto.value.AutoValue;

/**
* Contains metadata associated with a Firebase tenant.
*
* <p>Instances of this class are immutable and thread safe.
Comment thread
micahstairs marked this conversation as resolved.
*/
public final class Tenant {

@Key("tenantId")
private String tenantId;

@Key("displayName")
private String displayName;

@Key("allowPasswordSignup")
private String passwordSignInAllowed;

@Key("enableEmailLinkSignin")
private String emailLinkSignInEnabled;

/**
* Class used to hold the information needs to make a tenant create request.
*/
@AutoValue
public abstract static class CreateRequest {

/**
* Returns the display name of this tenant.
*
* @return a non-empty display name string.
*/
public abstract String getDisplayName();

/**
* Returns whether to allow email/password user authentication.
*
* @return true if a user can be authenticated using an email and password, and false otherwise.
*/
public abstract boolean isPasswordSignInAllowed();

/**
* Returns whether to enable email link user authentication.
*
* @return true if a user can be authenticated using an email link, and false otherwise.
*/
public abstract boolean isEmailLinkSignInEnabled();

/**
* Returns a builder for a tenant create request.
*/
public static Builder newBuilder() {
return new AutoValue_Tenant_CreateRequest.Builder();
}

/**
* Builder class used to construct a create request.
*/
@AutoValue.Builder
abstract static class Builder {
public abstract Builder setDisplayName(String displayName);

public abstract Builder setPasswordSignInAllowed(boolean allowPasswordSignIn);

public abstract Builder setEmailLinkSignInEnabled(boolean enableEmailLinkSignIn);

public abstract CreateRequest build();
}
}

/**
* Class used to hold the information needs to make a tenant update request.
*/
@AutoValue
public abstract static class UpdateRequest {

/**
* Returns the display name of this tenant.
*
* @return a non-empty display name string.
*/
public abstract String getDisplayName();

/**
* Returns whether to allow email/password user authentication.
*
* @return true if a user can be authenticated using an email and password, and false otherwise.
*/
public abstract boolean isPasswordSignInAllowed();

/**
* Returns whether to enable email link user authentication.
*
* @return true if a user can be authenticated using an email link, and false otherwise.
*/
public abstract boolean isEmailLinkSignInEnabled();

/**
* Returns a builder for a tenant update request.
*/
public static Builder newBuilder() {
return new AutoValue_Tenant_UpdateRequest.Builder();
}

/**
* Builder class used to construct a update request.
*/
@AutoValue.Builder
abstract static class Builder {
public abstract Builder setDisplayName(String displayName);

public abstract Builder setPasswordSignInAllowed(boolean allowPasswordSignIn);

public abstract Builder setEmailLinkSignInEnabled(boolean enableEmailLinkSignIn);

public abstract UpdateRequest build();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import static org.junit.Assert.assertSame;
import static org.junit.Assert.fail;

import com.google.auth.oauth2.GoogleCredentials;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
Expand All @@ -33,11 +34,12 @@
import com.google.firebase.database.util.EmulatorHelper;
import com.google.firebase.testing.ServiceAccount;
import com.google.firebase.testing.TestUtils;
import java.io.IOException;
import java.util.List;
import org.junit.Test;

public class FirebaseDatabaseTest {

private static final FirebaseOptions firebaseOptions =
new FirebaseOptions.Builder()
.setCredentials(TestUtils.getCertCredential(ServiceAccount.EDITOR.asStream()))
Expand Down Expand Up @@ -198,7 +200,7 @@ public void testInitAfterAppDelete() {
}

@Test
public void testDbUrlIsEmulatorUrlWhenSettingOptionsManually() {
public void testDbUrlIsEmulatorUrlWhenSettingOptionsManually() throws IOException {

List<CustomTestCase> testCases = ImmutableList.of(
// cases where the env var is ignored because the supplied DB URL is a valid emulator URL
Expand Down Expand Up @@ -235,7 +237,7 @@ public void testDbUrlIsEmulatorUrlWhenSettingOptionsManually() {
}

@Test
public void testDbUrlIsEmulatorUrlForDbRefWithPath() {
public void testDbUrlIsEmulatorUrlForDbRefWithPath() throws IOException {

List<CustomTestCase> testCases = ImmutableList.of(
new CustomTestCase("http://my-custom-hosted-emulator.com:80?ns=dummy-ns",
Expand Down