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

Implemented IID Delete API #142

Merged
merged 11 commits into from
Dec 20, 2017
Merged

Implemented IID Delete API #142

merged 11 commits into from
Dec 20, 2017

Conversation

hiranya911
Copy link
Contributor

A new API that enables deleting instance IDs associated with a Firebase project.

let result: Promise<void> = admin.instanceId().deleteInstanceId(iid);

go/firebase-admin-iid

Copy link
Contributor

@bojeil-google bojeil-google 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! Mostly nits.

const FIREBASE_IID_TIMEOUT = 10000;

/**
* Class that provides mechanism to send requests to the Firebase Auth backend endpoints.
Copy link
Contributor

Choose a reason for hiding this comment

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

Update comment: Firebase IID backend endpoints.

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

* Internals of an InstanceId service instance.
*/
class InstanceIdInternals implements FirebaseServiceInternalsInterface {
/**
Copy link
Contributor

Choose a reason for hiding this comment

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

Update the indentation to be consistent. We use 2 spaces in this case.

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

* @return {Promise<()>} An empty Promise that will be fulfilled when the service is deleted.
*/
public delete(): Promise<void> {
// There are no resources to clean up
Copy link
Contributor

Choose a reason for hiding this comment

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

Fix indentation

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

}

export class InstanceId implements FirebaseServiceInterface {
public INTERNAL: InstanceIdInternals = new InstanceIdInternals();
Copy link
Contributor

Choose a reason for hiding this comment

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

Indentation needs to be fixed here too and the rest of the class.

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

export class InstanceId implements FirebaseServiceInterface {
public INTERNAL: InstanceIdInternals = new InstanceIdInternals();

private app_: FirebaseApp;
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's stick with no trailing _ for private variables. This is also the recommended style for ts.

Copy link
Contributor Author

@hiranya911 hiranya911 Dec 8, 2017

Choose a reason for hiding this comment

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

That is going to conflict with the get app() getter. Is it better to remove that, and expose app as a public attribute of this class? But I guess that would make app writable, which we don't want.

it('should return a valid namespace when the named app is initialized', () => {
let app: FirebaseApp = firebaseNamespace.initializeApp(mocks.appOptions, 'testApp');
let iid: InstanceId = firebaseNamespace.instanceId(app);
expect(iid).to.not.be.null;
Copy link
Contributor

Choose a reason for hiding this comment

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

Add check:
expect(iid.app).to.be.deep.equal(app);

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

chai.use(chaiAsPromised);

describe('InstanceId', () => {
let iid: InstanceId;
Copy link
Contributor

Choose a reason for hiding this comment

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

fix indentation

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 no instance ID', () => {
return (iid as any).deleteInstanceId()
.should.eventually.be.rejected.and.have.property('code', 'instance-id/invalid-instance-id');
Copy link
Contributor

Choose a reason for hiding this comment

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

Indent second line .should... and .then below too.

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 an invalid instance ID', () => {
return iid.deleteInstanceId('')
Copy link
Contributor

Choose a reason for hiding this comment

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

Why don't you use should.eventually.be.rejected.and.have... like above

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 throw an error when the backend returns an error', () => {
// Stub getAccountInfoByUid to throw a backend error.
Copy link
Contributor

Choose a reason for hiding this comment

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

Update comment getAccountInfoByUid

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

@hiranya911
Copy link
Contributor Author

Made the suggested changes, and left one question. Over to @bojeil-google for another look.

@hiranya911
Copy link
Contributor Author

@bojeil-google I pushed a couple of commits to improve error handling and test coverage. PTAL.

});
});

describe('deleteInstanceId', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good. One suggestion: i think it would be a good idea to also confirm the error code too.

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

@hiranya911 hiranya911 merged commit 52bfaca into master Dec 20, 2017
@hiranya911 hiranya911 deleted the hkj-delete-iid branch December 20, 2017 19:10
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.

2 participants