Adds tenant management APIs to developer facing Auth instance.#567
Adds tenant management APIs to developer facing Auth instance.#567bojeil-google merged 3 commits intoauth-multi-tenancyfrom
Conversation
This includes getTenant, deleteTenant, listTenants, createTenant and updateTenant. This expects TenantServerResponse to be returned for createTenant and updateTenant. Expected results have not been confirmed. A followup PR will add integration tests for the above.
hiranya911
left a comment
There was a problem hiding this comment.
Looks good. Just one suggestion for consideration.
src/auth/auth.ts
Outdated
| * @return {Promise<Tenant>} A promise that resolves with the corresponding tenant. | ||
| */ | ||
| public getTenant(tenantId: string): Promise<Tenant> { | ||
| return (this.authRequestHandler as AuthRequestHandler).getTenant(tenantId) |
There was a problem hiding this comment.
You can use generics and get rid of these casts if you want to.
abstract class AbstractRequestHandler { }
class AuthRequestHandler extends AbstractRequestHandler {
public getTenant() { }
}
class TenantAwareRequestHandler extends AbstractRequestHandler { }
abstract class BaseAuth<T extends AbstractRequestHandler> {
protected requestHandler: T;
}
class Auth extends BaseAuth<AuthRequestHandler> {
public getTenant() {
// requestHandler is treated as AuthRequestHandler by the compiler
this.requestHandler.getTenant();
}
}
There was a problem hiding this comment.
Good idea. Done.
Adds missing backend errors.
hiranya911
left a comment
There was a problem hiding this comment.
Thanks for making the changes. Just a few comments on the tests.
| }; | ||
| // Stubs used to simulate underlying API calls. | ||
| let stubs: sinon.SinonStub[] = []; | ||
| afterEach(() => { |
There was a problem hiding this comment.
Nit: Add an empty line before this for clarity.
| .to.have.been.calledOnce.and.calledWith(undefined, undefined); | ||
| }); | ||
| }); | ||
|
|
| }); | ||
|
|
||
| it('should be rejected given TenantOptions with invalid property', () => { | ||
| return (auth as Auth).updateTenant(tenantId, {type: 'lightweight'}) |
There was a problem hiding this comment.
Can we make it clear what the invalid property is? Is it the key or the value that makes it invalid? Depending on the intention of the test either {invalid: 'lightweight'} or {type: 'invalid'}. If neither is appropriate, update the description of the test.
There was a problem hiding this comment.
I updated test description and added a comment here and in the createTenant test similar to this.
This includes getTenant, deleteTenant, listTenants, createTenant and updateTenant.
This expects TenantServerResponse to be returned for createTenant and updateTenant.
Expected results have not been confirmed. A followup PR will add integration tests for the above.