haikuwebkit/Websites/perf.webkit.org/server-tests/privileged-api-upate-run-st...

128 lines
5.4 KiB
JavaScript
Raw Permalink Normal View History

Invalid token error when trying to create an A/B analysis for a range https://bugs.webkit.org/show_bug.cgi?id=158679 Reviewed by Chris Dumez. The problem in this particular case was due to another website overriding cookies for our subdomain. Make PrivilegedAPI robust against its token becoming invalid in general to fix the bug since the cookie is only available under /privileged-api/ and the v3 UI can't access it for security reasons. This patch factors out PrivilegedAPI out of remote.js so that it can be tested separately in server tests as well as unit tests even though RemoteAPI itself is implemented differently in each case. * init-database.sql: Added a forgotten default value "false" to run_marked_outlier. * public/v3/index.html: * public/v3/privileged-api.js: Added. Extracted out of public/v3/remote.js. (PrivilegedAPI.sendRequest): Fixed the bug. When the initial request fails with "InvalidToken" error, re-generate the token and re-issue the request. (PrivilegedAPI.requestCSRFToken): * public/v3/remote.js: (RemoteAPI.postJSON): Added to match tools/js/remote.js. (RemoteAPI.postJSONWithStatus): Ditto. (PrivilegedAPI): Moved to privileged-api.js. * server-tests/api-measurement-set-tests.js: Removed the unused require for crypto. * server-tests/privileged-api-upate-run-status.js: Added tests for /privileged-api/update-run-status. * server-tests/resources/test-server.js: (TestServer.prototype.inject): Clear the cookies as well as tokens in PrivilegedAPI. * tools/js/remote.js: (RemoteAPI): Added the support for PrivilegedAPI by making cookie set by the server persist. (RemoteAPI.prototype.clearCookies): Added for tests. (RemoteAPI.prototype.postJSON): Make sure sendHttpRequest always sends a valid JSON. (RemoteAPI.prototype.postJSONWithStatus): Added since this API is used PrivilegedAPI. (RemoteAPI.prototype.sendHttpRequest): Retain the cookie set by the server and send it back in each request. * tools/js/v3-models.js: * unit-tests/privileged-api-tests.js: Added unit tests for PrivilegedAPI. * unit-tests/resources/mock-remote-api.js: (MockRemoteAPI.postJSON): Added for unit testing. (MockRemoteAPI.postJSONWithStatus): Ditto. Canonical link: https://commits.webkit.org/176780@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202001 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-13 19:47:38 +00:00
'use strict';
require('../tools/js/v3-models.js');
const assert = require('assert');
const TestServer = require('./resources/test-server.js');
const addBuilderForReport = require('./resources/common-operations.js').addBuilderForReport;
const prepareServerTest = require('./resources/common-operations.js').prepareServerTest;
Invalid token error when trying to create an A/B analysis for a range https://bugs.webkit.org/show_bug.cgi?id=158679 Reviewed by Chris Dumez. The problem in this particular case was due to another website overriding cookies for our subdomain. Make PrivilegedAPI robust against its token becoming invalid in general to fix the bug since the cookie is only available under /privileged-api/ and the v3 UI can't access it for security reasons. This patch factors out PrivilegedAPI out of remote.js so that it can be tested separately in server tests as well as unit tests even though RemoteAPI itself is implemented differently in each case. * init-database.sql: Added a forgotten default value "false" to run_marked_outlier. * public/v3/index.html: * public/v3/privileged-api.js: Added. Extracted out of public/v3/remote.js. (PrivilegedAPI.sendRequest): Fixed the bug. When the initial request fails with "InvalidToken" error, re-generate the token and re-issue the request. (PrivilegedAPI.requestCSRFToken): * public/v3/remote.js: (RemoteAPI.postJSON): Added to match tools/js/remote.js. (RemoteAPI.postJSONWithStatus): Ditto. (PrivilegedAPI): Moved to privileged-api.js. * server-tests/api-measurement-set-tests.js: Removed the unused require for crypto. * server-tests/privileged-api-upate-run-status.js: Added tests for /privileged-api/update-run-status. * server-tests/resources/test-server.js: (TestServer.prototype.inject): Clear the cookies as well as tokens in PrivilegedAPI. * tools/js/remote.js: (RemoteAPI): Added the support for PrivilegedAPI by making cookie set by the server persist. (RemoteAPI.prototype.clearCookies): Added for tests. (RemoteAPI.prototype.postJSON): Make sure sendHttpRequest always sends a valid JSON. (RemoteAPI.prototype.postJSONWithStatus): Added since this API is used PrivilegedAPI. (RemoteAPI.prototype.sendHttpRequest): Retain the cookie set by the server and send it back in each request. * tools/js/v3-models.js: * unit-tests/privileged-api-tests.js: Added unit tests for PrivilegedAPI. * unit-tests/resources/mock-remote-api.js: (MockRemoteAPI.postJSON): Added for unit testing. (MockRemoteAPI.postJSONWithStatus): Ditto. Canonical link: https://commits.webkit.org/176780@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202001 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-13 19:47:38 +00:00
describe("/privileged-api/update-run-status", function () {
prepareServerTest(this);
Invalid token error when trying to create an A/B analysis for a range https://bugs.webkit.org/show_bug.cgi?id=158679 Reviewed by Chris Dumez. The problem in this particular case was due to another website overriding cookies for our subdomain. Make PrivilegedAPI robust against its token becoming invalid in general to fix the bug since the cookie is only available under /privileged-api/ and the v3 UI can't access it for security reasons. This patch factors out PrivilegedAPI out of remote.js so that it can be tested separately in server tests as well as unit tests even though RemoteAPI itself is implemented differently in each case. * init-database.sql: Added a forgotten default value "false" to run_marked_outlier. * public/v3/index.html: * public/v3/privileged-api.js: Added. Extracted out of public/v3/remote.js. (PrivilegedAPI.sendRequest): Fixed the bug. When the initial request fails with "InvalidToken" error, re-generate the token and re-issue the request. (PrivilegedAPI.requestCSRFToken): * public/v3/remote.js: (RemoteAPI.postJSON): Added to match tools/js/remote.js. (RemoteAPI.postJSONWithStatus): Ditto. (PrivilegedAPI): Moved to privileged-api.js. * server-tests/api-measurement-set-tests.js: Removed the unused require for crypto. * server-tests/privileged-api-upate-run-status.js: Added tests for /privileged-api/update-run-status. * server-tests/resources/test-server.js: (TestServer.prototype.inject): Clear the cookies as well as tokens in PrivilegedAPI. * tools/js/remote.js: (RemoteAPI): Added the support for PrivilegedAPI by making cookie set by the server persist. (RemoteAPI.prototype.clearCookies): Added for tests. (RemoteAPI.prototype.postJSON): Make sure sendHttpRequest always sends a valid JSON. (RemoteAPI.prototype.postJSONWithStatus): Added since this API is used PrivilegedAPI. (RemoteAPI.prototype.sendHttpRequest): Retain the cookie set by the server and send it back in each request. * tools/js/v3-models.js: * unit-tests/privileged-api-tests.js: Added unit tests for PrivilegedAPI. * unit-tests/resources/mock-remote-api.js: (MockRemoteAPI.postJSON): Added for unit testing. (MockRemoteAPI.postJSONWithStatus): Ditto. Canonical link: https://commits.webkit.org/176780@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202001 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-13 19:47:38 +00:00
const reportWithRevision = [{
Refactor "builds" table "build_number" row to "build_tag" to fit more generic use cases. https://bugs.webkit.org/show_bug.cgi?id=203270 Reviewed by Ryosuke Niwa. Rename "build_number" to "build_tag" to fit more generic use cases. Add support to be backward compatible to accept reports contain either "buildNumber" or "buildTag". * browser-tests/index.html: * init-database.sql: * migrate-database.sql: Updated migration sql for this change. * public/admin/test-configurations.php: * public/api/measurement-set.php: * public/api/runs.php: * public/api/upload-root.php: Added support for both "buildNumber" and "buildTag". * public/include/report-processor.php: Added support for both "buildNumber" and "buildTag". * public/v3/models/builder.js: (Builder.prototype.urlForBuild): (Builder): (Build): (Build.prototype.buildTag): (Build.prototype.label): (Build.prototype.url): (Build.prototype.buildNumber): Deleted. * public/v3/models/measurement-adaptor.js: (MeasurementAdaptor): (MeasurementAdaptor.prototype.applyTo.return.build): * public/v3/pages/chart-pane-status-view.js: * public/v3/pages/test-freshness-page.js: (TestFreshnessPage.prototype._renderTooltip): * server-tests/admin-platforms-tests.js: (reportsForDifferentPlatforms): * server-tests/admin-reprocess-report-tests.js: * server-tests/api-commits-tests.js: * server-tests/api-manifest-tests.js: * server-tests/api-measurement-set-tests.js: * server-tests/api-report-tests.js: Added unit tests for testing "buildNumber" and "buildTag". (emptyReport): (reportWitMismatchingCommitTime): (reportWithOneSecondCommitTimeDifference): (emptySlaveReport): (makeReport): (reportWithSameSubtestName): * server-tests/api-upload-root-tests.js: Added unit tests for testing "buildNumber" and "buildTag". * server-tests/privileged-api-add-build-requests-tests.js: * server-tests/privileged-api-create-analysis-task-tests.js: * server-tests/privileged-api-create-test-group-tests.js: (createAnalysisTask): * server-tests/privileged-api-upate-run-status.js: * server-tests/privileged-api-update-test-group-tests.js: (async.createAnalysisTask): * server-tests/resources/mock-data.js: (MockData.addMockConfiguration): (MockData.sampleBuildData): (MockData.finishedBuildData): * server-tests/tools-sync-buildbot-integration-tests.js: * tools/js/buildbot-syncer.js: (BuildbotBuildEntry.prototype.initialize): (BuildbotBuildEntry.prototype.buildTag): (BuildbotBuildEntry.prototype.url): (BuildbotSyncer.prototype.urlForBuildTag): (BuildbotBuildEntry.prototype.buildNumber): Deleted. (BuildbotSyncer.prototype.urlForBuildNumber): Deleted. * unit-tests/analysis-task-tests.js: (measurementCluster): * unit-tests/buildbot-syncer-tests.js: * unit-tests/measurement-adaptor-tests.js: * unit-tests/measurement-set-analyzer-tests.js: * unit-tests/measurement-set-tests.js: * unit-tests/resources/mock-v3-models.js: Canonical link: https://commits.webkit.org/216795@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@251564 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-10-24 22:00:37 +00:00
"buildTag": "124",
Invalid token error when trying to create an A/B analysis for a range https://bugs.webkit.org/show_bug.cgi?id=158679 Reviewed by Chris Dumez. The problem in this particular case was due to another website overriding cookies for our subdomain. Make PrivilegedAPI robust against its token becoming invalid in general to fix the bug since the cookie is only available under /privileged-api/ and the v3 UI can't access it for security reasons. This patch factors out PrivilegedAPI out of remote.js so that it can be tested separately in server tests as well as unit tests even though RemoteAPI itself is implemented differently in each case. * init-database.sql: Added a forgotten default value "false" to run_marked_outlier. * public/v3/index.html: * public/v3/privileged-api.js: Added. Extracted out of public/v3/remote.js. (PrivilegedAPI.sendRequest): Fixed the bug. When the initial request fails with "InvalidToken" error, re-generate the token and re-issue the request. (PrivilegedAPI.requestCSRFToken): * public/v3/remote.js: (RemoteAPI.postJSON): Added to match tools/js/remote.js. (RemoteAPI.postJSONWithStatus): Ditto. (PrivilegedAPI): Moved to privileged-api.js. * server-tests/api-measurement-set-tests.js: Removed the unused require for crypto. * server-tests/privileged-api-upate-run-status.js: Added tests for /privileged-api/update-run-status. * server-tests/resources/test-server.js: (TestServer.prototype.inject): Clear the cookies as well as tokens in PrivilegedAPI. * tools/js/remote.js: (RemoteAPI): Added the support for PrivilegedAPI by making cookie set by the server persist. (RemoteAPI.prototype.clearCookies): Added for tests. (RemoteAPI.prototype.postJSON): Make sure sendHttpRequest always sends a valid JSON. (RemoteAPI.prototype.postJSONWithStatus): Added since this API is used PrivilegedAPI. (RemoteAPI.prototype.sendHttpRequest): Retain the cookie set by the server and send it back in each request. * tools/js/v3-models.js: * unit-tests/privileged-api-tests.js: Added unit tests for PrivilegedAPI. * unit-tests/resources/mock-remote-api.js: (MockRemoteAPI.postJSON): Added for unit testing. (MockRemoteAPI.postJSONWithStatus): Ditto. Canonical link: https://commits.webkit.org/176780@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202001 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-13 19:47:38 +00:00
"buildTime": "2013-02-28T15:34:51",
"revisions": {
"WebKit": {
"revision": "191622",
"timestamp": (new Date(1445945816878)).toISOString(),
},
},
"builderName": "someBuilder",
"builderPassword": "somePassword",
"platform": "some platform",
"tests": {
"Suite": {
"tests": {
"test1": {
"metrics": {"Time": { "current": [11] }}
}
}
},
}}];
it("should be able to mark a run as an outlier", () => {
Invalid token error when trying to create an A/B analysis for a range https://bugs.webkit.org/show_bug.cgi?id=158679 Reviewed by Chris Dumez. The problem in this particular case was due to another website overriding cookies for our subdomain. Make PrivilegedAPI robust against its token becoming invalid in general to fix the bug since the cookie is only available under /privileged-api/ and the v3 UI can't access it for security reasons. This patch factors out PrivilegedAPI out of remote.js so that it can be tested separately in server tests as well as unit tests even though RemoteAPI itself is implemented differently in each case. * init-database.sql: Added a forgotten default value "false" to run_marked_outlier. * public/v3/index.html: * public/v3/privileged-api.js: Added. Extracted out of public/v3/remote.js. (PrivilegedAPI.sendRequest): Fixed the bug. When the initial request fails with "InvalidToken" error, re-generate the token and re-issue the request. (PrivilegedAPI.requestCSRFToken): * public/v3/remote.js: (RemoteAPI.postJSON): Added to match tools/js/remote.js. (RemoteAPI.postJSONWithStatus): Ditto. (PrivilegedAPI): Moved to privileged-api.js. * server-tests/api-measurement-set-tests.js: Removed the unused require for crypto. * server-tests/privileged-api-upate-run-status.js: Added tests for /privileged-api/update-run-status. * server-tests/resources/test-server.js: (TestServer.prototype.inject): Clear the cookies as well as tokens in PrivilegedAPI. * tools/js/remote.js: (RemoteAPI): Added the support for PrivilegedAPI by making cookie set by the server persist. (RemoteAPI.prototype.clearCookies): Added for tests. (RemoteAPI.prototype.postJSON): Make sure sendHttpRequest always sends a valid JSON. (RemoteAPI.prototype.postJSONWithStatus): Added since this API is used PrivilegedAPI. (RemoteAPI.prototype.sendHttpRequest): Retain the cookie set by the server and send it back in each request. * tools/js/v3-models.js: * unit-tests/privileged-api-tests.js: Added unit tests for PrivilegedAPI. * unit-tests/resources/mock-remote-api.js: (MockRemoteAPI.postJSON): Added for unit testing. (MockRemoteAPI.postJSONWithStatus): Ditto. Canonical link: https://commits.webkit.org/176780@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202001 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-13 19:47:38 +00:00
const db = TestServer.database();
let id;
return addBuilderForReport(reportWithRevision[0]).then(() => {
Invalid token error when trying to create an A/B analysis for a range https://bugs.webkit.org/show_bug.cgi?id=158679 Reviewed by Chris Dumez. The problem in this particular case was due to another website overriding cookies for our subdomain. Make PrivilegedAPI robust against its token becoming invalid in general to fix the bug since the cookie is only available under /privileged-api/ and the v3 UI can't access it for security reasons. This patch factors out PrivilegedAPI out of remote.js so that it can be tested separately in server tests as well as unit tests even though RemoteAPI itself is implemented differently in each case. * init-database.sql: Added a forgotten default value "false" to run_marked_outlier. * public/v3/index.html: * public/v3/privileged-api.js: Added. Extracted out of public/v3/remote.js. (PrivilegedAPI.sendRequest): Fixed the bug. When the initial request fails with "InvalidToken" error, re-generate the token and re-issue the request. (PrivilegedAPI.requestCSRFToken): * public/v3/remote.js: (RemoteAPI.postJSON): Added to match tools/js/remote.js. (RemoteAPI.postJSONWithStatus): Ditto. (PrivilegedAPI): Moved to privileged-api.js. * server-tests/api-measurement-set-tests.js: Removed the unused require for crypto. * server-tests/privileged-api-upate-run-status.js: Added tests for /privileged-api/update-run-status. * server-tests/resources/test-server.js: (TestServer.prototype.inject): Clear the cookies as well as tokens in PrivilegedAPI. * tools/js/remote.js: (RemoteAPI): Added the support for PrivilegedAPI by making cookie set by the server persist. (RemoteAPI.prototype.clearCookies): Added for tests. (RemoteAPI.prototype.postJSON): Make sure sendHttpRequest always sends a valid JSON. (RemoteAPI.prototype.postJSONWithStatus): Added since this API is used PrivilegedAPI. (RemoteAPI.prototype.sendHttpRequest): Retain the cookie set by the server and send it back in each request. * tools/js/v3-models.js: * unit-tests/privileged-api-tests.js: Added unit tests for PrivilegedAPI. * unit-tests/resources/mock-remote-api.js: (MockRemoteAPI.postJSON): Added for unit testing. (MockRemoteAPI.postJSONWithStatus): Ditto. Canonical link: https://commits.webkit.org/176780@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202001 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-13 19:47:38 +00:00
return TestServer.remoteAPI().postJSON('/api/report/', reportWithRevision);
}).then((response) => {
Make server test run with new node version https://bugs.webkit.org/show_bug.cgi?id=222463 Change assert.equal to assert.strictEqual since node deprecated this API Add a new function console.assert to make sure it will throw an error Reviewed by Ryosuke Niwa. * public/v3/models/repository.js: (Repository.sortByNamePreferringOnesWithURL): (Repository): * server-tests/admin-platforms-tests.js: * server-tests/admin-reprocess-report-tests.js: * server-tests/api-build-requests-tests.js: (return.TestServer.remoteAPI.getJSON.string_appeared_here.then): * server-tests/api-commits-tests.js: (assertCommitIsSameAsOneSubmitted): (return.TestServer.remoteAPI.getJSON.string_appeared_here.then): * server-tests/api-manifest-tests.js: (return.TestServer.remoteAPI.getJSON.string_appeared_here.then): * server-tests/api-measurement-set-tests.js: * server-tests/api-report-commits-tests.js: (emptyReport.then): (async initialReportCommits): (async setUpTestsWithExpectedStatus): (async testWithExpectedFailure): * server-tests/api-report-tests.js: (emptyReport.then): * server-tests/api-test-groups.js: * server-tests/api-update-triggerable-tests.js: (update.then): (then.response.db.selectAll.string_appeared_here.then): (then.db.selectAll.string_appeared_here.then): (then.Manifest.fetch.then): * server-tests/api-upload-root-tests.js: * server-tests/api-uploaded-file-tests.js: (return.TestServer.remoteAPI.getJSON.string_appeared_here.then): * server-tests/privileged-api-add-build-requests-tests.js: (async createAnalysisTask): (const.commitSet.of.updatedGroups.0.requestedCommitSets): * server-tests/privileged-api-create-analysis-task-tests.js: * server-tests/privileged-api-create-test-group-tests.js: (createAnalysisTask): (return.createAnalysisTask.string_appeared_here.then): (return.addTriggerableAndCreateTask.string_appeared_here.then): (string_appeared_here.then): * server-tests/privileged-api-upate-run-status.js: * server-tests/privileged-api-update-test-group-tests.js: (async createAnalysisTask): * server-tests/privileged-api-upload-file-tests.js: (TestServer.testConfig.uploadFileLimitInMB.1.then): * server-tests/resources/common-operations.js: (async assertThrows): * server-tests/resources/temporary-file.js: (TemporaryFile.makeTemporaryFileOfSizeInMB): * server-tests/tools-buildbot-triggerable-tests.js: (assertRequestAndResolve): (then.refetchManifest.then): (getBuilderNameToIDMapPromise.then): * server-tests/tools-os-build-fetcher-tests.js: * server-tests/tools-sync-buildbot-integration-tests.js: (assertAndResolveRequest): * tools/js/assert-override.js: Added. (makeConsoleAssertThrow): * tools/js/buildbot-syncer.js: (BuildbotBuildEntry.prototype.initialize): (BuildbotBuildEntry.prototype.buildRequestStatusIfUpdateIsNeeded): (BuildbotBuildEntry): (BuildbotSyncer.prototype.scheduleRequest): (BuildbotSyncer._loadConfig): (BuildbotSyncer._parseRepositoryGroup): (BuildbotSyncer._validateAndMergeConfig): (BuildbotSyncer): * tools/js/buildbot-triggerable.js: (BuildbotTriggerable.prototype._validateRequests): * tools/js/markup-component.js: (const.MarkupDocument.new.MarkupDocument.prototype._idForClone): (const.MarkupDocument.new.MarkupDocument.prototype.markup): * tools/js/os-build-fetcher.js: (prototype._addOwnedCommitsForBuild): * tools/js/remote.js: (NodeRemoteAPI.prototype.configure): * tools/js/v3-models.js: * unit-tests/commit-set-tests.js: Canonical link: https://commits.webkit.org/234972@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274036 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-03-06 14:31:56 +00:00
assert.strictEqual(response['status'], 'OK');
Invalid token error when trying to create an A/B analysis for a range https://bugs.webkit.org/show_bug.cgi?id=158679 Reviewed by Chris Dumez. The problem in this particular case was due to another website overriding cookies for our subdomain. Make PrivilegedAPI robust against its token becoming invalid in general to fix the bug since the cookie is only available under /privileged-api/ and the v3 UI can't access it for security reasons. This patch factors out PrivilegedAPI out of remote.js so that it can be tested separately in server tests as well as unit tests even though RemoteAPI itself is implemented differently in each case. * init-database.sql: Added a forgotten default value "false" to run_marked_outlier. * public/v3/index.html: * public/v3/privileged-api.js: Added. Extracted out of public/v3/remote.js. (PrivilegedAPI.sendRequest): Fixed the bug. When the initial request fails with "InvalidToken" error, re-generate the token and re-issue the request. (PrivilegedAPI.requestCSRFToken): * public/v3/remote.js: (RemoteAPI.postJSON): Added to match tools/js/remote.js. (RemoteAPI.postJSONWithStatus): Ditto. (PrivilegedAPI): Moved to privileged-api.js. * server-tests/api-measurement-set-tests.js: Removed the unused require for crypto. * server-tests/privileged-api-upate-run-status.js: Added tests for /privileged-api/update-run-status. * server-tests/resources/test-server.js: (TestServer.prototype.inject): Clear the cookies as well as tokens in PrivilegedAPI. * tools/js/remote.js: (RemoteAPI): Added the support for PrivilegedAPI by making cookie set by the server persist. (RemoteAPI.prototype.clearCookies): Added for tests. (RemoteAPI.prototype.postJSON): Make sure sendHttpRequest always sends a valid JSON. (RemoteAPI.prototype.postJSONWithStatus): Added since this API is used PrivilegedAPI. (RemoteAPI.prototype.sendHttpRequest): Retain the cookie set by the server and send it back in each request. * tools/js/v3-models.js: * unit-tests/privileged-api-tests.js: Added unit tests for PrivilegedAPI. * unit-tests/resources/mock-remote-api.js: (MockRemoteAPI.postJSON): Added for unit testing. (MockRemoteAPI.postJSONWithStatus): Ditto. Canonical link: https://commits.webkit.org/176780@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202001 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-13 19:47:38 +00:00
return db.selectAll('test_runs');
}).then((runRows) => {
Make server test run with new node version https://bugs.webkit.org/show_bug.cgi?id=222463 Change assert.equal to assert.strictEqual since node deprecated this API Add a new function console.assert to make sure it will throw an error Reviewed by Ryosuke Niwa. * public/v3/models/repository.js: (Repository.sortByNamePreferringOnesWithURL): (Repository): * server-tests/admin-platforms-tests.js: * server-tests/admin-reprocess-report-tests.js: * server-tests/api-build-requests-tests.js: (return.TestServer.remoteAPI.getJSON.string_appeared_here.then): * server-tests/api-commits-tests.js: (assertCommitIsSameAsOneSubmitted): (return.TestServer.remoteAPI.getJSON.string_appeared_here.then): * server-tests/api-manifest-tests.js: (return.TestServer.remoteAPI.getJSON.string_appeared_here.then): * server-tests/api-measurement-set-tests.js: * server-tests/api-report-commits-tests.js: (emptyReport.then): (async initialReportCommits): (async setUpTestsWithExpectedStatus): (async testWithExpectedFailure): * server-tests/api-report-tests.js: (emptyReport.then): * server-tests/api-test-groups.js: * server-tests/api-update-triggerable-tests.js: (update.then): (then.response.db.selectAll.string_appeared_here.then): (then.db.selectAll.string_appeared_here.then): (then.Manifest.fetch.then): * server-tests/api-upload-root-tests.js: * server-tests/api-uploaded-file-tests.js: (return.TestServer.remoteAPI.getJSON.string_appeared_here.then): * server-tests/privileged-api-add-build-requests-tests.js: (async createAnalysisTask): (const.commitSet.of.updatedGroups.0.requestedCommitSets): * server-tests/privileged-api-create-analysis-task-tests.js: * server-tests/privileged-api-create-test-group-tests.js: (createAnalysisTask): (return.createAnalysisTask.string_appeared_here.then): (return.addTriggerableAndCreateTask.string_appeared_here.then): (string_appeared_here.then): * server-tests/privileged-api-upate-run-status.js: * server-tests/privileged-api-update-test-group-tests.js: (async createAnalysisTask): * server-tests/privileged-api-upload-file-tests.js: (TestServer.testConfig.uploadFileLimitInMB.1.then): * server-tests/resources/common-operations.js: (async assertThrows): * server-tests/resources/temporary-file.js: (TemporaryFile.makeTemporaryFileOfSizeInMB): * server-tests/tools-buildbot-triggerable-tests.js: (assertRequestAndResolve): (then.refetchManifest.then): (getBuilderNameToIDMapPromise.then): * server-tests/tools-os-build-fetcher-tests.js: * server-tests/tools-sync-buildbot-integration-tests.js: (assertAndResolveRequest): * tools/js/assert-override.js: Added. (makeConsoleAssertThrow): * tools/js/buildbot-syncer.js: (BuildbotBuildEntry.prototype.initialize): (BuildbotBuildEntry.prototype.buildRequestStatusIfUpdateIsNeeded): (BuildbotBuildEntry): (BuildbotSyncer.prototype.scheduleRequest): (BuildbotSyncer._loadConfig): (BuildbotSyncer._parseRepositoryGroup): (BuildbotSyncer._validateAndMergeConfig): (BuildbotSyncer): * tools/js/buildbot-triggerable.js: (BuildbotTriggerable.prototype._validateRequests): * tools/js/markup-component.js: (const.MarkupDocument.new.MarkupDocument.prototype._idForClone): (const.MarkupDocument.new.MarkupDocument.prototype.markup): * tools/js/os-build-fetcher.js: (prototype._addOwnedCommitsForBuild): * tools/js/remote.js: (NodeRemoteAPI.prototype.configure): * tools/js/v3-models.js: * unit-tests/commit-set-tests.js: Canonical link: https://commits.webkit.org/234972@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274036 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-03-06 14:31:56 +00:00
assert.strictEqual(runRows.length, 1);
assert.strictEqual(runRows[0]['mean_cache'], 11);
assert.strictEqual(runRows[0]['iteration_count_cache'], 1);
assert.strictEqual(runRows[0]['marked_outlier'], false);
Invalid token error when trying to create an A/B analysis for a range https://bugs.webkit.org/show_bug.cgi?id=158679 Reviewed by Chris Dumez. The problem in this particular case was due to another website overriding cookies for our subdomain. Make PrivilegedAPI robust against its token becoming invalid in general to fix the bug since the cookie is only available under /privileged-api/ and the v3 UI can't access it for security reasons. This patch factors out PrivilegedAPI out of remote.js so that it can be tested separately in server tests as well as unit tests even though RemoteAPI itself is implemented differently in each case. * init-database.sql: Added a forgotten default value "false" to run_marked_outlier. * public/v3/index.html: * public/v3/privileged-api.js: Added. Extracted out of public/v3/remote.js. (PrivilegedAPI.sendRequest): Fixed the bug. When the initial request fails with "InvalidToken" error, re-generate the token and re-issue the request. (PrivilegedAPI.requestCSRFToken): * public/v3/remote.js: (RemoteAPI.postJSON): Added to match tools/js/remote.js. (RemoteAPI.postJSONWithStatus): Ditto. (PrivilegedAPI): Moved to privileged-api.js. * server-tests/api-measurement-set-tests.js: Removed the unused require for crypto. * server-tests/privileged-api-upate-run-status.js: Added tests for /privileged-api/update-run-status. * server-tests/resources/test-server.js: (TestServer.prototype.inject): Clear the cookies as well as tokens in PrivilegedAPI. * tools/js/remote.js: (RemoteAPI): Added the support for PrivilegedAPI by making cookie set by the server persist. (RemoteAPI.prototype.clearCookies): Added for tests. (RemoteAPI.prototype.postJSON): Make sure sendHttpRequest always sends a valid JSON. (RemoteAPI.prototype.postJSONWithStatus): Added since this API is used PrivilegedAPI. (RemoteAPI.prototype.sendHttpRequest): Retain the cookie set by the server and send it back in each request. * tools/js/v3-models.js: * unit-tests/privileged-api-tests.js: Added unit tests for PrivilegedAPI. * unit-tests/resources/mock-remote-api.js: (MockRemoteAPI.postJSON): Added for unit testing. (MockRemoteAPI.postJSONWithStatus): Ditto. Canonical link: https://commits.webkit.org/176780@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202001 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-13 19:47:38 +00:00
id = runRows[0]['id'];
return PrivilegedAPI.requestCSRFToken();
}).then(() => {
Invalid token error when trying to create an A/B analysis for a range https://bugs.webkit.org/show_bug.cgi?id=158679 Reviewed by Chris Dumez. The problem in this particular case was due to another website overriding cookies for our subdomain. Make PrivilegedAPI robust against its token becoming invalid in general to fix the bug since the cookie is only available under /privileged-api/ and the v3 UI can't access it for security reasons. This patch factors out PrivilegedAPI out of remote.js so that it can be tested separately in server tests as well as unit tests even though RemoteAPI itself is implemented differently in each case. * init-database.sql: Added a forgotten default value "false" to run_marked_outlier. * public/v3/index.html: * public/v3/privileged-api.js: Added. Extracted out of public/v3/remote.js. (PrivilegedAPI.sendRequest): Fixed the bug. When the initial request fails with "InvalidToken" error, re-generate the token and re-issue the request. (PrivilegedAPI.requestCSRFToken): * public/v3/remote.js: (RemoteAPI.postJSON): Added to match tools/js/remote.js. (RemoteAPI.postJSONWithStatus): Ditto. (PrivilegedAPI): Moved to privileged-api.js. * server-tests/api-measurement-set-tests.js: Removed the unused require for crypto. * server-tests/privileged-api-upate-run-status.js: Added tests for /privileged-api/update-run-status. * server-tests/resources/test-server.js: (TestServer.prototype.inject): Clear the cookies as well as tokens in PrivilegedAPI. * tools/js/remote.js: (RemoteAPI): Added the support for PrivilegedAPI by making cookie set by the server persist. (RemoteAPI.prototype.clearCookies): Added for tests. (RemoteAPI.prototype.postJSON): Make sure sendHttpRequest always sends a valid JSON. (RemoteAPI.prototype.postJSONWithStatus): Added since this API is used PrivilegedAPI. (RemoteAPI.prototype.sendHttpRequest): Retain the cookie set by the server and send it back in each request. * tools/js/v3-models.js: * unit-tests/privileged-api-tests.js: Added unit tests for PrivilegedAPI. * unit-tests/resources/mock-remote-api.js: (MockRemoteAPI.postJSON): Added for unit testing. (MockRemoteAPI.postJSONWithStatus): Ditto. Canonical link: https://commits.webkit.org/176780@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202001 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-13 19:47:38 +00:00
return PrivilegedAPI.sendRequest('update-run-status', {'run': id, 'markedOutlier': true, 'token': PrivilegedAPI._token});
}).then(() => {
Invalid token error when trying to create an A/B analysis for a range https://bugs.webkit.org/show_bug.cgi?id=158679 Reviewed by Chris Dumez. The problem in this particular case was due to another website overriding cookies for our subdomain. Make PrivilegedAPI robust against its token becoming invalid in general to fix the bug since the cookie is only available under /privileged-api/ and the v3 UI can't access it for security reasons. This patch factors out PrivilegedAPI out of remote.js so that it can be tested separately in server tests as well as unit tests even though RemoteAPI itself is implemented differently in each case. * init-database.sql: Added a forgotten default value "false" to run_marked_outlier. * public/v3/index.html: * public/v3/privileged-api.js: Added. Extracted out of public/v3/remote.js. (PrivilegedAPI.sendRequest): Fixed the bug. When the initial request fails with "InvalidToken" error, re-generate the token and re-issue the request. (PrivilegedAPI.requestCSRFToken): * public/v3/remote.js: (RemoteAPI.postJSON): Added to match tools/js/remote.js. (RemoteAPI.postJSONWithStatus): Ditto. (PrivilegedAPI): Moved to privileged-api.js. * server-tests/api-measurement-set-tests.js: Removed the unused require for crypto. * server-tests/privileged-api-upate-run-status.js: Added tests for /privileged-api/update-run-status. * server-tests/resources/test-server.js: (TestServer.prototype.inject): Clear the cookies as well as tokens in PrivilegedAPI. * tools/js/remote.js: (RemoteAPI): Added the support for PrivilegedAPI by making cookie set by the server persist. (RemoteAPI.prototype.clearCookies): Added for tests. (RemoteAPI.prototype.postJSON): Make sure sendHttpRequest always sends a valid JSON. (RemoteAPI.prototype.postJSONWithStatus): Added since this API is used PrivilegedAPI. (RemoteAPI.prototype.sendHttpRequest): Retain the cookie set by the server and send it back in each request. * tools/js/v3-models.js: * unit-tests/privileged-api-tests.js: Added unit tests for PrivilegedAPI. * unit-tests/resources/mock-remote-api.js: (MockRemoteAPI.postJSON): Added for unit testing. (MockRemoteAPI.postJSONWithStatus): Ditto. Canonical link: https://commits.webkit.org/176780@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202001 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-13 19:47:38 +00:00
return db.selectAll('test_runs');
}).then((runRows) => {
Make server test run with new node version https://bugs.webkit.org/show_bug.cgi?id=222463 Change assert.equal to assert.strictEqual since node deprecated this API Add a new function console.assert to make sure it will throw an error Reviewed by Ryosuke Niwa. * public/v3/models/repository.js: (Repository.sortByNamePreferringOnesWithURL): (Repository): * server-tests/admin-platforms-tests.js: * server-tests/admin-reprocess-report-tests.js: * server-tests/api-build-requests-tests.js: (return.TestServer.remoteAPI.getJSON.string_appeared_here.then): * server-tests/api-commits-tests.js: (assertCommitIsSameAsOneSubmitted): (return.TestServer.remoteAPI.getJSON.string_appeared_here.then): * server-tests/api-manifest-tests.js: (return.TestServer.remoteAPI.getJSON.string_appeared_here.then): * server-tests/api-measurement-set-tests.js: * server-tests/api-report-commits-tests.js: (emptyReport.then): (async initialReportCommits): (async setUpTestsWithExpectedStatus): (async testWithExpectedFailure): * server-tests/api-report-tests.js: (emptyReport.then): * server-tests/api-test-groups.js: * server-tests/api-update-triggerable-tests.js: (update.then): (then.response.db.selectAll.string_appeared_here.then): (then.db.selectAll.string_appeared_here.then): (then.Manifest.fetch.then): * server-tests/api-upload-root-tests.js: * server-tests/api-uploaded-file-tests.js: (return.TestServer.remoteAPI.getJSON.string_appeared_here.then): * server-tests/privileged-api-add-build-requests-tests.js: (async createAnalysisTask): (const.commitSet.of.updatedGroups.0.requestedCommitSets): * server-tests/privileged-api-create-analysis-task-tests.js: * server-tests/privileged-api-create-test-group-tests.js: (createAnalysisTask): (return.createAnalysisTask.string_appeared_here.then): (return.addTriggerableAndCreateTask.string_appeared_here.then): (string_appeared_here.then): * server-tests/privileged-api-upate-run-status.js: * server-tests/privileged-api-update-test-group-tests.js: (async createAnalysisTask): * server-tests/privileged-api-upload-file-tests.js: (TestServer.testConfig.uploadFileLimitInMB.1.then): * server-tests/resources/common-operations.js: (async assertThrows): * server-tests/resources/temporary-file.js: (TemporaryFile.makeTemporaryFileOfSizeInMB): * server-tests/tools-buildbot-triggerable-tests.js: (assertRequestAndResolve): (then.refetchManifest.then): (getBuilderNameToIDMapPromise.then): * server-tests/tools-os-build-fetcher-tests.js: * server-tests/tools-sync-buildbot-integration-tests.js: (assertAndResolveRequest): * tools/js/assert-override.js: Added. (makeConsoleAssertThrow): * tools/js/buildbot-syncer.js: (BuildbotBuildEntry.prototype.initialize): (BuildbotBuildEntry.prototype.buildRequestStatusIfUpdateIsNeeded): (BuildbotBuildEntry): (BuildbotSyncer.prototype.scheduleRequest): (BuildbotSyncer._loadConfig): (BuildbotSyncer._parseRepositoryGroup): (BuildbotSyncer._validateAndMergeConfig): (BuildbotSyncer): * tools/js/buildbot-triggerable.js: (BuildbotTriggerable.prototype._validateRequests): * tools/js/markup-component.js: (const.MarkupDocument.new.MarkupDocument.prototype._idForClone): (const.MarkupDocument.new.MarkupDocument.prototype.markup): * tools/js/os-build-fetcher.js: (prototype._addOwnedCommitsForBuild): * tools/js/remote.js: (NodeRemoteAPI.prototype.configure): * tools/js/v3-models.js: * unit-tests/commit-set-tests.js: Canonical link: https://commits.webkit.org/234972@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274036 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-03-06 14:31:56 +00:00
assert.strictEqual(runRows.length, 1);
assert.strictEqual(runRows[0]['mean_cache'], 11);
assert.strictEqual(runRows[0]['iteration_count_cache'], 1);
assert.strictEqual(runRows[0]['marked_outlier'], true);
});
Invalid token error when trying to create an A/B analysis for a range https://bugs.webkit.org/show_bug.cgi?id=158679 Reviewed by Chris Dumez. The problem in this particular case was due to another website overriding cookies for our subdomain. Make PrivilegedAPI robust against its token becoming invalid in general to fix the bug since the cookie is only available under /privileged-api/ and the v3 UI can't access it for security reasons. This patch factors out PrivilegedAPI out of remote.js so that it can be tested separately in server tests as well as unit tests even though RemoteAPI itself is implemented differently in each case. * init-database.sql: Added a forgotten default value "false" to run_marked_outlier. * public/v3/index.html: * public/v3/privileged-api.js: Added. Extracted out of public/v3/remote.js. (PrivilegedAPI.sendRequest): Fixed the bug. When the initial request fails with "InvalidToken" error, re-generate the token and re-issue the request. (PrivilegedAPI.requestCSRFToken): * public/v3/remote.js: (RemoteAPI.postJSON): Added to match tools/js/remote.js. (RemoteAPI.postJSONWithStatus): Ditto. (PrivilegedAPI): Moved to privileged-api.js. * server-tests/api-measurement-set-tests.js: Removed the unused require for crypto. * server-tests/privileged-api-upate-run-status.js: Added tests for /privileged-api/update-run-status. * server-tests/resources/test-server.js: (TestServer.prototype.inject): Clear the cookies as well as tokens in PrivilegedAPI. * tools/js/remote.js: (RemoteAPI): Added the support for PrivilegedAPI by making cookie set by the server persist. (RemoteAPI.prototype.clearCookies): Added for tests. (RemoteAPI.prototype.postJSON): Make sure sendHttpRequest always sends a valid JSON. (RemoteAPI.prototype.postJSONWithStatus): Added since this API is used PrivilegedAPI. (RemoteAPI.prototype.sendHttpRequest): Retain the cookie set by the server and send it back in each request. * tools/js/v3-models.js: * unit-tests/privileged-api-tests.js: Added unit tests for PrivilegedAPI. * unit-tests/resources/mock-remote-api.js: (MockRemoteAPI.postJSON): Added for unit testing. (MockRemoteAPI.postJSONWithStatus): Ditto. Canonical link: https://commits.webkit.org/176780@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202001 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-13 19:47:38 +00:00
});
it("should reject when the token is not set in cookie", () => {
Invalid token error when trying to create an A/B analysis for a range https://bugs.webkit.org/show_bug.cgi?id=158679 Reviewed by Chris Dumez. The problem in this particular case was due to another website overriding cookies for our subdomain. Make PrivilegedAPI robust against its token becoming invalid in general to fix the bug since the cookie is only available under /privileged-api/ and the v3 UI can't access it for security reasons. This patch factors out PrivilegedAPI out of remote.js so that it can be tested separately in server tests as well as unit tests even though RemoteAPI itself is implemented differently in each case. * init-database.sql: Added a forgotten default value "false" to run_marked_outlier. * public/v3/index.html: * public/v3/privileged-api.js: Added. Extracted out of public/v3/remote.js. (PrivilegedAPI.sendRequest): Fixed the bug. When the initial request fails with "InvalidToken" error, re-generate the token and re-issue the request. (PrivilegedAPI.requestCSRFToken): * public/v3/remote.js: (RemoteAPI.postJSON): Added to match tools/js/remote.js. (RemoteAPI.postJSONWithStatus): Ditto. (PrivilegedAPI): Moved to privileged-api.js. * server-tests/api-measurement-set-tests.js: Removed the unused require for crypto. * server-tests/privileged-api-upate-run-status.js: Added tests for /privileged-api/update-run-status. * server-tests/resources/test-server.js: (TestServer.prototype.inject): Clear the cookies as well as tokens in PrivilegedAPI. * tools/js/remote.js: (RemoteAPI): Added the support for PrivilegedAPI by making cookie set by the server persist. (RemoteAPI.prototype.clearCookies): Added for tests. (RemoteAPI.prototype.postJSON): Make sure sendHttpRequest always sends a valid JSON. (RemoteAPI.prototype.postJSONWithStatus): Added since this API is used PrivilegedAPI. (RemoteAPI.prototype.sendHttpRequest): Retain the cookie set by the server and send it back in each request. * tools/js/v3-models.js: * unit-tests/privileged-api-tests.js: Added unit tests for PrivilegedAPI. * unit-tests/resources/mock-remote-api.js: (MockRemoteAPI.postJSON): Added for unit testing. (MockRemoteAPI.postJSONWithStatus): Ditto. Canonical link: https://commits.webkit.org/176780@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202001 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-13 19:47:38 +00:00
const db = TestServer.database();
return addBuilderForReport(reportWithRevision[0]).then(() => {
Invalid token error when trying to create an A/B analysis for a range https://bugs.webkit.org/show_bug.cgi?id=158679 Reviewed by Chris Dumez. The problem in this particular case was due to another website overriding cookies for our subdomain. Make PrivilegedAPI robust against its token becoming invalid in general to fix the bug since the cookie is only available under /privileged-api/ and the v3 UI can't access it for security reasons. This patch factors out PrivilegedAPI out of remote.js so that it can be tested separately in server tests as well as unit tests even though RemoteAPI itself is implemented differently in each case. * init-database.sql: Added a forgotten default value "false" to run_marked_outlier. * public/v3/index.html: * public/v3/privileged-api.js: Added. Extracted out of public/v3/remote.js. (PrivilegedAPI.sendRequest): Fixed the bug. When the initial request fails with "InvalidToken" error, re-generate the token and re-issue the request. (PrivilegedAPI.requestCSRFToken): * public/v3/remote.js: (RemoteAPI.postJSON): Added to match tools/js/remote.js. (RemoteAPI.postJSONWithStatus): Ditto. (PrivilegedAPI): Moved to privileged-api.js. * server-tests/api-measurement-set-tests.js: Removed the unused require for crypto. * server-tests/privileged-api-upate-run-status.js: Added tests for /privileged-api/update-run-status. * server-tests/resources/test-server.js: (TestServer.prototype.inject): Clear the cookies as well as tokens in PrivilegedAPI. * tools/js/remote.js: (RemoteAPI): Added the support for PrivilegedAPI by making cookie set by the server persist. (RemoteAPI.prototype.clearCookies): Added for tests. (RemoteAPI.prototype.postJSON): Make sure sendHttpRequest always sends a valid JSON. (RemoteAPI.prototype.postJSONWithStatus): Added since this API is used PrivilegedAPI. (RemoteAPI.prototype.sendHttpRequest): Retain the cookie set by the server and send it back in each request. * tools/js/v3-models.js: * unit-tests/privileged-api-tests.js: Added unit tests for PrivilegedAPI. * unit-tests/resources/mock-remote-api.js: (MockRemoteAPI.postJSON): Added for unit testing. (MockRemoteAPI.postJSONWithStatus): Ditto. Canonical link: https://commits.webkit.org/176780@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202001 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-13 19:47:38 +00:00
return TestServer.remoteAPI().postJSON('/api/report/', reportWithRevision);
}).then((response) => {
Make server test run with new node version https://bugs.webkit.org/show_bug.cgi?id=222463 Change assert.equal to assert.strictEqual since node deprecated this API Add a new function console.assert to make sure it will throw an error Reviewed by Ryosuke Niwa. * public/v3/models/repository.js: (Repository.sortByNamePreferringOnesWithURL): (Repository): * server-tests/admin-platforms-tests.js: * server-tests/admin-reprocess-report-tests.js: * server-tests/api-build-requests-tests.js: (return.TestServer.remoteAPI.getJSON.string_appeared_here.then): * server-tests/api-commits-tests.js: (assertCommitIsSameAsOneSubmitted): (return.TestServer.remoteAPI.getJSON.string_appeared_here.then): * server-tests/api-manifest-tests.js: (return.TestServer.remoteAPI.getJSON.string_appeared_here.then): * server-tests/api-measurement-set-tests.js: * server-tests/api-report-commits-tests.js: (emptyReport.then): (async initialReportCommits): (async setUpTestsWithExpectedStatus): (async testWithExpectedFailure): * server-tests/api-report-tests.js: (emptyReport.then): * server-tests/api-test-groups.js: * server-tests/api-update-triggerable-tests.js: (update.then): (then.response.db.selectAll.string_appeared_here.then): (then.db.selectAll.string_appeared_here.then): (then.Manifest.fetch.then): * server-tests/api-upload-root-tests.js: * server-tests/api-uploaded-file-tests.js: (return.TestServer.remoteAPI.getJSON.string_appeared_here.then): * server-tests/privileged-api-add-build-requests-tests.js: (async createAnalysisTask): (const.commitSet.of.updatedGroups.0.requestedCommitSets): * server-tests/privileged-api-create-analysis-task-tests.js: * server-tests/privileged-api-create-test-group-tests.js: (createAnalysisTask): (return.createAnalysisTask.string_appeared_here.then): (return.addTriggerableAndCreateTask.string_appeared_here.then): (string_appeared_here.then): * server-tests/privileged-api-upate-run-status.js: * server-tests/privileged-api-update-test-group-tests.js: (async createAnalysisTask): * server-tests/privileged-api-upload-file-tests.js: (TestServer.testConfig.uploadFileLimitInMB.1.then): * server-tests/resources/common-operations.js: (async assertThrows): * server-tests/resources/temporary-file.js: (TemporaryFile.makeTemporaryFileOfSizeInMB): * server-tests/tools-buildbot-triggerable-tests.js: (assertRequestAndResolve): (then.refetchManifest.then): (getBuilderNameToIDMapPromise.then): * server-tests/tools-os-build-fetcher-tests.js: * server-tests/tools-sync-buildbot-integration-tests.js: (assertAndResolveRequest): * tools/js/assert-override.js: Added. (makeConsoleAssertThrow): * tools/js/buildbot-syncer.js: (BuildbotBuildEntry.prototype.initialize): (BuildbotBuildEntry.prototype.buildRequestStatusIfUpdateIsNeeded): (BuildbotBuildEntry): (BuildbotSyncer.prototype.scheduleRequest): (BuildbotSyncer._loadConfig): (BuildbotSyncer._parseRepositoryGroup): (BuildbotSyncer._validateAndMergeConfig): (BuildbotSyncer): * tools/js/buildbot-triggerable.js: (BuildbotTriggerable.prototype._validateRequests): * tools/js/markup-component.js: (const.MarkupDocument.new.MarkupDocument.prototype._idForClone): (const.MarkupDocument.new.MarkupDocument.prototype.markup): * tools/js/os-build-fetcher.js: (prototype._addOwnedCommitsForBuild): * tools/js/remote.js: (NodeRemoteAPI.prototype.configure): * tools/js/v3-models.js: * unit-tests/commit-set-tests.js: Canonical link: https://commits.webkit.org/234972@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274036 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-03-06 14:31:56 +00:00
assert.strictEqual(response['status'], 'OK');
Invalid token error when trying to create an A/B analysis for a range https://bugs.webkit.org/show_bug.cgi?id=158679 Reviewed by Chris Dumez. The problem in this particular case was due to another website overriding cookies for our subdomain. Make PrivilegedAPI robust against its token becoming invalid in general to fix the bug since the cookie is only available under /privileged-api/ and the v3 UI can't access it for security reasons. This patch factors out PrivilegedAPI out of remote.js so that it can be tested separately in server tests as well as unit tests even though RemoteAPI itself is implemented differently in each case. * init-database.sql: Added a forgotten default value "false" to run_marked_outlier. * public/v3/index.html: * public/v3/privileged-api.js: Added. Extracted out of public/v3/remote.js. (PrivilegedAPI.sendRequest): Fixed the bug. When the initial request fails with "InvalidToken" error, re-generate the token and re-issue the request. (PrivilegedAPI.requestCSRFToken): * public/v3/remote.js: (RemoteAPI.postJSON): Added to match tools/js/remote.js. (RemoteAPI.postJSONWithStatus): Ditto. (PrivilegedAPI): Moved to privileged-api.js. * server-tests/api-measurement-set-tests.js: Removed the unused require for crypto. * server-tests/privileged-api-upate-run-status.js: Added tests for /privileged-api/update-run-status. * server-tests/resources/test-server.js: (TestServer.prototype.inject): Clear the cookies as well as tokens in PrivilegedAPI. * tools/js/remote.js: (RemoteAPI): Added the support for PrivilegedAPI by making cookie set by the server persist. (RemoteAPI.prototype.clearCookies): Added for tests. (RemoteAPI.prototype.postJSON): Make sure sendHttpRequest always sends a valid JSON. (RemoteAPI.prototype.postJSONWithStatus): Added since this API is used PrivilegedAPI. (RemoteAPI.prototype.sendHttpRequest): Retain the cookie set by the server and send it back in each request. * tools/js/v3-models.js: * unit-tests/privileged-api-tests.js: Added unit tests for PrivilegedAPI. * unit-tests/resources/mock-remote-api.js: (MockRemoteAPI.postJSON): Added for unit testing. (MockRemoteAPI.postJSONWithStatus): Ditto. Canonical link: https://commits.webkit.org/176780@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202001 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-13 19:47:38 +00:00
return db.selectAll('test_runs');
}).then((runRows) => {
Make server test run with new node version https://bugs.webkit.org/show_bug.cgi?id=222463 Change assert.equal to assert.strictEqual since node deprecated this API Add a new function console.assert to make sure it will throw an error Reviewed by Ryosuke Niwa. * public/v3/models/repository.js: (Repository.sortByNamePreferringOnesWithURL): (Repository): * server-tests/admin-platforms-tests.js: * server-tests/admin-reprocess-report-tests.js: * server-tests/api-build-requests-tests.js: (return.TestServer.remoteAPI.getJSON.string_appeared_here.then): * server-tests/api-commits-tests.js: (assertCommitIsSameAsOneSubmitted): (return.TestServer.remoteAPI.getJSON.string_appeared_here.then): * server-tests/api-manifest-tests.js: (return.TestServer.remoteAPI.getJSON.string_appeared_here.then): * server-tests/api-measurement-set-tests.js: * server-tests/api-report-commits-tests.js: (emptyReport.then): (async initialReportCommits): (async setUpTestsWithExpectedStatus): (async testWithExpectedFailure): * server-tests/api-report-tests.js: (emptyReport.then): * server-tests/api-test-groups.js: * server-tests/api-update-triggerable-tests.js: (update.then): (then.response.db.selectAll.string_appeared_here.then): (then.db.selectAll.string_appeared_here.then): (then.Manifest.fetch.then): * server-tests/api-upload-root-tests.js: * server-tests/api-uploaded-file-tests.js: (return.TestServer.remoteAPI.getJSON.string_appeared_here.then): * server-tests/privileged-api-add-build-requests-tests.js: (async createAnalysisTask): (const.commitSet.of.updatedGroups.0.requestedCommitSets): * server-tests/privileged-api-create-analysis-task-tests.js: * server-tests/privileged-api-create-test-group-tests.js: (createAnalysisTask): (return.createAnalysisTask.string_appeared_here.then): (return.addTriggerableAndCreateTask.string_appeared_here.then): (string_appeared_here.then): * server-tests/privileged-api-upate-run-status.js: * server-tests/privileged-api-update-test-group-tests.js: (async createAnalysisTask): * server-tests/privileged-api-upload-file-tests.js: (TestServer.testConfig.uploadFileLimitInMB.1.then): * server-tests/resources/common-operations.js: (async assertThrows): * server-tests/resources/temporary-file.js: (TemporaryFile.makeTemporaryFileOfSizeInMB): * server-tests/tools-buildbot-triggerable-tests.js: (assertRequestAndResolve): (then.refetchManifest.then): (getBuilderNameToIDMapPromise.then): * server-tests/tools-os-build-fetcher-tests.js: * server-tests/tools-sync-buildbot-integration-tests.js: (assertAndResolveRequest): * tools/js/assert-override.js: Added. (makeConsoleAssertThrow): * tools/js/buildbot-syncer.js: (BuildbotBuildEntry.prototype.initialize): (BuildbotBuildEntry.prototype.buildRequestStatusIfUpdateIsNeeded): (BuildbotBuildEntry): (BuildbotSyncer.prototype.scheduleRequest): (BuildbotSyncer._loadConfig): (BuildbotSyncer._parseRepositoryGroup): (BuildbotSyncer._validateAndMergeConfig): (BuildbotSyncer): * tools/js/buildbot-triggerable.js: (BuildbotTriggerable.prototype._validateRequests): * tools/js/markup-component.js: (const.MarkupDocument.new.MarkupDocument.prototype._idForClone): (const.MarkupDocument.new.MarkupDocument.prototype.markup): * tools/js/os-build-fetcher.js: (prototype._addOwnedCommitsForBuild): * tools/js/remote.js: (NodeRemoteAPI.prototype.configure): * tools/js/v3-models.js: * unit-tests/commit-set-tests.js: Canonical link: https://commits.webkit.org/234972@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274036 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-03-06 14:31:56 +00:00
assert.strictEqual(runRows.length, 1);
assert.strictEqual(runRows[0]['marked_outlier'], false);
Invalid token error when trying to create an A/B analysis for a range https://bugs.webkit.org/show_bug.cgi?id=158679 Reviewed by Chris Dumez. The problem in this particular case was due to another website overriding cookies for our subdomain. Make PrivilegedAPI robust against its token becoming invalid in general to fix the bug since the cookie is only available under /privileged-api/ and the v3 UI can't access it for security reasons. This patch factors out PrivilegedAPI out of remote.js so that it can be tested separately in server tests as well as unit tests even though RemoteAPI itself is implemented differently in each case. * init-database.sql: Added a forgotten default value "false" to run_marked_outlier. * public/v3/index.html: * public/v3/privileged-api.js: Added. Extracted out of public/v3/remote.js. (PrivilegedAPI.sendRequest): Fixed the bug. When the initial request fails with "InvalidToken" error, re-generate the token and re-issue the request. (PrivilegedAPI.requestCSRFToken): * public/v3/remote.js: (RemoteAPI.postJSON): Added to match tools/js/remote.js. (RemoteAPI.postJSONWithStatus): Ditto. (PrivilegedAPI): Moved to privileged-api.js. * server-tests/api-measurement-set-tests.js: Removed the unused require for crypto. * server-tests/privileged-api-upate-run-status.js: Added tests for /privileged-api/update-run-status. * server-tests/resources/test-server.js: (TestServer.prototype.inject): Clear the cookies as well as tokens in PrivilegedAPI. * tools/js/remote.js: (RemoteAPI): Added the support for PrivilegedAPI by making cookie set by the server persist. (RemoteAPI.prototype.clearCookies): Added for tests. (RemoteAPI.prototype.postJSON): Make sure sendHttpRequest always sends a valid JSON. (RemoteAPI.prototype.postJSONWithStatus): Added since this API is used PrivilegedAPI. (RemoteAPI.prototype.sendHttpRequest): Retain the cookie set by the server and send it back in each request. * tools/js/v3-models.js: * unit-tests/privileged-api-tests.js: Added unit tests for PrivilegedAPI. * unit-tests/resources/mock-remote-api.js: (MockRemoteAPI.postJSON): Added for unit testing. (MockRemoteAPI.postJSONWithStatus): Ditto. Canonical link: https://commits.webkit.org/176780@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202001 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-13 19:47:38 +00:00
return PrivilegedAPI.requestCSRFToken();
}).then(() => {
Invalid token error when trying to create an A/B analysis for a range https://bugs.webkit.org/show_bug.cgi?id=158679 Reviewed by Chris Dumez. The problem in this particular case was due to another website overriding cookies for our subdomain. Make PrivilegedAPI robust against its token becoming invalid in general to fix the bug since the cookie is only available under /privileged-api/ and the v3 UI can't access it for security reasons. This patch factors out PrivilegedAPI out of remote.js so that it can be tested separately in server tests as well as unit tests even though RemoteAPI itself is implemented differently in each case. * init-database.sql: Added a forgotten default value "false" to run_marked_outlier. * public/v3/index.html: * public/v3/privileged-api.js: Added. Extracted out of public/v3/remote.js. (PrivilegedAPI.sendRequest): Fixed the bug. When the initial request fails with "InvalidToken" error, re-generate the token and re-issue the request. (PrivilegedAPI.requestCSRFToken): * public/v3/remote.js: (RemoteAPI.postJSON): Added to match tools/js/remote.js. (RemoteAPI.postJSONWithStatus): Ditto. (PrivilegedAPI): Moved to privileged-api.js. * server-tests/api-measurement-set-tests.js: Removed the unused require for crypto. * server-tests/privileged-api-upate-run-status.js: Added tests for /privileged-api/update-run-status. * server-tests/resources/test-server.js: (TestServer.prototype.inject): Clear the cookies as well as tokens in PrivilegedAPI. * tools/js/remote.js: (RemoteAPI): Added the support for PrivilegedAPI by making cookie set by the server persist. (RemoteAPI.prototype.clearCookies): Added for tests. (RemoteAPI.prototype.postJSON): Make sure sendHttpRequest always sends a valid JSON. (RemoteAPI.prototype.postJSONWithStatus): Added since this API is used PrivilegedAPI. (RemoteAPI.prototype.sendHttpRequest): Retain the cookie set by the server and send it back in each request. * tools/js/v3-models.js: * unit-tests/privileged-api-tests.js: Added unit tests for PrivilegedAPI. * unit-tests/resources/mock-remote-api.js: (MockRemoteAPI.postJSON): Added for unit testing. (MockRemoteAPI.postJSONWithStatus): Ditto. Canonical link: https://commits.webkit.org/176780@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202001 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-13 19:47:38 +00:00
RemoteAPI.clearCookies();
return RemoteAPI.postJSONWithStatus('/privileged-api/update-run-status', {token: PrivilegedAPI._token});
}).then(() => {
In-browser and node.js implementations of RemoteAPI should share some code https://bugs.webkit.org/show_bug.cgi?id=169695 Rubber-stamped by Antti Koivisto. Extracted CommonRemoteAPI out of RemoteAPI implementations for node.js and browser. * public/shared/common-remote.js: Added. (CommonRemoteAPI): Added. (CommonRemoteAPI.prototype.postJSON): Extracted from RemoteAPI. (CommonRemoteAPI.prototype.postJSONWithStatus): Ditto. (CommonRemoteAPI.prototype.getJSON): Ditto. (CommonRemoteAPI.prototype.getJSONWithStatus): Ditto. (CommonRemoteAPI.prototype.sendHttpRequest): Added. Needs to implemented by a subclass. (CommonRemoteAPI.prototype._asJSON): Added. (CommonRemoteAPI.prototype._checkStatus): Added. * public/v3/index.html: Include common-remote.js. * public/v3/privileged-api.js: (PrivilegedAPI): Use class now that we don't include data.js. (PrivilegedAPI.sendRequest): Modernized the code. (PrivilegedAPI.requestCSRFToken): Ditto. * public/v3/remote.js: (BrowserRemoteAPI): Renamed from RemoteAPI. window.RemoteAPI is now an instance of this class. (BrowserRemoteAPI.prototype.sendHttpRequest): Moved from RemoteAPI.sendHttpRequest. (BrowserRemoteAPI.prototype.sendHttpRequest): * server-tests/privileged-api-create-analysis-task-tests.js: Updated tests since NodeJSRemoteAPI now throws the JSON status as an error to be consistent with BrowserRemoteAPI. * server-tests/privileged-api-create-test-group-tests.js: Ditto. * server-tests/privileged-api-upate-run-status.js: Ditto. * tools/js/buildbot-triggerable.js: (BuildbotTriggerable.prototype.syncOnce): Just use postJSONWithStatus instead of manually checking the status. * tools/js/remote.js: (NodeRemoteAPI): Renamed from RemoteAPI. Still exported as RemoteAPI. (NodeRemoteAPI.prototype.constructor): (NodeRemoteAPI.prototype.sendHttpRequest): Modernized the code. Canonical link: https://commits.webkit.org/186683@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@214008 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-03-15 21:59:12 +00:00
assert(false, 'should never be reached');
}, (error) => {
Make server test run with new node version https://bugs.webkit.org/show_bug.cgi?id=222463 Change assert.equal to assert.strictEqual since node deprecated this API Add a new function console.assert to make sure it will throw an error Reviewed by Ryosuke Niwa. * public/v3/models/repository.js: (Repository.sortByNamePreferringOnesWithURL): (Repository): * server-tests/admin-platforms-tests.js: * server-tests/admin-reprocess-report-tests.js: * server-tests/api-build-requests-tests.js: (return.TestServer.remoteAPI.getJSON.string_appeared_here.then): * server-tests/api-commits-tests.js: (assertCommitIsSameAsOneSubmitted): (return.TestServer.remoteAPI.getJSON.string_appeared_here.then): * server-tests/api-manifest-tests.js: (return.TestServer.remoteAPI.getJSON.string_appeared_here.then): * server-tests/api-measurement-set-tests.js: * server-tests/api-report-commits-tests.js: (emptyReport.then): (async initialReportCommits): (async setUpTestsWithExpectedStatus): (async testWithExpectedFailure): * server-tests/api-report-tests.js: (emptyReport.then): * server-tests/api-test-groups.js: * server-tests/api-update-triggerable-tests.js: (update.then): (then.response.db.selectAll.string_appeared_here.then): (then.db.selectAll.string_appeared_here.then): (then.Manifest.fetch.then): * server-tests/api-upload-root-tests.js: * server-tests/api-uploaded-file-tests.js: (return.TestServer.remoteAPI.getJSON.string_appeared_here.then): * server-tests/privileged-api-add-build-requests-tests.js: (async createAnalysisTask): (const.commitSet.of.updatedGroups.0.requestedCommitSets): * server-tests/privileged-api-create-analysis-task-tests.js: * server-tests/privileged-api-create-test-group-tests.js: (createAnalysisTask): (return.createAnalysisTask.string_appeared_here.then): (return.addTriggerableAndCreateTask.string_appeared_here.then): (string_appeared_here.then): * server-tests/privileged-api-upate-run-status.js: * server-tests/privileged-api-update-test-group-tests.js: (async createAnalysisTask): * server-tests/privileged-api-upload-file-tests.js: (TestServer.testConfig.uploadFileLimitInMB.1.then): * server-tests/resources/common-operations.js: (async assertThrows): * server-tests/resources/temporary-file.js: (TemporaryFile.makeTemporaryFileOfSizeInMB): * server-tests/tools-buildbot-triggerable-tests.js: (assertRequestAndResolve): (then.refetchManifest.then): (getBuilderNameToIDMapPromise.then): * server-tests/tools-os-build-fetcher-tests.js: * server-tests/tools-sync-buildbot-integration-tests.js: (assertAndResolveRequest): * tools/js/assert-override.js: Added. (makeConsoleAssertThrow): * tools/js/buildbot-syncer.js: (BuildbotBuildEntry.prototype.initialize): (BuildbotBuildEntry.prototype.buildRequestStatusIfUpdateIsNeeded): (BuildbotBuildEntry): (BuildbotSyncer.prototype.scheduleRequest): (BuildbotSyncer._loadConfig): (BuildbotSyncer._parseRepositoryGroup): (BuildbotSyncer._validateAndMergeConfig): (BuildbotSyncer): * tools/js/buildbot-triggerable.js: (BuildbotTriggerable.prototype._validateRequests): * tools/js/markup-component.js: (const.MarkupDocument.new.MarkupDocument.prototype._idForClone): (const.MarkupDocument.new.MarkupDocument.prototype.markup): * tools/js/os-build-fetcher.js: (prototype._addOwnedCommitsForBuild): * tools/js/remote.js: (NodeRemoteAPI.prototype.configure): * tools/js/v3-models.js: * unit-tests/commit-set-tests.js: Canonical link: https://commits.webkit.org/234972@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274036 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-03-06 14:31:56 +00:00
assert.strictEqual(error, 'InvalidToken');
});
Invalid token error when trying to create an A/B analysis for a range https://bugs.webkit.org/show_bug.cgi?id=158679 Reviewed by Chris Dumez. The problem in this particular case was due to another website overriding cookies for our subdomain. Make PrivilegedAPI robust against its token becoming invalid in general to fix the bug since the cookie is only available under /privileged-api/ and the v3 UI can't access it for security reasons. This patch factors out PrivilegedAPI out of remote.js so that it can be tested separately in server tests as well as unit tests even though RemoteAPI itself is implemented differently in each case. * init-database.sql: Added a forgotten default value "false" to run_marked_outlier. * public/v3/index.html: * public/v3/privileged-api.js: Added. Extracted out of public/v3/remote.js. (PrivilegedAPI.sendRequest): Fixed the bug. When the initial request fails with "InvalidToken" error, re-generate the token and re-issue the request. (PrivilegedAPI.requestCSRFToken): * public/v3/remote.js: (RemoteAPI.postJSON): Added to match tools/js/remote.js. (RemoteAPI.postJSONWithStatus): Ditto. (PrivilegedAPI): Moved to privileged-api.js. * server-tests/api-measurement-set-tests.js: Removed the unused require for crypto. * server-tests/privileged-api-upate-run-status.js: Added tests for /privileged-api/update-run-status. * server-tests/resources/test-server.js: (TestServer.prototype.inject): Clear the cookies as well as tokens in PrivilegedAPI. * tools/js/remote.js: (RemoteAPI): Added the support for PrivilegedAPI by making cookie set by the server persist. (RemoteAPI.prototype.clearCookies): Added for tests. (RemoteAPI.prototype.postJSON): Make sure sendHttpRequest always sends a valid JSON. (RemoteAPI.prototype.postJSONWithStatus): Added since this API is used PrivilegedAPI. (RemoteAPI.prototype.sendHttpRequest): Retain the cookie set by the server and send it back in each request. * tools/js/v3-models.js: * unit-tests/privileged-api-tests.js: Added unit tests for PrivilegedAPI. * unit-tests/resources/mock-remote-api.js: (MockRemoteAPI.postJSON): Added for unit testing. (MockRemoteAPI.postJSONWithStatus): Ditto. Canonical link: https://commits.webkit.org/176780@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202001 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-13 19:47:38 +00:00
});
it("should reject when the token in the request content is bad", () => {
return addBuilderForReport(reportWithRevision[0]).then(() => {
Invalid token error when trying to create an A/B analysis for a range https://bugs.webkit.org/show_bug.cgi?id=158679 Reviewed by Chris Dumez. The problem in this particular case was due to another website overriding cookies for our subdomain. Make PrivilegedAPI robust against its token becoming invalid in general to fix the bug since the cookie is only available under /privileged-api/ and the v3 UI can't access it for security reasons. This patch factors out PrivilegedAPI out of remote.js so that it can be tested separately in server tests as well as unit tests even though RemoteAPI itself is implemented differently in each case. * init-database.sql: Added a forgotten default value "false" to run_marked_outlier. * public/v3/index.html: * public/v3/privileged-api.js: Added. Extracted out of public/v3/remote.js. (PrivilegedAPI.sendRequest): Fixed the bug. When the initial request fails with "InvalidToken" error, re-generate the token and re-issue the request. (PrivilegedAPI.requestCSRFToken): * public/v3/remote.js: (RemoteAPI.postJSON): Added to match tools/js/remote.js. (RemoteAPI.postJSONWithStatus): Ditto. (PrivilegedAPI): Moved to privileged-api.js. * server-tests/api-measurement-set-tests.js: Removed the unused require for crypto. * server-tests/privileged-api-upate-run-status.js: Added tests for /privileged-api/update-run-status. * server-tests/resources/test-server.js: (TestServer.prototype.inject): Clear the cookies as well as tokens in PrivilegedAPI. * tools/js/remote.js: (RemoteAPI): Added the support for PrivilegedAPI by making cookie set by the server persist. (RemoteAPI.prototype.clearCookies): Added for tests. (RemoteAPI.prototype.postJSON): Make sure sendHttpRequest always sends a valid JSON. (RemoteAPI.prototype.postJSONWithStatus): Added since this API is used PrivilegedAPI. (RemoteAPI.prototype.sendHttpRequest): Retain the cookie set by the server and send it back in each request. * tools/js/v3-models.js: * unit-tests/privileged-api-tests.js: Added unit tests for PrivilegedAPI. * unit-tests/resources/mock-remote-api.js: (MockRemoteAPI.postJSON): Added for unit testing. (MockRemoteAPI.postJSONWithStatus): Ditto. Canonical link: https://commits.webkit.org/176780@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202001 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-13 19:47:38 +00:00
return TestServer.remoteAPI().postJSON('/api/report/', reportWithRevision);
}).then((response) => {
Make server test run with new node version https://bugs.webkit.org/show_bug.cgi?id=222463 Change assert.equal to assert.strictEqual since node deprecated this API Add a new function console.assert to make sure it will throw an error Reviewed by Ryosuke Niwa. * public/v3/models/repository.js: (Repository.sortByNamePreferringOnesWithURL): (Repository): * server-tests/admin-platforms-tests.js: * server-tests/admin-reprocess-report-tests.js: * server-tests/api-build-requests-tests.js: (return.TestServer.remoteAPI.getJSON.string_appeared_here.then): * server-tests/api-commits-tests.js: (assertCommitIsSameAsOneSubmitted): (return.TestServer.remoteAPI.getJSON.string_appeared_here.then): * server-tests/api-manifest-tests.js: (return.TestServer.remoteAPI.getJSON.string_appeared_here.then): * server-tests/api-measurement-set-tests.js: * server-tests/api-report-commits-tests.js: (emptyReport.then): (async initialReportCommits): (async setUpTestsWithExpectedStatus): (async testWithExpectedFailure): * server-tests/api-report-tests.js: (emptyReport.then): * server-tests/api-test-groups.js: * server-tests/api-update-triggerable-tests.js: (update.then): (then.response.db.selectAll.string_appeared_here.then): (then.db.selectAll.string_appeared_here.then): (then.Manifest.fetch.then): * server-tests/api-upload-root-tests.js: * server-tests/api-uploaded-file-tests.js: (return.TestServer.remoteAPI.getJSON.string_appeared_here.then): * server-tests/privileged-api-add-build-requests-tests.js: (async createAnalysisTask): (const.commitSet.of.updatedGroups.0.requestedCommitSets): * server-tests/privileged-api-create-analysis-task-tests.js: * server-tests/privileged-api-create-test-group-tests.js: (createAnalysisTask): (return.createAnalysisTask.string_appeared_here.then): (return.addTriggerableAndCreateTask.string_appeared_here.then): (string_appeared_here.then): * server-tests/privileged-api-upate-run-status.js: * server-tests/privileged-api-update-test-group-tests.js: (async createAnalysisTask): * server-tests/privileged-api-upload-file-tests.js: (TestServer.testConfig.uploadFileLimitInMB.1.then): * server-tests/resources/common-operations.js: (async assertThrows): * server-tests/resources/temporary-file.js: (TemporaryFile.makeTemporaryFileOfSizeInMB): * server-tests/tools-buildbot-triggerable-tests.js: (assertRequestAndResolve): (then.refetchManifest.then): (getBuilderNameToIDMapPromise.then): * server-tests/tools-os-build-fetcher-tests.js: * server-tests/tools-sync-buildbot-integration-tests.js: (assertAndResolveRequest): * tools/js/assert-override.js: Added. (makeConsoleAssertThrow): * tools/js/buildbot-syncer.js: (BuildbotBuildEntry.prototype.initialize): (BuildbotBuildEntry.prototype.buildRequestStatusIfUpdateIsNeeded): (BuildbotBuildEntry): (BuildbotSyncer.prototype.scheduleRequest): (BuildbotSyncer._loadConfig): (BuildbotSyncer._parseRepositoryGroup): (BuildbotSyncer._validateAndMergeConfig): (BuildbotSyncer): * tools/js/buildbot-triggerable.js: (BuildbotTriggerable.prototype._validateRequests): * tools/js/markup-component.js: (const.MarkupDocument.new.MarkupDocument.prototype._idForClone): (const.MarkupDocument.new.MarkupDocument.prototype.markup): * tools/js/os-build-fetcher.js: (prototype._addOwnedCommitsForBuild): * tools/js/remote.js: (NodeRemoteAPI.prototype.configure): * tools/js/v3-models.js: * unit-tests/commit-set-tests.js: Canonical link: https://commits.webkit.org/234972@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274036 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-03-06 14:31:56 +00:00
assert.strictEqual(response['status'], 'OK');
return TestServer.database().selectAll('test_runs');
}).then((runRows) => {
Make server test run with new node version https://bugs.webkit.org/show_bug.cgi?id=222463 Change assert.equal to assert.strictEqual since node deprecated this API Add a new function console.assert to make sure it will throw an error Reviewed by Ryosuke Niwa. * public/v3/models/repository.js: (Repository.sortByNamePreferringOnesWithURL): (Repository): * server-tests/admin-platforms-tests.js: * server-tests/admin-reprocess-report-tests.js: * server-tests/api-build-requests-tests.js: (return.TestServer.remoteAPI.getJSON.string_appeared_here.then): * server-tests/api-commits-tests.js: (assertCommitIsSameAsOneSubmitted): (return.TestServer.remoteAPI.getJSON.string_appeared_here.then): * server-tests/api-manifest-tests.js: (return.TestServer.remoteAPI.getJSON.string_appeared_here.then): * server-tests/api-measurement-set-tests.js: * server-tests/api-report-commits-tests.js: (emptyReport.then): (async initialReportCommits): (async setUpTestsWithExpectedStatus): (async testWithExpectedFailure): * server-tests/api-report-tests.js: (emptyReport.then): * server-tests/api-test-groups.js: * server-tests/api-update-triggerable-tests.js: (update.then): (then.response.db.selectAll.string_appeared_here.then): (then.db.selectAll.string_appeared_here.then): (then.Manifest.fetch.then): * server-tests/api-upload-root-tests.js: * server-tests/api-uploaded-file-tests.js: (return.TestServer.remoteAPI.getJSON.string_appeared_here.then): * server-tests/privileged-api-add-build-requests-tests.js: (async createAnalysisTask): (const.commitSet.of.updatedGroups.0.requestedCommitSets): * server-tests/privileged-api-create-analysis-task-tests.js: * server-tests/privileged-api-create-test-group-tests.js: (createAnalysisTask): (return.createAnalysisTask.string_appeared_here.then): (return.addTriggerableAndCreateTask.string_appeared_here.then): (string_appeared_here.then): * server-tests/privileged-api-upate-run-status.js: * server-tests/privileged-api-update-test-group-tests.js: (async createAnalysisTask): * server-tests/privileged-api-upload-file-tests.js: (TestServer.testConfig.uploadFileLimitInMB.1.then): * server-tests/resources/common-operations.js: (async assertThrows): * server-tests/resources/temporary-file.js: (TemporaryFile.makeTemporaryFileOfSizeInMB): * server-tests/tools-buildbot-triggerable-tests.js: (assertRequestAndResolve): (then.refetchManifest.then): (getBuilderNameToIDMapPromise.then): * server-tests/tools-os-build-fetcher-tests.js: * server-tests/tools-sync-buildbot-integration-tests.js: (assertAndResolveRequest): * tools/js/assert-override.js: Added. (makeConsoleAssertThrow): * tools/js/buildbot-syncer.js: (BuildbotBuildEntry.prototype.initialize): (BuildbotBuildEntry.prototype.buildRequestStatusIfUpdateIsNeeded): (BuildbotBuildEntry): (BuildbotSyncer.prototype.scheduleRequest): (BuildbotSyncer._loadConfig): (BuildbotSyncer._parseRepositoryGroup): (BuildbotSyncer._validateAndMergeConfig): (BuildbotSyncer): * tools/js/buildbot-triggerable.js: (BuildbotTriggerable.prototype._validateRequests): * tools/js/markup-component.js: (const.MarkupDocument.new.MarkupDocument.prototype._idForClone): (const.MarkupDocument.new.MarkupDocument.prototype.markup): * tools/js/os-build-fetcher.js: (prototype._addOwnedCommitsForBuild): * tools/js/remote.js: (NodeRemoteAPI.prototype.configure): * tools/js/v3-models.js: * unit-tests/commit-set-tests.js: Canonical link: https://commits.webkit.org/234972@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274036 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-03-06 14:31:56 +00:00
assert.strictEqual(runRows.length, 1);
assert.strictEqual(runRows[0]['marked_outlier'], false);
Invalid token error when trying to create an A/B analysis for a range https://bugs.webkit.org/show_bug.cgi?id=158679 Reviewed by Chris Dumez. The problem in this particular case was due to another website overriding cookies for our subdomain. Make PrivilegedAPI robust against its token becoming invalid in general to fix the bug since the cookie is only available under /privileged-api/ and the v3 UI can't access it for security reasons. This patch factors out PrivilegedAPI out of remote.js so that it can be tested separately in server tests as well as unit tests even though RemoteAPI itself is implemented differently in each case. * init-database.sql: Added a forgotten default value "false" to run_marked_outlier. * public/v3/index.html: * public/v3/privileged-api.js: Added. Extracted out of public/v3/remote.js. (PrivilegedAPI.sendRequest): Fixed the bug. When the initial request fails with "InvalidToken" error, re-generate the token and re-issue the request. (PrivilegedAPI.requestCSRFToken): * public/v3/remote.js: (RemoteAPI.postJSON): Added to match tools/js/remote.js. (RemoteAPI.postJSONWithStatus): Ditto. (PrivilegedAPI): Moved to privileged-api.js. * server-tests/api-measurement-set-tests.js: Removed the unused require for crypto. * server-tests/privileged-api-upate-run-status.js: Added tests for /privileged-api/update-run-status. * server-tests/resources/test-server.js: (TestServer.prototype.inject): Clear the cookies as well as tokens in PrivilegedAPI. * tools/js/remote.js: (RemoteAPI): Added the support for PrivilegedAPI by making cookie set by the server persist. (RemoteAPI.prototype.clearCookies): Added for tests. (RemoteAPI.prototype.postJSON): Make sure sendHttpRequest always sends a valid JSON. (RemoteAPI.prototype.postJSONWithStatus): Added since this API is used PrivilegedAPI. (RemoteAPI.prototype.sendHttpRequest): Retain the cookie set by the server and send it back in each request. * tools/js/v3-models.js: * unit-tests/privileged-api-tests.js: Added unit tests for PrivilegedAPI. * unit-tests/resources/mock-remote-api.js: (MockRemoteAPI.postJSON): Added for unit testing. (MockRemoteAPI.postJSONWithStatus): Ditto. Canonical link: https://commits.webkit.org/176780@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202001 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-13 19:47:38 +00:00
return PrivilegedAPI.requestCSRFToken();
}).then(() => {
Invalid token error when trying to create an A/B analysis for a range https://bugs.webkit.org/show_bug.cgi?id=158679 Reviewed by Chris Dumez. The problem in this particular case was due to another website overriding cookies for our subdomain. Make PrivilegedAPI robust against its token becoming invalid in general to fix the bug since the cookie is only available under /privileged-api/ and the v3 UI can't access it for security reasons. This patch factors out PrivilegedAPI out of remote.js so that it can be tested separately in server tests as well as unit tests even though RemoteAPI itself is implemented differently in each case. * init-database.sql: Added a forgotten default value "false" to run_marked_outlier. * public/v3/index.html: * public/v3/privileged-api.js: Added. Extracted out of public/v3/remote.js. (PrivilegedAPI.sendRequest): Fixed the bug. When the initial request fails with "InvalidToken" error, re-generate the token and re-issue the request. (PrivilegedAPI.requestCSRFToken): * public/v3/remote.js: (RemoteAPI.postJSON): Added to match tools/js/remote.js. (RemoteAPI.postJSONWithStatus): Ditto. (PrivilegedAPI): Moved to privileged-api.js. * server-tests/api-measurement-set-tests.js: Removed the unused require for crypto. * server-tests/privileged-api-upate-run-status.js: Added tests for /privileged-api/update-run-status. * server-tests/resources/test-server.js: (TestServer.prototype.inject): Clear the cookies as well as tokens in PrivilegedAPI. * tools/js/remote.js: (RemoteAPI): Added the support for PrivilegedAPI by making cookie set by the server persist. (RemoteAPI.prototype.clearCookies): Added for tests. (RemoteAPI.prototype.postJSON): Make sure sendHttpRequest always sends a valid JSON. (RemoteAPI.prototype.postJSONWithStatus): Added since this API is used PrivilegedAPI. (RemoteAPI.prototype.sendHttpRequest): Retain the cookie set by the server and send it back in each request. * tools/js/v3-models.js: * unit-tests/privileged-api-tests.js: Added unit tests for PrivilegedAPI. * unit-tests/resources/mock-remote-api.js: (MockRemoteAPI.postJSON): Added for unit testing. (MockRemoteAPI.postJSONWithStatus): Ditto. Canonical link: https://commits.webkit.org/176780@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202001 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-13 19:47:38 +00:00
return RemoteAPI.postJSONWithStatus('/privileged-api/update-run-status', {token: 'bad'});
}).then(() => {
In-browser and node.js implementations of RemoteAPI should share some code https://bugs.webkit.org/show_bug.cgi?id=169695 Rubber-stamped by Antti Koivisto. Extracted CommonRemoteAPI out of RemoteAPI implementations for node.js and browser. * public/shared/common-remote.js: Added. (CommonRemoteAPI): Added. (CommonRemoteAPI.prototype.postJSON): Extracted from RemoteAPI. (CommonRemoteAPI.prototype.postJSONWithStatus): Ditto. (CommonRemoteAPI.prototype.getJSON): Ditto. (CommonRemoteAPI.prototype.getJSONWithStatus): Ditto. (CommonRemoteAPI.prototype.sendHttpRequest): Added. Needs to implemented by a subclass. (CommonRemoteAPI.prototype._asJSON): Added. (CommonRemoteAPI.prototype._checkStatus): Added. * public/v3/index.html: Include common-remote.js. * public/v3/privileged-api.js: (PrivilegedAPI): Use class now that we don't include data.js. (PrivilegedAPI.sendRequest): Modernized the code. (PrivilegedAPI.requestCSRFToken): Ditto. * public/v3/remote.js: (BrowserRemoteAPI): Renamed from RemoteAPI. window.RemoteAPI is now an instance of this class. (BrowserRemoteAPI.prototype.sendHttpRequest): Moved from RemoteAPI.sendHttpRequest. (BrowserRemoteAPI.prototype.sendHttpRequest): * server-tests/privileged-api-create-analysis-task-tests.js: Updated tests since NodeJSRemoteAPI now throws the JSON status as an error to be consistent with BrowserRemoteAPI. * server-tests/privileged-api-create-test-group-tests.js: Ditto. * server-tests/privileged-api-upate-run-status.js: Ditto. * tools/js/buildbot-triggerable.js: (BuildbotTriggerable.prototype.syncOnce): Just use postJSONWithStatus instead of manually checking the status. * tools/js/remote.js: (NodeRemoteAPI): Renamed from RemoteAPI. Still exported as RemoteAPI. (NodeRemoteAPI.prototype.constructor): (NodeRemoteAPI.prototype.sendHttpRequest): Modernized the code. Canonical link: https://commits.webkit.org/186683@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@214008 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-03-15 21:59:12 +00:00
assert(false, 'should never be reached');
}, (error) => {
Make server test run with new node version https://bugs.webkit.org/show_bug.cgi?id=222463 Change assert.equal to assert.strictEqual since node deprecated this API Add a new function console.assert to make sure it will throw an error Reviewed by Ryosuke Niwa. * public/v3/models/repository.js: (Repository.sortByNamePreferringOnesWithURL): (Repository): * server-tests/admin-platforms-tests.js: * server-tests/admin-reprocess-report-tests.js: * server-tests/api-build-requests-tests.js: (return.TestServer.remoteAPI.getJSON.string_appeared_here.then): * server-tests/api-commits-tests.js: (assertCommitIsSameAsOneSubmitted): (return.TestServer.remoteAPI.getJSON.string_appeared_here.then): * server-tests/api-manifest-tests.js: (return.TestServer.remoteAPI.getJSON.string_appeared_here.then): * server-tests/api-measurement-set-tests.js: * server-tests/api-report-commits-tests.js: (emptyReport.then): (async initialReportCommits): (async setUpTestsWithExpectedStatus): (async testWithExpectedFailure): * server-tests/api-report-tests.js: (emptyReport.then): * server-tests/api-test-groups.js: * server-tests/api-update-triggerable-tests.js: (update.then): (then.response.db.selectAll.string_appeared_here.then): (then.db.selectAll.string_appeared_here.then): (then.Manifest.fetch.then): * server-tests/api-upload-root-tests.js: * server-tests/api-uploaded-file-tests.js: (return.TestServer.remoteAPI.getJSON.string_appeared_here.then): * server-tests/privileged-api-add-build-requests-tests.js: (async createAnalysisTask): (const.commitSet.of.updatedGroups.0.requestedCommitSets): * server-tests/privileged-api-create-analysis-task-tests.js: * server-tests/privileged-api-create-test-group-tests.js: (createAnalysisTask): (return.createAnalysisTask.string_appeared_here.then): (return.addTriggerableAndCreateTask.string_appeared_here.then): (string_appeared_here.then): * server-tests/privileged-api-upate-run-status.js: * server-tests/privileged-api-update-test-group-tests.js: (async createAnalysisTask): * server-tests/privileged-api-upload-file-tests.js: (TestServer.testConfig.uploadFileLimitInMB.1.then): * server-tests/resources/common-operations.js: (async assertThrows): * server-tests/resources/temporary-file.js: (TemporaryFile.makeTemporaryFileOfSizeInMB): * server-tests/tools-buildbot-triggerable-tests.js: (assertRequestAndResolve): (then.refetchManifest.then): (getBuilderNameToIDMapPromise.then): * server-tests/tools-os-build-fetcher-tests.js: * server-tests/tools-sync-buildbot-integration-tests.js: (assertAndResolveRequest): * tools/js/assert-override.js: Added. (makeConsoleAssertThrow): * tools/js/buildbot-syncer.js: (BuildbotBuildEntry.prototype.initialize): (BuildbotBuildEntry.prototype.buildRequestStatusIfUpdateIsNeeded): (BuildbotBuildEntry): (BuildbotSyncer.prototype.scheduleRequest): (BuildbotSyncer._loadConfig): (BuildbotSyncer._parseRepositoryGroup): (BuildbotSyncer._validateAndMergeConfig): (BuildbotSyncer): * tools/js/buildbot-triggerable.js: (BuildbotTriggerable.prototype._validateRequests): * tools/js/markup-component.js: (const.MarkupDocument.new.MarkupDocument.prototype._idForClone): (const.MarkupDocument.new.MarkupDocument.prototype.markup): * tools/js/os-build-fetcher.js: (prototype._addOwnedCommitsForBuild): * tools/js/remote.js: (NodeRemoteAPI.prototype.configure): * tools/js/v3-models.js: * unit-tests/commit-set-tests.js: Canonical link: https://commits.webkit.org/234972@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274036 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-03-06 14:31:56 +00:00
assert.strictEqual(error, 'InvalidToken');
});
Invalid token error when trying to create an A/B analysis for a range https://bugs.webkit.org/show_bug.cgi?id=158679 Reviewed by Chris Dumez. The problem in this particular case was due to another website overriding cookies for our subdomain. Make PrivilegedAPI robust against its token becoming invalid in general to fix the bug since the cookie is only available under /privileged-api/ and the v3 UI can't access it for security reasons. This patch factors out PrivilegedAPI out of remote.js so that it can be tested separately in server tests as well as unit tests even though RemoteAPI itself is implemented differently in each case. * init-database.sql: Added a forgotten default value "false" to run_marked_outlier. * public/v3/index.html: * public/v3/privileged-api.js: Added. Extracted out of public/v3/remote.js. (PrivilegedAPI.sendRequest): Fixed the bug. When the initial request fails with "InvalidToken" error, re-generate the token and re-issue the request. (PrivilegedAPI.requestCSRFToken): * public/v3/remote.js: (RemoteAPI.postJSON): Added to match tools/js/remote.js. (RemoteAPI.postJSONWithStatus): Ditto. (PrivilegedAPI): Moved to privileged-api.js. * server-tests/api-measurement-set-tests.js: Removed the unused require for crypto. * server-tests/privileged-api-upate-run-status.js: Added tests for /privileged-api/update-run-status. * server-tests/resources/test-server.js: (TestServer.prototype.inject): Clear the cookies as well as tokens in PrivilegedAPI. * tools/js/remote.js: (RemoteAPI): Added the support for PrivilegedAPI by making cookie set by the server persist. (RemoteAPI.prototype.clearCookies): Added for tests. (RemoteAPI.prototype.postJSON): Make sure sendHttpRequest always sends a valid JSON. (RemoteAPI.prototype.postJSONWithStatus): Added since this API is used PrivilegedAPI. (RemoteAPI.prototype.sendHttpRequest): Retain the cookie set by the server and send it back in each request. * tools/js/v3-models.js: * unit-tests/privileged-api-tests.js: Added unit tests for PrivilegedAPI. * unit-tests/resources/mock-remote-api.js: (MockRemoteAPI.postJSON): Added for unit testing. (MockRemoteAPI.postJSONWithStatus): Ditto. Canonical link: https://commits.webkit.org/176780@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202001 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-13 19:47:38 +00:00
});
it("should be able to unmark a run as an outlier", () => {
Invalid token error when trying to create an A/B analysis for a range https://bugs.webkit.org/show_bug.cgi?id=158679 Reviewed by Chris Dumez. The problem in this particular case was due to another website overriding cookies for our subdomain. Make PrivilegedAPI robust against its token becoming invalid in general to fix the bug since the cookie is only available under /privileged-api/ and the v3 UI can't access it for security reasons. This patch factors out PrivilegedAPI out of remote.js so that it can be tested separately in server tests as well as unit tests even though RemoteAPI itself is implemented differently in each case. * init-database.sql: Added a forgotten default value "false" to run_marked_outlier. * public/v3/index.html: * public/v3/privileged-api.js: Added. Extracted out of public/v3/remote.js. (PrivilegedAPI.sendRequest): Fixed the bug. When the initial request fails with "InvalidToken" error, re-generate the token and re-issue the request. (PrivilegedAPI.requestCSRFToken): * public/v3/remote.js: (RemoteAPI.postJSON): Added to match tools/js/remote.js. (RemoteAPI.postJSONWithStatus): Ditto. (PrivilegedAPI): Moved to privileged-api.js. * server-tests/api-measurement-set-tests.js: Removed the unused require for crypto. * server-tests/privileged-api-upate-run-status.js: Added tests for /privileged-api/update-run-status. * server-tests/resources/test-server.js: (TestServer.prototype.inject): Clear the cookies as well as tokens in PrivilegedAPI. * tools/js/remote.js: (RemoteAPI): Added the support for PrivilegedAPI by making cookie set by the server persist. (RemoteAPI.prototype.clearCookies): Added for tests. (RemoteAPI.prototype.postJSON): Make sure sendHttpRequest always sends a valid JSON. (RemoteAPI.prototype.postJSONWithStatus): Added since this API is used PrivilegedAPI. (RemoteAPI.prototype.sendHttpRequest): Retain the cookie set by the server and send it back in each request. * tools/js/v3-models.js: * unit-tests/privileged-api-tests.js: Added unit tests for PrivilegedAPI. * unit-tests/resources/mock-remote-api.js: (MockRemoteAPI.postJSON): Added for unit testing. (MockRemoteAPI.postJSONWithStatus): Ditto. Canonical link: https://commits.webkit.org/176780@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202001 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-13 19:47:38 +00:00
const db = TestServer.database();
return addBuilderForReport(reportWithRevision[0]).then(() => {
Invalid token error when trying to create an A/B analysis for a range https://bugs.webkit.org/show_bug.cgi?id=158679 Reviewed by Chris Dumez. The problem in this particular case was due to another website overriding cookies for our subdomain. Make PrivilegedAPI robust against its token becoming invalid in general to fix the bug since the cookie is only available under /privileged-api/ and the v3 UI can't access it for security reasons. This patch factors out PrivilegedAPI out of remote.js so that it can be tested separately in server tests as well as unit tests even though RemoteAPI itself is implemented differently in each case. * init-database.sql: Added a forgotten default value "false" to run_marked_outlier. * public/v3/index.html: * public/v3/privileged-api.js: Added. Extracted out of public/v3/remote.js. (PrivilegedAPI.sendRequest): Fixed the bug. When the initial request fails with "InvalidToken" error, re-generate the token and re-issue the request. (PrivilegedAPI.requestCSRFToken): * public/v3/remote.js: (RemoteAPI.postJSON): Added to match tools/js/remote.js. (RemoteAPI.postJSONWithStatus): Ditto. (PrivilegedAPI): Moved to privileged-api.js. * server-tests/api-measurement-set-tests.js: Removed the unused require for crypto. * server-tests/privileged-api-upate-run-status.js: Added tests for /privileged-api/update-run-status. * server-tests/resources/test-server.js: (TestServer.prototype.inject): Clear the cookies as well as tokens in PrivilegedAPI. * tools/js/remote.js: (RemoteAPI): Added the support for PrivilegedAPI by making cookie set by the server persist. (RemoteAPI.prototype.clearCookies): Added for tests. (RemoteAPI.prototype.postJSON): Make sure sendHttpRequest always sends a valid JSON. (RemoteAPI.prototype.postJSONWithStatus): Added since this API is used PrivilegedAPI. (RemoteAPI.prototype.sendHttpRequest): Retain the cookie set by the server and send it back in each request. * tools/js/v3-models.js: * unit-tests/privileged-api-tests.js: Added unit tests for PrivilegedAPI. * unit-tests/resources/mock-remote-api.js: (MockRemoteAPI.postJSON): Added for unit testing. (MockRemoteAPI.postJSONWithStatus): Ditto. Canonical link: https://commits.webkit.org/176780@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202001 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-13 19:47:38 +00:00
return TestServer.remoteAPI().postJSON('/api/report/', reportWithRevision);
}).then((response) => {
Make server test run with new node version https://bugs.webkit.org/show_bug.cgi?id=222463 Change assert.equal to assert.strictEqual since node deprecated this API Add a new function console.assert to make sure it will throw an error Reviewed by Ryosuke Niwa. * public/v3/models/repository.js: (Repository.sortByNamePreferringOnesWithURL): (Repository): * server-tests/admin-platforms-tests.js: * server-tests/admin-reprocess-report-tests.js: * server-tests/api-build-requests-tests.js: (return.TestServer.remoteAPI.getJSON.string_appeared_here.then): * server-tests/api-commits-tests.js: (assertCommitIsSameAsOneSubmitted): (return.TestServer.remoteAPI.getJSON.string_appeared_here.then): * server-tests/api-manifest-tests.js: (return.TestServer.remoteAPI.getJSON.string_appeared_here.then): * server-tests/api-measurement-set-tests.js: * server-tests/api-report-commits-tests.js: (emptyReport.then): (async initialReportCommits): (async setUpTestsWithExpectedStatus): (async testWithExpectedFailure): * server-tests/api-report-tests.js: (emptyReport.then): * server-tests/api-test-groups.js: * server-tests/api-update-triggerable-tests.js: (update.then): (then.response.db.selectAll.string_appeared_here.then): (then.db.selectAll.string_appeared_here.then): (then.Manifest.fetch.then): * server-tests/api-upload-root-tests.js: * server-tests/api-uploaded-file-tests.js: (return.TestServer.remoteAPI.getJSON.string_appeared_here.then): * server-tests/privileged-api-add-build-requests-tests.js: (async createAnalysisTask): (const.commitSet.of.updatedGroups.0.requestedCommitSets): * server-tests/privileged-api-create-analysis-task-tests.js: * server-tests/privileged-api-create-test-group-tests.js: (createAnalysisTask): (return.createAnalysisTask.string_appeared_here.then): (return.addTriggerableAndCreateTask.string_appeared_here.then): (string_appeared_here.then): * server-tests/privileged-api-upate-run-status.js: * server-tests/privileged-api-update-test-group-tests.js: (async createAnalysisTask): * server-tests/privileged-api-upload-file-tests.js: (TestServer.testConfig.uploadFileLimitInMB.1.then): * server-tests/resources/common-operations.js: (async assertThrows): * server-tests/resources/temporary-file.js: (TemporaryFile.makeTemporaryFileOfSizeInMB): * server-tests/tools-buildbot-triggerable-tests.js: (assertRequestAndResolve): (then.refetchManifest.then): (getBuilderNameToIDMapPromise.then): * server-tests/tools-os-build-fetcher-tests.js: * server-tests/tools-sync-buildbot-integration-tests.js: (assertAndResolveRequest): * tools/js/assert-override.js: Added. (makeConsoleAssertThrow): * tools/js/buildbot-syncer.js: (BuildbotBuildEntry.prototype.initialize): (BuildbotBuildEntry.prototype.buildRequestStatusIfUpdateIsNeeded): (BuildbotBuildEntry): (BuildbotSyncer.prototype.scheduleRequest): (BuildbotSyncer._loadConfig): (BuildbotSyncer._parseRepositoryGroup): (BuildbotSyncer._validateAndMergeConfig): (BuildbotSyncer): * tools/js/buildbot-triggerable.js: (BuildbotTriggerable.prototype._validateRequests): * tools/js/markup-component.js: (const.MarkupDocument.new.MarkupDocument.prototype._idForClone): (const.MarkupDocument.new.MarkupDocument.prototype.markup): * tools/js/os-build-fetcher.js: (prototype._addOwnedCommitsForBuild): * tools/js/remote.js: (NodeRemoteAPI.prototype.configure): * tools/js/v3-models.js: * unit-tests/commit-set-tests.js: Canonical link: https://commits.webkit.org/234972@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274036 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-03-06 14:31:56 +00:00
assert.strictEqual(response['status'], 'OK');
Invalid token error when trying to create an A/B analysis for a range https://bugs.webkit.org/show_bug.cgi?id=158679 Reviewed by Chris Dumez. The problem in this particular case was due to another website overriding cookies for our subdomain. Make PrivilegedAPI robust against its token becoming invalid in general to fix the bug since the cookie is only available under /privileged-api/ and the v3 UI can't access it for security reasons. This patch factors out PrivilegedAPI out of remote.js so that it can be tested separately in server tests as well as unit tests even though RemoteAPI itself is implemented differently in each case. * init-database.sql: Added a forgotten default value "false" to run_marked_outlier. * public/v3/index.html: * public/v3/privileged-api.js: Added. Extracted out of public/v3/remote.js. (PrivilegedAPI.sendRequest): Fixed the bug. When the initial request fails with "InvalidToken" error, re-generate the token and re-issue the request. (PrivilegedAPI.requestCSRFToken): * public/v3/remote.js: (RemoteAPI.postJSON): Added to match tools/js/remote.js. (RemoteAPI.postJSONWithStatus): Ditto. (PrivilegedAPI): Moved to privileged-api.js. * server-tests/api-measurement-set-tests.js: Removed the unused require for crypto. * server-tests/privileged-api-upate-run-status.js: Added tests for /privileged-api/update-run-status. * server-tests/resources/test-server.js: (TestServer.prototype.inject): Clear the cookies as well as tokens in PrivilegedAPI. * tools/js/remote.js: (RemoteAPI): Added the support for PrivilegedAPI by making cookie set by the server persist. (RemoteAPI.prototype.clearCookies): Added for tests. (RemoteAPI.prototype.postJSON): Make sure sendHttpRequest always sends a valid JSON. (RemoteAPI.prototype.postJSONWithStatus): Added since this API is used PrivilegedAPI. (RemoteAPI.prototype.sendHttpRequest): Retain the cookie set by the server and send it back in each request. * tools/js/v3-models.js: * unit-tests/privileged-api-tests.js: Added unit tests for PrivilegedAPI. * unit-tests/resources/mock-remote-api.js: (MockRemoteAPI.postJSON): Added for unit testing. (MockRemoteAPI.postJSONWithStatus): Ditto. Canonical link: https://commits.webkit.org/176780@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202001 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-13 19:47:38 +00:00
return db.selectAll('test_runs');
}).then((runRows) => {
Make server test run with new node version https://bugs.webkit.org/show_bug.cgi?id=222463 Change assert.equal to assert.strictEqual since node deprecated this API Add a new function console.assert to make sure it will throw an error Reviewed by Ryosuke Niwa. * public/v3/models/repository.js: (Repository.sortByNamePreferringOnesWithURL): (Repository): * server-tests/admin-platforms-tests.js: * server-tests/admin-reprocess-report-tests.js: * server-tests/api-build-requests-tests.js: (return.TestServer.remoteAPI.getJSON.string_appeared_here.then): * server-tests/api-commits-tests.js: (assertCommitIsSameAsOneSubmitted): (return.TestServer.remoteAPI.getJSON.string_appeared_here.then): * server-tests/api-manifest-tests.js: (return.TestServer.remoteAPI.getJSON.string_appeared_here.then): * server-tests/api-measurement-set-tests.js: * server-tests/api-report-commits-tests.js: (emptyReport.then): (async initialReportCommits): (async setUpTestsWithExpectedStatus): (async testWithExpectedFailure): * server-tests/api-report-tests.js: (emptyReport.then): * server-tests/api-test-groups.js: * server-tests/api-update-triggerable-tests.js: (update.then): (then.response.db.selectAll.string_appeared_here.then): (then.db.selectAll.string_appeared_here.then): (then.Manifest.fetch.then): * server-tests/api-upload-root-tests.js: * server-tests/api-uploaded-file-tests.js: (return.TestServer.remoteAPI.getJSON.string_appeared_here.then): * server-tests/privileged-api-add-build-requests-tests.js: (async createAnalysisTask): (const.commitSet.of.updatedGroups.0.requestedCommitSets): * server-tests/privileged-api-create-analysis-task-tests.js: * server-tests/privileged-api-create-test-group-tests.js: (createAnalysisTask): (return.createAnalysisTask.string_appeared_here.then): (return.addTriggerableAndCreateTask.string_appeared_here.then): (string_appeared_here.then): * server-tests/privileged-api-upate-run-status.js: * server-tests/privileged-api-update-test-group-tests.js: (async createAnalysisTask): * server-tests/privileged-api-upload-file-tests.js: (TestServer.testConfig.uploadFileLimitInMB.1.then): * server-tests/resources/common-operations.js: (async assertThrows): * server-tests/resources/temporary-file.js: (TemporaryFile.makeTemporaryFileOfSizeInMB): * server-tests/tools-buildbot-triggerable-tests.js: (assertRequestAndResolve): (then.refetchManifest.then): (getBuilderNameToIDMapPromise.then): * server-tests/tools-os-build-fetcher-tests.js: * server-tests/tools-sync-buildbot-integration-tests.js: (assertAndResolveRequest): * tools/js/assert-override.js: Added. (makeConsoleAssertThrow): * tools/js/buildbot-syncer.js: (BuildbotBuildEntry.prototype.initialize): (BuildbotBuildEntry.prototype.buildRequestStatusIfUpdateIsNeeded): (BuildbotBuildEntry): (BuildbotSyncer.prototype.scheduleRequest): (BuildbotSyncer._loadConfig): (BuildbotSyncer._parseRepositoryGroup): (BuildbotSyncer._validateAndMergeConfig): (BuildbotSyncer): * tools/js/buildbot-triggerable.js: (BuildbotTriggerable.prototype._validateRequests): * tools/js/markup-component.js: (const.MarkupDocument.new.MarkupDocument.prototype._idForClone): (const.MarkupDocument.new.MarkupDocument.prototype.markup): * tools/js/os-build-fetcher.js: (prototype._addOwnedCommitsForBuild): * tools/js/remote.js: (NodeRemoteAPI.prototype.configure): * tools/js/v3-models.js: * unit-tests/commit-set-tests.js: Canonical link: https://commits.webkit.org/234972@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274036 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-03-06 14:31:56 +00:00
assert.strictEqual(runRows.length, 1);
assert.strictEqual(runRows[0]['marked_outlier'], false);
Invalid token error when trying to create an A/B analysis for a range https://bugs.webkit.org/show_bug.cgi?id=158679 Reviewed by Chris Dumez. The problem in this particular case was due to another website overriding cookies for our subdomain. Make PrivilegedAPI robust against its token becoming invalid in general to fix the bug since the cookie is only available under /privileged-api/ and the v3 UI can't access it for security reasons. This patch factors out PrivilegedAPI out of remote.js so that it can be tested separately in server tests as well as unit tests even though RemoteAPI itself is implemented differently in each case. * init-database.sql: Added a forgotten default value "false" to run_marked_outlier. * public/v3/index.html: * public/v3/privileged-api.js: Added. Extracted out of public/v3/remote.js. (PrivilegedAPI.sendRequest): Fixed the bug. When the initial request fails with "InvalidToken" error, re-generate the token and re-issue the request. (PrivilegedAPI.requestCSRFToken): * public/v3/remote.js: (RemoteAPI.postJSON): Added to match tools/js/remote.js. (RemoteAPI.postJSONWithStatus): Ditto. (PrivilegedAPI): Moved to privileged-api.js. * server-tests/api-measurement-set-tests.js: Removed the unused require for crypto. * server-tests/privileged-api-upate-run-status.js: Added tests for /privileged-api/update-run-status. * server-tests/resources/test-server.js: (TestServer.prototype.inject): Clear the cookies as well as tokens in PrivilegedAPI. * tools/js/remote.js: (RemoteAPI): Added the support for PrivilegedAPI by making cookie set by the server persist. (RemoteAPI.prototype.clearCookies): Added for tests. (RemoteAPI.prototype.postJSON): Make sure sendHttpRequest always sends a valid JSON. (RemoteAPI.prototype.postJSONWithStatus): Added since this API is used PrivilegedAPI. (RemoteAPI.prototype.sendHttpRequest): Retain the cookie set by the server and send it back in each request. * tools/js/v3-models.js: * unit-tests/privileged-api-tests.js: Added unit tests for PrivilegedAPI. * unit-tests/resources/mock-remote-api.js: (MockRemoteAPI.postJSON): Added for unit testing. (MockRemoteAPI.postJSONWithStatus): Ditto. Canonical link: https://commits.webkit.org/176780@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202001 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-13 19:47:38 +00:00
return PrivilegedAPI.sendRequest('update-run-status', {'run': runRows[0]['id'], 'markedOutlier': true});
}).then(() => {
Invalid token error when trying to create an A/B analysis for a range https://bugs.webkit.org/show_bug.cgi?id=158679 Reviewed by Chris Dumez. The problem in this particular case was due to another website overriding cookies for our subdomain. Make PrivilegedAPI robust against its token becoming invalid in general to fix the bug since the cookie is only available under /privileged-api/ and the v3 UI can't access it for security reasons. This patch factors out PrivilegedAPI out of remote.js so that it can be tested separately in server tests as well as unit tests even though RemoteAPI itself is implemented differently in each case. * init-database.sql: Added a forgotten default value "false" to run_marked_outlier. * public/v3/index.html: * public/v3/privileged-api.js: Added. Extracted out of public/v3/remote.js. (PrivilegedAPI.sendRequest): Fixed the bug. When the initial request fails with "InvalidToken" error, re-generate the token and re-issue the request. (PrivilegedAPI.requestCSRFToken): * public/v3/remote.js: (RemoteAPI.postJSON): Added to match tools/js/remote.js. (RemoteAPI.postJSONWithStatus): Ditto. (PrivilegedAPI): Moved to privileged-api.js. * server-tests/api-measurement-set-tests.js: Removed the unused require for crypto. * server-tests/privileged-api-upate-run-status.js: Added tests for /privileged-api/update-run-status. * server-tests/resources/test-server.js: (TestServer.prototype.inject): Clear the cookies as well as tokens in PrivilegedAPI. * tools/js/remote.js: (RemoteAPI): Added the support for PrivilegedAPI by making cookie set by the server persist. (RemoteAPI.prototype.clearCookies): Added for tests. (RemoteAPI.prototype.postJSON): Make sure sendHttpRequest always sends a valid JSON. (RemoteAPI.prototype.postJSONWithStatus): Added since this API is used PrivilegedAPI. (RemoteAPI.prototype.sendHttpRequest): Retain the cookie set by the server and send it back in each request. * tools/js/v3-models.js: * unit-tests/privileged-api-tests.js: Added unit tests for PrivilegedAPI. * unit-tests/resources/mock-remote-api.js: (MockRemoteAPI.postJSON): Added for unit testing. (MockRemoteAPI.postJSONWithStatus): Ditto. Canonical link: https://commits.webkit.org/176780@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202001 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-13 19:47:38 +00:00
return db.selectAll('test_runs');
}).then((runRows) => {
Make server test run with new node version https://bugs.webkit.org/show_bug.cgi?id=222463 Change assert.equal to assert.strictEqual since node deprecated this API Add a new function console.assert to make sure it will throw an error Reviewed by Ryosuke Niwa. * public/v3/models/repository.js: (Repository.sortByNamePreferringOnesWithURL): (Repository): * server-tests/admin-platforms-tests.js: * server-tests/admin-reprocess-report-tests.js: * server-tests/api-build-requests-tests.js: (return.TestServer.remoteAPI.getJSON.string_appeared_here.then): * server-tests/api-commits-tests.js: (assertCommitIsSameAsOneSubmitted): (return.TestServer.remoteAPI.getJSON.string_appeared_here.then): * server-tests/api-manifest-tests.js: (return.TestServer.remoteAPI.getJSON.string_appeared_here.then): * server-tests/api-measurement-set-tests.js: * server-tests/api-report-commits-tests.js: (emptyReport.then): (async initialReportCommits): (async setUpTestsWithExpectedStatus): (async testWithExpectedFailure): * server-tests/api-report-tests.js: (emptyReport.then): * server-tests/api-test-groups.js: * server-tests/api-update-triggerable-tests.js: (update.then): (then.response.db.selectAll.string_appeared_here.then): (then.db.selectAll.string_appeared_here.then): (then.Manifest.fetch.then): * server-tests/api-upload-root-tests.js: * server-tests/api-uploaded-file-tests.js: (return.TestServer.remoteAPI.getJSON.string_appeared_here.then): * server-tests/privileged-api-add-build-requests-tests.js: (async createAnalysisTask): (const.commitSet.of.updatedGroups.0.requestedCommitSets): * server-tests/privileged-api-create-analysis-task-tests.js: * server-tests/privileged-api-create-test-group-tests.js: (createAnalysisTask): (return.createAnalysisTask.string_appeared_here.then): (return.addTriggerableAndCreateTask.string_appeared_here.then): (string_appeared_here.then): * server-tests/privileged-api-upate-run-status.js: * server-tests/privileged-api-update-test-group-tests.js: (async createAnalysisTask): * server-tests/privileged-api-upload-file-tests.js: (TestServer.testConfig.uploadFileLimitInMB.1.then): * server-tests/resources/common-operations.js: (async assertThrows): * server-tests/resources/temporary-file.js: (TemporaryFile.makeTemporaryFileOfSizeInMB): * server-tests/tools-buildbot-triggerable-tests.js: (assertRequestAndResolve): (then.refetchManifest.then): (getBuilderNameToIDMapPromise.then): * server-tests/tools-os-build-fetcher-tests.js: * server-tests/tools-sync-buildbot-integration-tests.js: (assertAndResolveRequest): * tools/js/assert-override.js: Added. (makeConsoleAssertThrow): * tools/js/buildbot-syncer.js: (BuildbotBuildEntry.prototype.initialize): (BuildbotBuildEntry.prototype.buildRequestStatusIfUpdateIsNeeded): (BuildbotBuildEntry): (BuildbotSyncer.prototype.scheduleRequest): (BuildbotSyncer._loadConfig): (BuildbotSyncer._parseRepositoryGroup): (BuildbotSyncer._validateAndMergeConfig): (BuildbotSyncer): * tools/js/buildbot-triggerable.js: (BuildbotTriggerable.prototype._validateRequests): * tools/js/markup-component.js: (const.MarkupDocument.new.MarkupDocument.prototype._idForClone): (const.MarkupDocument.new.MarkupDocument.prototype.markup): * tools/js/os-build-fetcher.js: (prototype._addOwnedCommitsForBuild): * tools/js/remote.js: (NodeRemoteAPI.prototype.configure): * tools/js/v3-models.js: * unit-tests/commit-set-tests.js: Canonical link: https://commits.webkit.org/234972@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274036 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-03-06 14:31:56 +00:00
assert.strictEqual(runRows.length, 1);
assert.strictEqual(runRows[0]['marked_outlier'], true);
Invalid token error when trying to create an A/B analysis for a range https://bugs.webkit.org/show_bug.cgi?id=158679 Reviewed by Chris Dumez. The problem in this particular case was due to another website overriding cookies for our subdomain. Make PrivilegedAPI robust against its token becoming invalid in general to fix the bug since the cookie is only available under /privileged-api/ and the v3 UI can't access it for security reasons. This patch factors out PrivilegedAPI out of remote.js so that it can be tested separately in server tests as well as unit tests even though RemoteAPI itself is implemented differently in each case. * init-database.sql: Added a forgotten default value "false" to run_marked_outlier. * public/v3/index.html: * public/v3/privileged-api.js: Added. Extracted out of public/v3/remote.js. (PrivilegedAPI.sendRequest): Fixed the bug. When the initial request fails with "InvalidToken" error, re-generate the token and re-issue the request. (PrivilegedAPI.requestCSRFToken): * public/v3/remote.js: (RemoteAPI.postJSON): Added to match tools/js/remote.js. (RemoteAPI.postJSONWithStatus): Ditto. (PrivilegedAPI): Moved to privileged-api.js. * server-tests/api-measurement-set-tests.js: Removed the unused require for crypto. * server-tests/privileged-api-upate-run-status.js: Added tests for /privileged-api/update-run-status. * server-tests/resources/test-server.js: (TestServer.prototype.inject): Clear the cookies as well as tokens in PrivilegedAPI. * tools/js/remote.js: (RemoteAPI): Added the support for PrivilegedAPI by making cookie set by the server persist. (RemoteAPI.prototype.clearCookies): Added for tests. (RemoteAPI.prototype.postJSON): Make sure sendHttpRequest always sends a valid JSON. (RemoteAPI.prototype.postJSONWithStatus): Added since this API is used PrivilegedAPI. (RemoteAPI.prototype.sendHttpRequest): Retain the cookie set by the server and send it back in each request. * tools/js/v3-models.js: * unit-tests/privileged-api-tests.js: Added unit tests for PrivilegedAPI. * unit-tests/resources/mock-remote-api.js: (MockRemoteAPI.postJSON): Added for unit testing. (MockRemoteAPI.postJSONWithStatus): Ditto. Canonical link: https://commits.webkit.org/176780@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202001 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-13 19:47:38 +00:00
return PrivilegedAPI.sendRequest('update-run-status', {'run': runRows[0]['id'], 'markedOutlier': false});
}).then(() => {
Invalid token error when trying to create an A/B analysis for a range https://bugs.webkit.org/show_bug.cgi?id=158679 Reviewed by Chris Dumez. The problem in this particular case was due to another website overriding cookies for our subdomain. Make PrivilegedAPI robust against its token becoming invalid in general to fix the bug since the cookie is only available under /privileged-api/ and the v3 UI can't access it for security reasons. This patch factors out PrivilegedAPI out of remote.js so that it can be tested separately in server tests as well as unit tests even though RemoteAPI itself is implemented differently in each case. * init-database.sql: Added a forgotten default value "false" to run_marked_outlier. * public/v3/index.html: * public/v3/privileged-api.js: Added. Extracted out of public/v3/remote.js. (PrivilegedAPI.sendRequest): Fixed the bug. When the initial request fails with "InvalidToken" error, re-generate the token and re-issue the request. (PrivilegedAPI.requestCSRFToken): * public/v3/remote.js: (RemoteAPI.postJSON): Added to match tools/js/remote.js. (RemoteAPI.postJSONWithStatus): Ditto. (PrivilegedAPI): Moved to privileged-api.js. * server-tests/api-measurement-set-tests.js: Removed the unused require for crypto. * server-tests/privileged-api-upate-run-status.js: Added tests for /privileged-api/update-run-status. * server-tests/resources/test-server.js: (TestServer.prototype.inject): Clear the cookies as well as tokens in PrivilegedAPI. * tools/js/remote.js: (RemoteAPI): Added the support for PrivilegedAPI by making cookie set by the server persist. (RemoteAPI.prototype.clearCookies): Added for tests. (RemoteAPI.prototype.postJSON): Make sure sendHttpRequest always sends a valid JSON. (RemoteAPI.prototype.postJSONWithStatus): Added since this API is used PrivilegedAPI. (RemoteAPI.prototype.sendHttpRequest): Retain the cookie set by the server and send it back in each request. * tools/js/v3-models.js: * unit-tests/privileged-api-tests.js: Added unit tests for PrivilegedAPI. * unit-tests/resources/mock-remote-api.js: (MockRemoteAPI.postJSON): Added for unit testing. (MockRemoteAPI.postJSONWithStatus): Ditto. Canonical link: https://commits.webkit.org/176780@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202001 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-13 19:47:38 +00:00
return db.selectAll('test_runs');
}).then((runRows) => {
Make server test run with new node version https://bugs.webkit.org/show_bug.cgi?id=222463 Change assert.equal to assert.strictEqual since node deprecated this API Add a new function console.assert to make sure it will throw an error Reviewed by Ryosuke Niwa. * public/v3/models/repository.js: (Repository.sortByNamePreferringOnesWithURL): (Repository): * server-tests/admin-platforms-tests.js: * server-tests/admin-reprocess-report-tests.js: * server-tests/api-build-requests-tests.js: (return.TestServer.remoteAPI.getJSON.string_appeared_here.then): * server-tests/api-commits-tests.js: (assertCommitIsSameAsOneSubmitted): (return.TestServer.remoteAPI.getJSON.string_appeared_here.then): * server-tests/api-manifest-tests.js: (return.TestServer.remoteAPI.getJSON.string_appeared_here.then): * server-tests/api-measurement-set-tests.js: * server-tests/api-report-commits-tests.js: (emptyReport.then): (async initialReportCommits): (async setUpTestsWithExpectedStatus): (async testWithExpectedFailure): * server-tests/api-report-tests.js: (emptyReport.then): * server-tests/api-test-groups.js: * server-tests/api-update-triggerable-tests.js: (update.then): (then.response.db.selectAll.string_appeared_here.then): (then.db.selectAll.string_appeared_here.then): (then.Manifest.fetch.then): * server-tests/api-upload-root-tests.js: * server-tests/api-uploaded-file-tests.js: (return.TestServer.remoteAPI.getJSON.string_appeared_here.then): * server-tests/privileged-api-add-build-requests-tests.js: (async createAnalysisTask): (const.commitSet.of.updatedGroups.0.requestedCommitSets): * server-tests/privileged-api-create-analysis-task-tests.js: * server-tests/privileged-api-create-test-group-tests.js: (createAnalysisTask): (return.createAnalysisTask.string_appeared_here.then): (return.addTriggerableAndCreateTask.string_appeared_here.then): (string_appeared_here.then): * server-tests/privileged-api-upate-run-status.js: * server-tests/privileged-api-update-test-group-tests.js: (async createAnalysisTask): * server-tests/privileged-api-upload-file-tests.js: (TestServer.testConfig.uploadFileLimitInMB.1.then): * server-tests/resources/common-operations.js: (async assertThrows): * server-tests/resources/temporary-file.js: (TemporaryFile.makeTemporaryFileOfSizeInMB): * server-tests/tools-buildbot-triggerable-tests.js: (assertRequestAndResolve): (then.refetchManifest.then): (getBuilderNameToIDMapPromise.then): * server-tests/tools-os-build-fetcher-tests.js: * server-tests/tools-sync-buildbot-integration-tests.js: (assertAndResolveRequest): * tools/js/assert-override.js: Added. (makeConsoleAssertThrow): * tools/js/buildbot-syncer.js: (BuildbotBuildEntry.prototype.initialize): (BuildbotBuildEntry.prototype.buildRequestStatusIfUpdateIsNeeded): (BuildbotBuildEntry): (BuildbotSyncer.prototype.scheduleRequest): (BuildbotSyncer._loadConfig): (BuildbotSyncer._parseRepositoryGroup): (BuildbotSyncer._validateAndMergeConfig): (BuildbotSyncer): * tools/js/buildbot-triggerable.js: (BuildbotTriggerable.prototype._validateRequests): * tools/js/markup-component.js: (const.MarkupDocument.new.MarkupDocument.prototype._idForClone): (const.MarkupDocument.new.MarkupDocument.prototype.markup): * tools/js/os-build-fetcher.js: (prototype._addOwnedCommitsForBuild): * tools/js/remote.js: (NodeRemoteAPI.prototype.configure): * tools/js/v3-models.js: * unit-tests/commit-set-tests.js: Canonical link: https://commits.webkit.org/234972@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274036 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-03-06 14:31:56 +00:00
assert.strictEqual(runRows.length, 1);
assert.strictEqual(runRows[0]['marked_outlier'], false);
});
Invalid token error when trying to create an A/B analysis for a range https://bugs.webkit.org/show_bug.cgi?id=158679 Reviewed by Chris Dumez. The problem in this particular case was due to another website overriding cookies for our subdomain. Make PrivilegedAPI robust against its token becoming invalid in general to fix the bug since the cookie is only available under /privileged-api/ and the v3 UI can't access it for security reasons. This patch factors out PrivilegedAPI out of remote.js so that it can be tested separately in server tests as well as unit tests even though RemoteAPI itself is implemented differently in each case. * init-database.sql: Added a forgotten default value "false" to run_marked_outlier. * public/v3/index.html: * public/v3/privileged-api.js: Added. Extracted out of public/v3/remote.js. (PrivilegedAPI.sendRequest): Fixed the bug. When the initial request fails with "InvalidToken" error, re-generate the token and re-issue the request. (PrivilegedAPI.requestCSRFToken): * public/v3/remote.js: (RemoteAPI.postJSON): Added to match tools/js/remote.js. (RemoteAPI.postJSONWithStatus): Ditto. (PrivilegedAPI): Moved to privileged-api.js. * server-tests/api-measurement-set-tests.js: Removed the unused require for crypto. * server-tests/privileged-api-upate-run-status.js: Added tests for /privileged-api/update-run-status. * server-tests/resources/test-server.js: (TestServer.prototype.inject): Clear the cookies as well as tokens in PrivilegedAPI. * tools/js/remote.js: (RemoteAPI): Added the support for PrivilegedAPI by making cookie set by the server persist. (RemoteAPI.prototype.clearCookies): Added for tests. (RemoteAPI.prototype.postJSON): Make sure sendHttpRequest always sends a valid JSON. (RemoteAPI.prototype.postJSONWithStatus): Added since this API is used PrivilegedAPI. (RemoteAPI.prototype.sendHttpRequest): Retain the cookie set by the server and send it back in each request. * tools/js/v3-models.js: * unit-tests/privileged-api-tests.js: Added unit tests for PrivilegedAPI. * unit-tests/resources/mock-remote-api.js: (MockRemoteAPI.postJSON): Added for unit testing. (MockRemoteAPI.postJSONWithStatus): Ditto. Canonical link: https://commits.webkit.org/176780@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202001 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-13 19:47:38 +00:00
});
});