| OLD | NEW |
| 1 <!-- | 1 <!-- |
| 2 Copyright 2016 The LUCI Authors. All rights reserved. | 2 Copyright 2016 The LUCI Authors. All rights reserved. |
| 3 Use of this source code is governed under the Apache License, Version 2.0 | 3 Use of this source code is governed under the Apache License, Version 2.0 |
| 4 that can be found in the LICENSE file. | 4 that can be found in the LICENSE file. |
| 5 | 5 |
| 6 --> | 6 --> |
| 7 <!DOCTYPE html> | 7 <!DOCTYPE html> |
| 8 <html> | 8 <html> |
| 9 <head> | 9 <head> |
| 10 <title>bot-page Demo</title> | 10 <title>bot-page Demo</title> |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 <!-- Makes a var called events. It's an array of things that could be returne
d--> | 21 <!-- Makes a var called events. It's an array of things that could be returne
d--> |
| 22 <script type="text/javascript" src="bot-events-demo.json"></script> | 22 <script type="text/javascript" src="bot-events-demo.json"></script> |
| 23 <!-- Makes a var called tasks. It's an array of things that could be returned
--> | 23 <!-- Makes a var called tasks. It's an array of things that could be returned
--> |
| 24 <script type="text/javascript" src="bot-tasks-demo.json"></script> | 24 <script type="text/javascript" src="bot-tasks-demo.json"></script> |
| 25 | 25 |
| 26 <script type="text/javascript" charset="utf-8"> | 26 <script type="text/javascript" charset="utf-8"> |
| 27 sinon.format = function(object) {return JSON.stringify(object);} | 27 sinon.format = function(object) {return JSON.stringify(object);} |
| 28 sinon.log = function(message) {console.log(message);}; | 28 sinon.log = function(message) {console.log(message);}; |
| 29 var server = sinon.fakeServer.create(); | 29 var server = sinon.fakeServer.create(); |
| 30 server.autoRespond = true; | 30 server.autoRespond = true; |
| 31 //server.autoRespondAfter = 2000; | 31 server.autoRespondAfter = 1000; |
| 32 | 32 |
| 33 var genResponse = function(arr) { | 33 var genResponse = function(arr) { |
| 34 return function(request){ | 34 return function(request){ |
| 35 if (!request.requestHeaders.authorization) { | 35 if (!request.requestHeaders.authorization) { |
| 36 sinon.log("You must be logged in (check your Oauth?)"); | 36 sinon.log("You must be logged in (check your Oauth?)"); |
| 37 request.respond(403, {}, "You must be logged in (check your Oauth?)"); | 37 request.respond(403, {}, "You must be logged in (check your Oauth?)"); |
| 38 return; | 38 return; |
| 39 } | 39 } |
| 40 sinon.log("User authenticated :) "+ request.requestHeaders.authorization
); | 40 sinon.log("User authenticated :) "+ request.requestHeaders.authorization
); |
| 41 sinon.log("Bot Request: "+sinon.format(request)); | 41 sinon.log("Bot Request: "+sinon.format(request)); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 70 terminate_bot: true, | 70 terminate_bot: true, |
| 71 }; | 71 }; |
| 72 server.respondWith("GET", /^\/_ah\/api\/swarming\/v1\/server\/permissions/,
JSON.stringify(permissions)); | 72 server.respondWith("GET", /^\/_ah\/api\/swarming\/v1\/server\/permissions/,
JSON.stringify(permissions)); |
| 73 server.respondWith("GET", /^\/api\/swarming\/v1\/server\/permissions/, JSON.
stringify(permissions)); | 73 server.respondWith("GET", /^\/api\/swarming\/v1\/server\/permissions/, JSON.
stringify(permissions)); |
| 74 | 74 |
| 75 var details = { | 75 var details = { |
| 76 server_version: "1234-deadbeef", | 76 server_version: "1234-deadbeef", |
| 77 }; | 77 }; |
| 78 server.respondWith("GET", /^\/_ah\/api\/swarming\/v1\/server\/details/, JSON
.stringify(details)); | 78 server.respondWith("GET", /^\/_ah\/api\/swarming\/v1\/server\/details/, JSON
.stringify(details)); |
| 79 server.respondWith("GET", /^\/api\/swarming\/v1\/server\/details/, JSON.stri
ngify(details)); | 79 server.respondWith("GET", /^\/api\/swarming\/v1\/server\/details/, JSON.stri
ngify(details)); |
| 80 |
| 81 var deleteRequest = function(request) { |
| 82 console.log("Deleting", request); |
| 83 if (!request.requestHeaders.authorization) { |
| 84 sinon.log("You must be logged in (check your Oauth?)"); |
| 85 request.respond(403, {}, "You must be logged in (check your Oauth?)"); |
| 86 return; |
| 87 } |
| 88 request.respond(200, {}, "Bot has been deleted."); |
| 89 } |
| 90 |
| 91 server.respondWith("POST", /^\/_ah\/api\/swarming\/v1\/bot\/.+\/delete/, del
eteRequest); |
| 92 server.respondWith("POST", /^\/api\/swarming\/v1\/bot\/.+\/delete/, deleteRe
quest); |
| 93 |
| 94 var terminateRequest = function(request) { |
| 95 console.log("Terminating", request); |
| 96 if (!request.requestHeaders.authorization) { |
| 97 sinon.log("You must be logged in (check your Oauth?)"); |
| 98 request.respond(403, {}, "You must be logged in (check your Oauth?)"); |
| 99 return; |
| 100 } |
| 101 request.respond(200, {}, "Bot has been terminated."); |
| 102 } |
| 103 |
| 104 server.respondWith("POST", /^\/_ah\/api\/swarming\/v1\/bot\/.+\/terminate/,
terminateRequest); |
| 105 server.respondWith("POST", /^\/api\/swarming\/v1\/bot\/.+\/terminate/, termi
nateRequest); |
| 80 </script> | 106 </script> |
| 81 | 107 |
| 82 <link rel="import" href="bot-page.html"> | 108 <link rel="import" href="bot-page.html"> |
| 83 </head> | 109 </head> |
| 84 <body> | 110 <body> |
| 85 | 111 |
| 86 <bot-page | 112 <bot-page |
| 87 bot_id="test-bot-001" | 113 bot_id="test-bot-001" |
| 88 client_id="20770472288-t5smpbpjptka4nd888fv0ctd23ftba2o.apps.googleusercontent
.com" | 114 client_id="20770472288-t5smpbpjptka4nd888fv0ctd23ftba2o.apps.googleusercontent
.com"> |
| 89 > | |
| 90 </bot-page> | 115 </bot-page> |
| 91 | 116 |
| 92 </body> | 117 </body> |
| 93 </html> | 118 </html> |
| OLD | NEW |