-
Notifications
You must be signed in to change notification settings - Fork 378
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
Conversation
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! Mostly nits.
const FIREBASE_IID_TIMEOUT = 10000; | ||
|
||
/** | ||
* Class that provides mechanism to send requests to the Firebase Auth backend endpoints. |
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.
Update comment: Firebase IID backend endpoints.
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
src/instance-id/instance-id.ts
Outdated
* Internals of an InstanceId service instance. | ||
*/ | ||
class InstanceIdInternals implements FirebaseServiceInternalsInterface { | ||
/** |
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.
Update the indentation to be consistent. We use 2 spaces in this case.
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
src/instance-id/instance-id.ts
Outdated
* @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 |
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.
Fix indentation
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
src/instance-id/instance-id.ts
Outdated
} | ||
|
||
export class InstanceId implements FirebaseServiceInterface { | ||
public INTERNAL: InstanceIdInternals = new InstanceIdInternals(); |
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.
Indentation needs to be fixed here too and the rest of the class.
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
src/instance-id/instance-id.ts
Outdated
export class InstanceId implements FirebaseServiceInterface { | ||
public INTERNAL: InstanceIdInternals = new InstanceIdInternals(); | ||
|
||
private app_: FirebaseApp; |
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.
Let's stick with no trailing _ for private variables. This is also the recommended style for ts.
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.
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; |
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.
Add check:
expect(iid.app).to.be.deep.equal(app);
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
chai.use(chaiAsPromised); | ||
|
||
describe('InstanceId', () => { | ||
let iid: InstanceId; |
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.
fix indentation
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 no instance ID', () => { | ||
return (iid as any).deleteInstanceId() | ||
.should.eventually.be.rejected.and.have.property('code', 'instance-id/invalid-instance-id'); |
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.
Indent second line .should...
and .then
below too.
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 an invalid instance ID', () => { | ||
return iid.deleteInstanceId('') |
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.
Why don't you use should.eventually.be.rejected.and.have...
like 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.
Done
}); | ||
|
||
it('should throw an error when the backend returns an error', () => { | ||
// Stub getAccountInfoByUid to throw a backend error. |
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.
Update comment getAccountInfoByUid
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
Made the suggested changes, and left one question. Over to @bojeil-google for another look. |
@bojeil-google I pushed a couple of commits to improve error handling and test coverage. PTAL. |
…mantics of util.format()
}); | ||
}); | ||
|
||
describe('deleteInstanceId', () => { |
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. One suggestion: i think it would be a good idea to also confirm the error code too.
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
…o be consistent across all SDKs.
A new API that enables deleting instance IDs associated with a Firebase project.
go/firebase-admin-iid