Skip to content

Commit e94f1c0

Browse files
authored
Inline DecodedAppCheck definition (#891)
Fixes an issue where old (but supported) versions of firebase-admin didn't expose AppCheck and then TSC failed.
1 parent 8e4a446 commit e94f1c0

File tree

15 files changed

+102
-42
lines changed

15 files changed

+102
-42
lines changed

integration_test/functions/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
import { PubSub } from '@google-cloud/pubsub';
12
import { Request, Response } from 'express';
23
import * as admin from 'firebase-admin';
34
import * as functions from 'firebase-functions';
45
import * as fs from 'fs';
56
import * as https from 'https';
6-
import { PubSub } from '@google-cloud/pubsub';
77

88
export * from './pubsub-tests';
99
export * from './database-tests';

integration_test/functions/src/testLab-tests.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as functions from 'firebase-functions';
2-
import { TestSuite, expectEq } from './testing';
2+
import { expectEq, TestSuite } from './testing';
33
import TestMatrix = functions.testLab.TestMatrix;
44
const REGION = process.env.FIREBASE_FUNCTIONS_TEST_REGION || 'us-central1';
55

integration_test/functions/src/testLab-utils.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import * as admin from 'firebase-admin';
12
import * as http from 'http';
23
import * as https from 'https';
3-
import * as admin from 'firebase-admin';
44
import * as utils from './test-utils';
55

66
interface AndroidDevice {
@@ -50,12 +50,12 @@ async function fetchDefaultDevice(
5050
const model = defaultModels[0];
5151
const versions = model.supportedVersionIds;
5252

53-
return <AndroidDevice>{
53+
return {
5454
androidModelId: model.id,
5555
androidVersionId: versions[versions.length - 1],
5656
locale: 'en',
5757
orientation: 'portrait',
58-
};
58+
} as AndroidDevice;
5959
}
6060

6161
function createTestMatrix(
@@ -70,7 +70,7 @@ function createTestMatrix(
7070
'/v1/projects/' + projectId + '/testMatrices'
7171
);
7272
const body = {
73-
projectId: projectId,
73+
projectId,
7474
testSpecification: {
7575
androidRoboTest: {
7676
appApk: {
@@ -105,9 +105,9 @@ function requestOptions(
105105
path: string
106106
): https.RequestOptions {
107107
return {
108-
method: method,
108+
method,
109109
hostname: TESTING_API_SERVICE_NAME,
110-
path: path,
110+
path,
111111
headers: {
112112
Authorization: 'Bearer ' + accessToken.access_token,
113113
'Content-Type': 'application/json',

integration_test/functions/src/testing.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ function deepEq(left: any, right: any) {
9292
return false;
9393
}
9494

95-
for (let key in left) {
95+
for (const key in left) {
9696
if (!right.hasOwnProperty(key)) {
9797
return false;
9898
}

spec/fixtures/mockrequest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import * as jwt from 'jsonwebtoken';
22
import * as jwkToPem from 'jwk-to-pem';
33
import * as _ from 'lodash';
44
import * as nock from 'nock';
5-
import * as mockKey from '../fixtures/credential/key.json';
65
import * as mockJWK from '../fixtures/credential/jwk.json';
6+
import * as mockKey from '../fixtures/credential/key.json';
77

88
// MockRequest mocks an https.Request.
99
export class MockRequest {

spec/logger.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ const SUPPORTS_STRUCTURED_LOGS =
77
describe(`logger (${
88
SUPPORTS_STRUCTURED_LOGS ? 'structured' : 'unstructured'
99
})`, () => {
10-
let stdoutWrite = process.stdout.write.bind(process.stdout);
11-
let stderrWrite = process.stderr.write.bind(process.stderr);
10+
const stdoutWrite = process.stdout.write.bind(process.stdout);
11+
const stderrWrite = process.stderr.write.bind(process.stderr);
1212
let lastOut: string;
1313
let lastErr: string;
1414

@@ -127,7 +127,7 @@ describe(`logger (${
127127

128128
for (const severity of ['DEBUG', 'INFO', 'NOTICE']) {
129129
it(`should output ${severity} severity to stdout`, () => {
130-
let entry: logger.LogEntry = {
130+
const entry: logger.LogEntry = {
131131
severity: severity as logger.LogSeverity,
132132
message: 'test',
133133
};
@@ -144,7 +144,7 @@ describe(`logger (${
144144
'EMERGENCY',
145145
]) {
146146
it(`should output ${severity} severity to stderr`, () => {
147-
let entry: logger.LogEntry = {
147+
const entry: logger.LogEntry = {
148148
severity: severity as logger.LogSeverity,
149149
message: 'test',
150150
};

spec/providers/testLab.spec.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -66,23 +66,23 @@ describe('Test Lab Functions', () => {
6666
resource: {},
6767
},
6868
};
69-
const expected = <testLab.TestMatrix>{
69+
const expected = {
7070
testMatrixId: 'matrix-375mfeu9mnw8t',
7171
state: 'INVALID',
7272
createTime: '2019-04-15T17:43:32.538Z',
7373
outcomeSummary: undefined,
7474
invalidMatrixDetails: 'INVALID_INPUT_APK',
75-
resultStorage: <testLab.ResultStorage>{
75+
resultStorage: {
7676
gcsPath: 'gs://test.appspot.com',
7777
resultsUrl: undefined,
7878
toolResultsHistoryId: undefined,
7979
toolResultsExecutionId: undefined,
80-
},
81-
clientInfo: <testLab.ClientInfo>{
80+
} as testLab.ResultStorage,
81+
clientInfo: {
8282
name: 'test',
8383
details: {},
84-
},
85-
};
84+
} as testLab.ClientInfo,
85+
} as testLab.TestMatrix;
8686
const func = testLab.testMatrix().onComplete((matrix) => matrix);
8787
return expect(func(event.data, event.context)).to.eventually.deep.equal(
8888
expected
@@ -119,23 +119,23 @@ describe('Test Lab Functions', () => {
119119
resource: {},
120120
},
121121
};
122-
const expected = <testLab.TestMatrix>{
122+
const expected = {
123123
testMatrixId: 'matrix-tsgjk8pnvxhya',
124124
state: 'FINISHED',
125125
createTime: '2019-04-15T18:03:11.115Z',
126126
outcomeSummary: 'FAILURE',
127127
invalidMatrixDetails: undefined,
128-
resultStorage: <testLab.ResultStorage>{
128+
resultStorage: {
129129
gcsPath: 'gs://test.appspot.com',
130130
toolResultsHistoryId: 'bh.9b6f4dac24d3049',
131131
toolResultsExecutionId: '6352915701487950333',
132132
resultsUrl: 'https://path/to/results',
133-
},
134-
clientInfo: <testLab.ClientInfo>{
133+
} as testLab.ResultStorage,
134+
clientInfo: {
135135
name: 'test',
136136
details: {},
137-
},
138-
};
137+
} as testLab.ClientInfo,
138+
} as testLab.TestMatrix;
139139
const func = testLab.testMatrix().onComplete((matrix) => matrix);
140140
return expect(func(event.data, event.context)).to.eventually.deep.equal(
141141
expected
@@ -161,15 +161,15 @@ describe('Test Lab Functions', () => {
161161
describe('TestMatrix', () => {
162162
describe('constructor', () => {
163163
it('should populate basic fields', () => {
164-
const expected = <testLab.TestMatrix>{
164+
const expected = {
165165
testMatrixId: 'id1',
166166
createTime: '2019-02-08T18:50:32.178Z',
167167
state: 'FINISHED',
168168
outcomeSummary: 'SUCCESS',
169169
invalidMatrixDetails: 'DETAILS_UNAVAILABLE',
170170
resultStorage: new testLab.ResultStorage(),
171171
clientInfo: new testLab.ClientInfo(),
172-
};
172+
} as testLab.TestMatrix;
173173
const actual = new testLab.TestMatrix({
174174
testMatrixId: 'id1',
175175
timestamp: '2019-02-08T18:50:32.178Z',
@@ -185,24 +185,24 @@ describe('Test Lab Functions', () => {
185185
describe('ClientInfo', () => {
186186
describe('constructor', () => {
187187
it('should populate basic fields', () => {
188-
const expected = <testLab.ClientInfo>{
188+
const expected = {
189189
name: 'client',
190190
details: {},
191-
};
191+
} as testLab.ClientInfo;
192192
const actual = new testLab.ClientInfo({
193193
name: 'client',
194194
});
195195
expect(actual).to.deep.equal(expected);
196196
});
197197

198198
it('should populate key/value details', () => {
199-
const expected = <testLab.ClientInfo>{
199+
const expected = {
200200
name: 'client',
201201
details: {
202202
k0: 'v0',
203203
k1: '',
204204
},
205-
};
205+
} as testLab.ClientInfo;
206206
const actual = new testLab.ClientInfo({
207207
name: 'client',
208208
clientInfoDetails: [
@@ -223,12 +223,12 @@ describe('Test Lab Functions', () => {
223223
describe('ResultStorage', () => {
224224
describe('constructor', () => {
225225
it('should populate basic fields', () => {
226-
const expected = <testLab.ResultStorage>{
226+
const expected = {
227227
gcsPath: 'path',
228228
toolResultsHistoryId: 'h1',
229229
toolResultsExecutionId: 'e2',
230230
resultsUrl: 'http://example.com/',
231-
};
231+
} as testLab.ResultStorage;
232232
const actual = new testLab.ResultStorage({
233233
googleCloudStorage: {
234234
gcsPath: 'path',

src/cloud-functions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222

2323
import { Request, Response } from 'express';
2424
import * as _ from 'lodash';
25-
import { warn } from './logger';
2625
import {
2726
DEFAULT_FAILURE_POLICY,
2827
DeploymentOptions,
2928
FailurePolicy,
3029
Schedule,
3130
} from './function-configuration';
31+
import { warn } from './logger';
3232
export { Request, Response };
3333

3434
/** @hidden */

src/function-builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ import * as _ from 'lodash';
2626
import { CloudFunction, EventContext } from './cloud-functions';
2727
import {
2828
DeploymentOptions,
29+
INGRESS_SETTINGS_OPTIONS,
2930
MAX_TIMEOUT_SECONDS,
3031
RuntimeOptions,
3132
SUPPORTED_REGIONS,
3233
VALID_MEMORY_OPTIONS,
3334
VPC_EGRESS_SETTINGS_OPTIONS,
34-
INGRESS_SETTINGS_OPTIONS,
3535
} from './function-configuration';
3636
import * as analytics from './providers/analytics';
3737
import * as auth from './providers/auth';

src/function-configuration.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,13 @@ export interface RuntimeOptions {
116116
*/
117117
minInstances?: number;
118118

119+
/**
120+
* Which version of the internal contract between the CLI and the SDK are
121+
* we using? For internal testing only.
122+
* @hidden
123+
*/
124+
apiVersion?: 1 | 2;
125+
119126
/**
120127
* Max number of actual instances allowed to be running in parallel
121128
*/

0 commit comments

Comments
 (0)