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

Remove tenant level mobileLinksConfig CRUD. #2731

Merged
merged 2 commits into from
Oct 22, 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
2 changes: 0 additions & 2 deletions etc/firebase-admin.auth.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,6 @@ export class Tenant {
readonly displayName?: string;
readonly emailPrivacyConfig?: EmailPrivacyConfig;
get emailSignInConfig(): EmailSignInProviderConfig | undefined;
readonly mobileLinksConfig?: MobileLinksConfig;
get multiFactorConfig(): MultiFactorConfig | undefined;
readonly passwordPolicyConfig?: PasswordPolicyConfig;
get recaptchaConfig(): RecaptchaConfig | undefined;
Expand Down Expand Up @@ -1032,7 +1031,6 @@ export interface UpdateTenantRequest {
displayName?: string;
emailPrivacyConfig?: EmailPrivacyConfig;
emailSignInConfig?: EmailSignInProviderConfig;
mobileLinksConfig?: MobileLinksConfig;
multiFactorConfig?: MultiFactorConfig;
passwordPolicyConfig?: PasswordPolicyConfig;
recaptchaConfig?: RecaptchaConfig;
Expand Down
28 changes: 0 additions & 28 deletions src/auth/tenant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import {
MultiFactorAuthConfig, SmsRegionConfig, SmsRegionsAuthConfig, RecaptchaAuthConfig, RecaptchaConfig,
PasswordPolicyConfig,
PasswordPolicyAuthConfig, PasswordPolicyAuthServerConfig, EmailPrivacyConfig, EmailPrivacyAuthConfig,
MobileLinksConfig, MobileLinksAuthConfig
} from './auth-config';

/**
Expand Down Expand Up @@ -78,11 +77,6 @@ export interface UpdateTenantRequest {
* The email privacy configuration for the tenant
*/
emailPrivacyConfig?: EmailPrivacyConfig;

/**
* The mobile links configuration for the project
*/
mobileLinksConfig?: MobileLinksConfig;
}

/**
Expand All @@ -101,7 +95,6 @@ export interface TenantOptionsServerRequest extends EmailSignInConfigServerReque
recaptchaConfig?: RecaptchaConfig;
passwordPolicyConfig?: PasswordPolicyAuthServerConfig;
emailPrivacyConfig?: EmailPrivacyConfig;
mobileLinksConfig?: MobileLinksConfig;
}

/** The tenant server response interface. */
Expand All @@ -117,7 +110,6 @@ export interface TenantServerResponse {
recaptchaConfig? : RecaptchaConfig;
passwordPolicyConfig?: PasswordPolicyAuthServerConfig;
emailPrivacyConfig?: EmailPrivacyConfig;
mobileLinksConfig?: MobileLinksConfig;
}

/**
Expand Down Expand Up @@ -183,11 +175,6 @@ export class Tenant {
* The email privacy configuration for the tenant
*/
public readonly emailPrivacyConfig?: EmailPrivacyConfig;
/**
* The mobile links configuration for the tenant
*/
public readonly mobileLinksConfig?: MobileLinksConfig


/**
* Builds the corresponding server request for a TenantOptions object.
Expand Down Expand Up @@ -230,9 +217,6 @@ export class Tenant {
if (typeof tenantOptions.emailPrivacyConfig !== 'undefined') {
request.emailPrivacyConfig = tenantOptions.emailPrivacyConfig;
}
if (typeof tenantOptions.mobileLinksConfig !== 'undefined') {
request.mobileLinksConfig = tenantOptions.mobileLinksConfig;
}
return request;
}

Expand Down Expand Up @@ -270,7 +254,6 @@ export class Tenant {
recaptchaConfig: true,
passwordPolicyConfig: true,
emailPrivacyConfig: true,
mobileLinksConfig: true,
};
const label = createRequest ? 'CreateTenantRequest' : 'UpdateTenantRequest';
if (!validator.isNonNullObject(request)) {
Expand Down Expand Up @@ -334,10 +317,6 @@ export class Tenant {
if (typeof request.emailPrivacyConfig !== 'undefined') {
EmailPrivacyAuthConfig.validate(request.emailPrivacyConfig);
}
// Validate Mobile Links Config if provided.
if (typeof request.mobileLinksConfig !== 'undefined') {
MobileLinksAuthConfig.validate(request.mobileLinksConfig);
}
}

/**
Expand Down Expand Up @@ -384,9 +363,6 @@ export class Tenant {
if (typeof response.emailPrivacyConfig !== 'undefined') {
this.emailPrivacyConfig = deepCopy(response.emailPrivacyConfig);
}
if (typeof response.mobileLinksConfig !== 'undefined') {
this.mobileLinksConfig = deepCopy(response.mobileLinksConfig);
}
}

/**
Expand Down Expand Up @@ -427,7 +403,6 @@ export class Tenant {
recaptchaConfig: this.recaptchaConfig_?.toJSON(),
passwordPolicyConfig: deepCopy(this.passwordPolicyConfig),
emailPrivacyConfig: deepCopy(this.emailPrivacyConfig),
mobileLinksConfig: deepCopy(this.mobileLinksConfig),
};
if (typeof json.multiFactorConfig === 'undefined') {
delete json.multiFactorConfig;
Expand All @@ -447,9 +422,6 @@ export class Tenant {
if (typeof json.emailPrivacyConfig === 'undefined') {
delete json.emailPrivacyConfig;
}
if (typeof json.mobileLinksConfig === 'undefined') {
delete json.mobileLinksConfig;
}
return json;
}
}
Expand Down
56 changes: 0 additions & 56 deletions test/unit/auth/tenant.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,6 @@ describe('Tenant', () => {
emailPrivacyConfig: {
enableImprovedEmailPrivacy: true,
},
mobileLinksConfig: {
domain: 'HOSTING_DOMAIN'
},
};

const clientRequest: UpdateTenantRequest = {
Expand Down Expand Up @@ -135,9 +132,6 @@ describe('Tenant', () => {
emailPrivacyConfig: {
enableImprovedEmailPrivacy: true,
},
mobileLinksConfig: {
domain: 'HOSTING_DOMAIN'
},
};

const serverRequestWithoutMfa: TenantServerResponse = {
Expand All @@ -149,9 +143,6 @@ describe('Tenant', () => {
emailPrivacyConfig: {
enableImprovedEmailPrivacy: true,
},
mobileLinksConfig: {
domain: 'HOSTING_DOMAIN'
},
};

const clientRequestWithoutMfa: UpdateTenantRequest = {
Expand All @@ -164,9 +155,6 @@ describe('Tenant', () => {
emailPrivacyConfig: {
enableImprovedEmailPrivacy: true,
},
mobileLinksConfig: {
domain: 'HOSTING_DOMAIN'
},
};

const clientRequestWithRecaptcha: UpdateTenantRequest = {
Expand Down Expand Up @@ -231,9 +219,6 @@ describe('Tenant', () => {
emailPrivacyConfig: {
enableImprovedEmailPrivacy: true,
},
mobileLinksConfig: {
domain: 'HOSTING_DOMAIN'
},
};

describe('buildServerRequest()', () => {
Expand Down Expand Up @@ -599,22 +584,6 @@ describe('Tenant', () => {
}).to.throw('"EmailPrivacyConfig.enableImprovedEmailPrivacy" must be a valid boolean value.');
});

it('should throw on invalid MobileLinksConfig attribute', () => {
const tenantOptionsClientRequest = deepCopy(clientRequest) as any;
tenantOptionsClientRequest.mobileLinksConfig.invalidParameter = 'invalid';
expect(() => {
Tenant.buildServerRequest(tenantOptionsClientRequest, !createRequest);
}).to.throw('"invalidParameter" is not a valid "MobileLinksConfig" parameter.');
});

it('should throw on invalid domain attribute', () => {
const tenantOptionsClientRequest = deepCopy(clientRequest) as any;
tenantOptionsClientRequest.mobileLinksConfig.domain = 'random domain';
expect(() => {
Tenant.buildServerRequest(tenantOptionsClientRequest, !createRequest);
}).to.throw('"MobileLinksConfig.domain" must be either "HOSTING_DOMAIN" or "FIREBASE_DYNAMIC_LINK_DOMAIN".');
});

it('should not throw on valid client request object', () => {
const tenantOptionsClientRequest = deepCopy(clientRequestWithRecaptcha);
expect(() => {
Expand Down Expand Up @@ -1010,22 +979,6 @@ describe('Tenant', () => {
}).to.throw('"EmailPrivacyConfig.enableImprovedEmailPrivacy" must be a valid boolean value.');
});

it('should throw on invalid MobileLinksConfig attribute', () => {
const tenantOptionsClientRequest = deepCopy(clientRequest) as any;
tenantOptionsClientRequest.mobileLinksConfig.invalidParameter = 'invalid';
expect(() => {
Tenant.buildServerRequest(tenantOptionsClientRequest, createRequest);
}).to.throw('"invalidParameter" is not a valid "MobileLinksConfig" parameter.');
});

it('should throw on invalid domain attribute', () => {
const tenantOptionsClientRequest = deepCopy(clientRequest) as any;
tenantOptionsClientRequest.mobileLinksConfig.domain = 'random domain';
expect(() => {
Tenant.buildServerRequest(tenantOptionsClientRequest, createRequest);
}).to.throw('"MobileLinksConfig.domain" must be either "HOSTING_DOMAIN" or "FIREBASE_DYNAMIC_LINK_DOMAIN".');
});

const nonObjects = [null, NaN, 0, 1, true, false, '', 'a', [], [1, 'a'], _.noop];
nonObjects.forEach((request) => {
it('should throw on invalid CreateTenantRequest:' + JSON.stringify(request), () => {
Expand Down Expand Up @@ -1145,13 +1098,6 @@ describe('Tenant', () => {
deepCopy(clientRequest.passwordPolicyConfig));
});

it('should set readonly property mobileLinksConfig', () => {
const expectedMobileLinksConfig = {
domain: 'HOSTING_DOMAIN',
};
expect(clientRequest.mobileLinksConfig).to.deep.equal(expectedMobileLinksConfig);
});

it('should set readonly property emailPrivacyConfig', () => {
const expectedEmailPrivacyConfig = {
enableImprovedEmailPrivacy: true,
Expand Down Expand Up @@ -1201,7 +1147,6 @@ describe('Tenant', () => {
recaptchaConfig: deepCopy(serverResponseWithRecaptcha.recaptchaConfig),
passwordPolicyConfig: deepCopy(clientRequest.passwordPolicyConfig),
emailPrivacyConfig: deepCopy(clientRequest.emailPrivacyConfig),
mobileLinksConfig: deepCopy(clientRequest.mobileLinksConfig),
});
});

Expand All @@ -1213,7 +1158,6 @@ describe('Tenant', () => {
delete serverRequestCopyWithoutMfa.recaptchaConfig;
delete serverRequestCopyWithoutMfa.passwordPolicyConfig;
delete serverRequestCopyWithoutMfa.emailPrivacyConfig;
delete serverRequestCopyWithoutMfa.mobileLinksConfig;
expect(new Tenant(serverRequestCopyWithoutMfa).toJSON()).to.deep.equal({
tenantId: 'TENANT-ID',
displayName: 'TENANT-DISPLAY-NAME',
Expand Down