Skip to content

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

Merged
merged 3 commits into from
Jun 14, 2019

Conversation

bojeil-google
Copy link
Contributor

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.

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.
Copy link
Contributor

@hiranya911 hiranya911 left a 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)
Copy link
Contributor

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();
  }
}

Copy link
Contributor Author

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.
Copy link
Contributor

@hiranya911 hiranya911 left a 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(() => {
Copy link
Contributor

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.

Copy link
Contributor Author

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);
});
});

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant empty line

Copy link
Contributor Author

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'})
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

@hiranya911 hiranya911 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. LGTM 👍

@bojeil-google bojeil-google merged commit 5aa4dc0 into auth-multi-tenancy Jun 14, 2019
@bojeil-google bojeil-google deleted the temp-multi-tenancy branch June 17, 2019 05:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants