-
Notifications
You must be signed in to change notification settings - Fork 393
Adds tenant management APIs to developer facing Auth instance. #567
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. Done.
Adds missing backend errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Add an empty line before this for clarity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
.to.have.been.calledOnce.and.calledWith(undefined, undefined); | ||
}); | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant empty line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
}); | ||
|
||
it('should be rejected given TenantOptions with invalid property', () => { | ||
return (auth as Auth).updateTenant(tenantId, {type: 'lightweight'}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated test description and added a comment here and in the createTenant
test similar to this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. LGTM 👍
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.