Skip to content

Commit

Permalink
Make ShaCertificate constructor available through admin.projectManage…
Browse files Browse the repository at this point in the history
…ment().shaCertificate(shaHash). (#417)

* Make ShaCertificate constructor available through admin.projectManagement().shaCertificate(shaHash).

* Add unit test for projectManagement.shaCertificate().

* Update changelog.
  • Loading branch information
nbegley authored and hiranya911 committed Jan 7, 2019
1 parent fb9d779 commit b232114
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

- [fixed] Correctly parses error codes with details messages in Firebase Auth.
- [fixed] Fixed optional fields in UserRecord types to be optional.
- [added] `admin.projectManagement().shaCertificate()` method to create an
instance of admin.projectManagement.ShaCertificate.

# v6.4.0

Expand Down
1 change: 1 addition & 0 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,7 @@ declare namespace admin.projectManagement {
listIosApps(): Promise<admin.projectManagement.IosApp[]>;
androidApp(appId: string): admin.projectManagement.AndroidApp;
iosApp(appId: string): admin.projectManagement.IosApp;
shaCertificate(shaHash: string): admin.projectManagement.ShaCertificate;
createAndroidApp(
packageName: string, displayName?: string): Promise<admin.projectManagement.AndroidApp>;
createIosApp(bundleId: string, displayName?: string): Promise<admin.projectManagement.IosApp>;
Expand Down
9 changes: 8 additions & 1 deletion src/project-management/project-management.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { FirebaseServiceInterface, FirebaseServiceInternalsInterface } from '../
import { FirebaseProjectManagementError } from '../utils/error';
import * as utils from '../utils/index';
import * as validator from '../utils/validator';
import { AndroidApp } from './android-app';
import { AndroidApp, ShaCertificate } from './android-app';
import { IosApp } from './ios-app';
import { ProjectManagementRequestHandler, assertServerResponse } from './project-management-api-request';

Expand Down Expand Up @@ -102,6 +102,13 @@ export class ProjectManagement implements FirebaseServiceInterface {
return new IosApp(appId, this.requestHandler);
}

/**
* Returns a ShaCertificate object for the given shaHash. No RPC is made.
*/
public shaCertificate(shaHash: string): ShaCertificate {
return new ShaCertificate(shaHash);
}

/**
* Creates a new Firebase Android app, associated with this Firebase project.
*/
Expand Down
10 changes: 10 additions & 0 deletions test/unit/project-management/project-management.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ const PACKAGE_NAME = 'test-package-name';
const BUNDLE_ID = 'test-bundle-id';
const EXPECTED_ERROR = new FirebaseProjectManagementError('internal-error', 'message');

const VALID_SHA_256_HASH = '0123456789abcdefABCDEF01234567890123456701234567890123456789abcd';

describe('ProjectManagement', () => {
// Stubs used to simulate underlying api calls.
let stubs: sinon.SinonStub[] = [];
Expand Down Expand Up @@ -276,6 +278,14 @@ describe('ProjectManagement', () => {
});
});

describe('shaCertificate', () => {
it('should successfully return a ShaCertificate', () => {
const shaCertificate = projectManagement.shaCertificate(VALID_SHA_256_HASH);
shaCertificate.shaHash.should.equal(VALID_SHA_256_HASH);
shaCertificate.certType.should.equal('sha256');
});
});

describe('createAndroidApp', () => {
it('should propagate intial API response errors', () => {
const stub = sinon
Expand Down

0 comments on commit b232114

Please sign in to comment.