Skip to content

Commit

Permalink
PR fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lahirumaramba committed Jul 12, 2021
1 parent 53226ab commit 752437d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
5 changes: 2 additions & 3 deletions src/app-check/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,8 @@ export namespace appCheck {
*/
export interface AppCheckTokenOptions {
/**
* The length of time measured in milliseconds starting from when the server
* mints the token for which the returned FAC token will be valid.
* This value must be in milliseconds and between 30 minutes and 7 days, inclusive.
* The length of time, in milliseconds, for which the App Check token will
* be valid. This value must be between 30 minutes and 7 days, inclusive.
*/
ttlMillis?: number;
}
Expand Down
34 changes: 21 additions & 13 deletions test/unit/app-check/token-generator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,18 +157,22 @@ describe('AppCheckTokenGenerator', () => {
.should.eventually.be.a('string').and.not.be.empty;
});

[[THIRTY_MIN_IN_MS, '1800s'], [THIRTY_MIN_IN_MS + 1, '1800.001000000s'],
[SEVEN_DAYS_IN_MS / 2, '302400s'], [SEVEN_DAYS_IN_MS - 1, '604799.999000000s'], [SEVEN_DAYS_IN_MS, '604800s']]
.forEach((ttl) => {
it('should be fulfilled with a Firebase Custom JWT with a valid custom ttl' + JSON.stringify(ttl[0]), () => {
return tokenGenerator.createCustomToken(APP_ID, { ttlMillis: ttl[0] as number })
.then((token) => {
const decoded = jwt.decode(token) as { [key: string]: any };

expect(decoded['ttl']).to.equal(ttl[1]);
});
});
[
[THIRTY_MIN_IN_MS, '1800s'],
[THIRTY_MIN_IN_MS + 1, '1800.001000000s'],
[SEVEN_DAYS_IN_MS / 2, '302400s'],
[SEVEN_DAYS_IN_MS - 1, '604799.999000000s'],
[SEVEN_DAYS_IN_MS, '604800s']
].forEach((ttl) => {
it('should be fulfilled with a Firebase Custom JWT with a valid custom ttl' + JSON.stringify(ttl[0]), () => {
return tokenGenerator.createCustomToken(APP_ID, { ttlMillis: ttl[0] as number })
.then((token) => {
const decoded = jwt.decode(token) as { [key: string]: any };

expect(decoded['ttl']).to.equal(ttl[1]);
});
});
});

it('should be fulfilled with a JWT with the correct decoded payload', () => {
clock = sinon.useFakeTimers(1000);
Expand Down Expand Up @@ -212,8 +216,12 @@ describe('AppCheckTokenGenerator', () => {
});
});

[[1800000.000001, '1800.000000001s'], [1800000.001, '1800.000000999s'], [172800000, '172800s'],
[604799999, '604799.999000000s'], [604800000, '604800s']
[
[1800000.000001, '1800.000000001s'],
[1800000.001, '1800.000000999s'],
[172800000, '172800s'],
[604799999, '604799.999000000s'],
[604800000, '604800s']
].forEach((ttl) => {
it('should be fulfilled with a JWT with custom ttl in decoded payload', () => {
clock = sinon.useFakeTimers(1000);
Expand Down

0 comments on commit 752437d

Please sign in to comment.