Skip to content

Commit

Permalink
fix getJWT and authorize methods in tests (#414)
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisRumyantsev authored Aug 3, 2023
1 parent 3c8657e commit 206e070
Show file tree
Hide file tree
Showing 19 changed files with 184 additions and 79 deletions.
16 changes: 10 additions & 6 deletions Tasks/GooglePlayIncreaseRolloutV2/Tests/L0GoogleAuthError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,18 @@ tr.registerMock('./googleutil', {
publisher: {
edits: {}
},
getJWT: () => {
return {
authorize: () => { throw new Error('authorize() error'); }
};
},
getJWT: () => ({ authorize: () => { throw new Error('JWT.authorize() should be run via googleutil.authorize(JWT)'); } }),
authorize: () => Promise.reject(new Error('authorize() error')),
updateGlobalParams: () => sinon.stub()
});

process.env['ENDPOINT_AUTH_myServiceEndpoint'] = '{ "parameters": {"username": "myUser", "password": "myPass"}, "scheme": "UsernamePassword"}';
process.env['ENDPOINT_AUTH_myServiceEndpoint'] = JSON.stringify({
parameters: {
username: 'myUser',
password: 'myPass'
},

scheme: 'UsernamePassword'
});

tr.run();
12 changes: 10 additions & 2 deletions Tasks/GooglePlayIncreaseRolloutV2/Tests/L0NothingInProgress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ tr.registerMock('./googleutil', {
commit: () => Promise.resolve({ data: {} })
}
},
getJWT: () => ({ authorize: () => sinon.stub() }),
getJWT: () => ({ authorize: () => { throw new Error('JWT.authorize() should be run via googleutil.authorize(JWT)'); } }),
authorize: () => Promise.resolve(),
updateGlobalParams: () => ({}),
getNewEdit: () => Promise.resolve({}),
updateTrack: () => Promise.resolve({}),
Expand All @@ -32,6 +33,13 @@ tr.registerMock('./googleutil', {
})
});

process.env['ENDPOINT_AUTH_myServiceEndpoint'] = '{ "parameters": {"username": "myUser", "password": "myPass"}, "scheme": "UsernamePassword"}';
process.env['ENDPOINT_AUTH_myServiceEndpoint'] = JSON.stringify({
parameters: {
username: 'myUser',
password: 'myPass'
},

scheme: 'UsernamePassword'
});

tr.run();
12 changes: 10 additions & 2 deletions Tasks/GooglePlayIncreaseRolloutV2/Tests/L0SendReleaseNotes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ tr.registerMock('./googleutil', {
commit: () => Promise.resolve({ data: {} })
}
},
getJWT: () => ({ authorize: () => sinon.stub() }),
getJWT: () => ({ authorize: () => { throw new Error('JWT.authorize() should be run via googleutil.authorize(JWT)'); } }),
authorize: () => Promise.resolve(),
updateGlobalParams: () => ({}),
getNewEdit: () => Promise.resolve({}),
updateTrack: (_edits, _packageName, _track, _versionCode, _userFraction, releaseNotes?) => Promise.resolve(releaseNotes),
Expand All @@ -35,6 +36,13 @@ tr.registerMock('./googleutil', {
})
});

process.env['ENDPOINT_AUTH_myServiceEndpoint'] = '{ "parameters": {"username": "myUser", "password": "myPass"}, "scheme": "UsernamePassword"}';
process.env['ENDPOINT_AUTH_myServiceEndpoint'] = JSON.stringify({
parameters: {
username: 'myUser',
password: 'myPass'
},

scheme: 'UsernamePassword'
});

tr.run();
12 changes: 10 additions & 2 deletions Tasks/GooglePlayPromoteV3/Tests/L0PromoteNoVersionCode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ tr.registerMock('./googleutil', {
commit: () => Promise.resolve({ data: {} })
}
},
getJWT: () => ({ authorize: () => sinon.stub() }),
getJWT: () => ({ authorize: () => { throw new Error('JWT.authorize() should be run via googleutil.authorize(JWT)'); } }),
authorize: () => Promise.resolve(),
updateGlobalParams: () => ({}),
getNewEdit: () => Promise.resolve({}),

Expand All @@ -46,6 +47,13 @@ tr.registerMock('./googleutil', {
})
});

process.env['ENDPOINT_AUTH_myServiceEndpoint'] = '{ "parameters": {"username": "myUser", "password": "myPass"}, "scheme": "UsernamePassword"}';
process.env['ENDPOINT_AUTH_myServiceEndpoint'] = JSON.stringify({
parameters: {
username: 'myUser',
password: 'myPass'
},

scheme: 'UsernamePassword'
});

tr.run();
12 changes: 10 additions & 2 deletions Tasks/GooglePlayPromoteV3/Tests/L0PromoteWithVersionCode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ tr.registerMock('./googleutil', {
commit: () => Promise.resolve({ data: {} })
}
},
getJWT: () => ({ authorize: () => sinon.stub() }),
getJWT: () => ({ authorize: () => { throw new Error('JWT.authorize() should be run via googleutil.authorize(JWT)'); } }),
authorize: () => Promise.resolve(),
updateGlobalParams: () => ({}),
getNewEdit: () => Promise.resolve({}),
updateTrack: (_edits, _packageName, _track, _versionCode, _userFraction, releaseNotes?) => Promise.resolve({
Expand All @@ -47,6 +48,13 @@ tr.registerMock('./googleutil', {
})
});

process.env['ENDPOINT_AUTH_myServiceEndpoint'] = '{ "parameters": {"username": "myUser", "password": "myPass"}, "scheme": "UsernamePassword"}';
process.env['ENDPOINT_AUTH_myServiceEndpoint'] = JSON.stringify({
parameters: {
username: 'myUser',
password: 'myPass'
},

scheme: 'UsernamePassword'
});

tr.run();
12 changes: 10 additions & 2 deletions Tasks/GooglePlayPromoteV3/Tests/L0SendReleaseNotes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ tr.registerMock('./googleutil', {
commit: () => Promise.resolve({ data: {} })
}
},
getJWT: () => ({ authorize: () => sinon.stub() }),
getJWT: () => ({ authorize: () => { throw new Error('JWT.authorize() should be run via googleutil.authorize(JWT)'); } }),
authorize: () => Promise.resolve(),
updateGlobalParams: () => ({}),
getNewEdit: () => Promise.resolve({}),
updateTrack: (_edits, _packageName, _track, _versionCode, _userFraction, releaseNotes?) => Promise.resolve(releaseNotes),
Expand All @@ -36,6 +37,13 @@ tr.registerMock('./googleutil', {
})
});

process.env['ENDPOINT_AUTH_myServiceEndpoint'] = '{ "parameters": {"username": "myUser", "password": "myPass"}, "scheme": "UsernamePassword"}';
process.env['ENDPOINT_AUTH_myServiceEndpoint'] = JSON.stringify({
parameters: {
username: 'myUser',
password: 'myPass'
},

scheme: 'UsernamePassword'
});

tr.run();
16 changes: 10 additions & 6 deletions Tasks/GooglePlayReleaseV4/Tests/L0AttachMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@ import path = require('path');
const taskPath = path.join(__dirname, '..', 'main.js');
const tr: tmrm.TaskMockRunner = new tmrm.TaskMockRunner(taskPath);

process.env['ENDPOINT_AUTH_myServiceEndpoint'] = '{ "parameters": {"username": "myUser", "password": "myPass"}, "scheme": "UsernamePassword"}';
process.env['ENDPOINT_AUTH_myServiceEndpoint'] = JSON.stringify({
parameters: {
username: 'myUser',
password: 'myPass'
},

scheme: 'UsernamePassword'
});

tr.setInput('authType', 'ServiceEndpoint');
tr.setInput('serviceEndpoint', 'myServiceEndpoint');
Expand Down Expand Up @@ -37,11 +44,8 @@ tr.registerMock('./modules/googleutil', {
}
}
},
getJWT: () => {
return {
authorize: sinon.stub()
};
},
getJWT: () => ({ authorize: () => { throw new Error('JWT.authorize() should be run via googleutil.authorize(JWT)'); } }),
authorize: () => Promise.resolve(),
getNewEdit: () => Promise.resolve({}),
getTrack: () => Promise.resolve({ releases: [{ versionCodes: [1, 2, 3 ]}]}),
updateTrack: () => Promise.resolve({}),
Expand Down
9 changes: 8 additions & 1 deletion Tasks/GooglePlayReleaseV4/Tests/L0BadVersionList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ import path = require('path');
const taskPath = path.join(__dirname, '..', 'main.js');
const tr: tmrm.TaskMockRunner = new tmrm.TaskMockRunner(taskPath);

process.env['ENDPOINT_AUTH_myServiceEndpoint'] = '{ "parameters": {"username": "myUser", "password": "myPass"}, "scheme": "UsernamePassword"}';
process.env['ENDPOINT_AUTH_myServiceEndpoint'] = JSON.stringify({
parameters: {
username: 'myUser',
password: 'myPass'
},

scheme: 'UsernamePassword'
});

tr.setInput('authType', 'ServiceEndpoint');
tr.setInput('serviceEndpoint', 'myServiceEndpoint');
Expand Down
16 changes: 10 additions & 6 deletions Tasks/GooglePlayReleaseV4/Tests/L0DeobfuscationFileNotFound.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@ import path = require('path');
const taskPath = path.join(__dirname, '..', 'main.js');
const tr: tmrm.TaskMockRunner = new tmrm.TaskMockRunner(taskPath);

process.env['ENDPOINT_AUTH_myServiceEndpoint'] = '{ "parameters": {"username": "myUser", "password": "myPass"}, "scheme": "UsernamePassword"}';
process.env['ENDPOINT_AUTH_myServiceEndpoint'] = JSON.stringify({
parameters: {
username: 'myUser',
password: 'myPass'
},

scheme: 'UsernamePassword'
});

tr.setInput('authType', 'ServiceEndpoint');
tr.setInput('serviceEndpoint', 'myServiceEndpoint');
Expand All @@ -32,11 +39,8 @@ tr.registerMock('./modules/googleutil', {
commit: sinon.stub()
}
},
getJWT: () => {
return {
authorize: sinon.stub()
};
},
getJWT: () => ({ authorize: () => { throw new Error('JWT.authorize() should be run via googleutil.authorize(JWT)'); } }),
authorize: () => Promise.resolve(),
getNewEdit: () => Promise.resolve({}),
getTrack: () => Promise.resolve({}),
updateTrack: () => Promise.resolve({}),
Expand Down
16 changes: 10 additions & 6 deletions Tasks/GooglePlayReleaseV4/Tests/L0FoundDeobfuscationFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@ import path = require('path');
const taskPath = path.join(__dirname, '..', 'main.js');
const tr: tmrm.TaskMockRunner = new tmrm.TaskMockRunner(taskPath);

process.env['ENDPOINT_AUTH_myServiceEndpoint'] = '{ "parameters": {"username": "myUser", "password": "myPass"}, "scheme": "UsernamePassword"}';
process.env['ENDPOINT_AUTH_myServiceEndpoint'] = JSON.stringify({
parameters: {
username: 'myUser',
password: 'myPass'
},

scheme: 'UsernamePassword'
});

tr.setInput('authType', 'ServiceEndpoint');
tr.setInput('serviceEndpoint', 'myServiceEndpoint');
Expand All @@ -34,11 +41,8 @@ tr.registerMock('./modules/googleutil', {
commit: sinon.stub()
}
},
getJWT: () => {
return {
authorize: sinon.stub()
};
},
getJWT: () => ({ authorize: () => { throw new Error('JWT.authorize() should be run via googleutil.authorize(JWT)'); } }),
authorize: () => Promise.resolve(),
getNewEdit: () => Promise.resolve({}),
getTrack: () => Promise.resolve({}),
updateTrack: () => Promise.resolve({}),
Expand Down
16 changes: 10 additions & 6 deletions Tasks/GooglePlayReleaseV4/Tests/L0HappyPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@ import path = require('path');
const taskPath = path.join(__dirname, '..', 'main.js');
const tr: tmrm.TaskMockRunner = new tmrm.TaskMockRunner(taskPath);

process.env['ENDPOINT_AUTH_myServiceEndpoint'] = '{ "parameters": {"username": "myUser", "password": "myPass"}, "scheme": "UsernamePassword"}';
process.env['ENDPOINT_AUTH_myServiceEndpoint'] = JSON.stringify({
parameters: {
username: 'myUser',
password: 'myPass'
},

scheme: 'UsernamePassword'
});

tr.setInput('authType', 'ServiceEndpoint');
tr.setInput('serviceEndpoint', 'myServiceEndpoint');
Expand All @@ -30,11 +37,8 @@ tr.registerMock('./modules/googleutil', {
commit: sinon.stub()
}
},
getJWT: () => {
return {
authorize: sinon.stub()
};
},
getJWT: () => ({ authorize: () => { throw new Error('JWT.authorize() should be run via googleutil.authorize(JWT)'); } }),
authorize: () => Promise.resolve(),
getNewEdit: () => Promise.resolve({}),
getTrack: () => Promise.resolve({}),
updateTrack: () => Promise.resolve({}),
Expand Down
9 changes: 8 additions & 1 deletion Tasks/GooglePlayReleaseV4/Tests/L0NoApkFound.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ import path = require('path');
const taskPath = path.join(__dirname, '..', 'main.js');
const tr: tmrm.TaskMockRunner = new tmrm.TaskMockRunner(taskPath);

process.env['ENDPOINT_AUTH_myServiceEndpoint'] = '{ "parameters": {"username": "myUser", "password": "myPass"}, "scheme": "UsernamePassword"}';
process.env['ENDPOINT_AUTH_myServiceEndpoint'] = JSON.stringify({
parameters: {
username: 'myUser',
password: 'myPass'
},

scheme: 'UsernamePassword'
});

tr.setInput('authType', 'ServiceEndpoint');
tr.setInput('serviceEndpoint', 'myServiceEndpoint');
Expand Down
9 changes: 8 additions & 1 deletion Tasks/GooglePlayReleaseV4/Tests/L0NoApkSupplied.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ tr.setInput('applicationId', 'package');
tr.setInput('action', 'SingleApk');
tr.setInput('apkFile', '');

process.env['ENDPOINT_AUTH_myServiceEndpoint'] = '{ "parameters": {"username": "myUser", "password": "myPass"}, "scheme": "UsernamePassword"}';
process.env['ENDPOINT_AUTH_myServiceEndpoint'] = JSON.stringify({
parameters: {
username: 'myUser',
password: 'myPass'
},

scheme: 'UsernamePassword'
});

tr.run();
16 changes: 10 additions & 6 deletions Tasks/GooglePlayReleaseV4/Tests/L0ObbFileNotFound.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@ import path = require('path');
const taskPath = path.join(__dirname, '..', 'main.js');
const tr: tmrm.TaskMockRunner = new tmrm.TaskMockRunner(taskPath);

process.env['ENDPOINT_AUTH_myServiceEndpoint'] = '{ "parameters": {"username": "myUser", "password": "myPass"}, "scheme": "UsernamePassword"}';
process.env['ENDPOINT_AUTH_myServiceEndpoint'] = JSON.stringify({
parameters: {
username: 'myUser',
password: 'myPass'
},

scheme: 'UsernamePassword'
});

tr.setInput('authType', 'ServiceEndpoint');
tr.setInput('serviceEndpoint', 'myServiceEndpoint');
Expand All @@ -32,11 +39,8 @@ tr.registerMock('./modules/googleutil', {
commit: sinon.stub()
}
},
getJWT: () => {
return {
authorize: sinon.stub()
};
},
getJWT: () => ({ authorize: () => { throw new Error('JWT.authorize() should be run via googleutil.authorize(JWT)'); } }),
authorize: () => Promise.resolve(),
getNewEdit: () => Promise.resolve({}),
getTrack: () => Promise.resolve({ releases: [{ versionCodes: [1, 2, 3 ]}]}),
updateTrack: () => Promise.resolve({}),
Expand Down
16 changes: 10 additions & 6 deletions Tasks/GooglePlayReleaseV4/Tests/L0ObbFoundInApkDirectory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,14 @@ stubForReaddirSync.onFirstCall().returns(['/path/to/obbfolder/file.exe', '/path/
stubForReaddirSync.onSecondCall().returns(['main.1.package.obb', '/path/to/obbfolder/filename.txt']);
stubForReaddirSync.onThirdCall().returns(['main.1.package.obb', '/path/to/obbfolder/filename.txt']);

process.env['ENDPOINT_AUTH_myServiceEndpoint'] = '{ "parameters": {"username": "myUser", "password": "myPass"}, "scheme": "UsernamePassword"}';
process.env['ENDPOINT_AUTH_myServiceEndpoint'] = JSON.stringify({
parameters: {
username: 'myUser',
password: 'myPass'
},

scheme: 'UsernamePassword'
});

tr.setInput('authType', 'ServiceEndpoint');
tr.setInput('serviceEndpoint', 'myServiceEndpoint');
Expand All @@ -38,11 +45,8 @@ tr.registerMock('./modules/googleutil', {
commit: sinon.stub()
}
},
getJWT: () => {
return {
authorize: sinon.stub()
};
},
getJWT: () => ({ authorize: () => { throw new Error('JWT.authorize() should be run via googleutil.authorize(JWT)'); } }),
authorize: () => Promise.resolve(),
getNewEdit: () => Promise.resolve({}),
getTrack: () => Promise.resolve({ releases: [{ versionCodes: [1, 2, 3 ]}]}),
updateTrack: () => Promise.resolve({}),
Expand Down
Loading

0 comments on commit 206e070

Please sign in to comment.