test.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * Copyright (c) 2020, 2019 Girish M
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation; either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program; if not, write to the Free Software
  15. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  16. * MA 02110-1301, USA.
  17. *
  18. */
  19. let createKeyTest = () => {
  20. var http = require("http");
  21. var options = {
  22. "method": "POST",
  23. "hostname": "localhost",
  24. "port": "3000",
  25. "path": [
  26. "cache"
  27. ],
  28. "headers": {
  29. "Content-Type": "application/json",
  30. "User-Agent": "PostmanRuntime/7.20.1",
  31. "Accept": "*/*",
  32. "Cache-Control": "no-cache",
  33. "Postman-Token": "0169a7cd-ebc2-457c-8f3a-4bd203b649a1,0d43ecdd-8ebc-474f-b53a-fd9a4212cfbc",
  34. "Host": "localhost:3000",
  35. "Accept-Encoding": "gzip, deflate",
  36. "Content-Length": "20",
  37. "Connection": "keep-alive",
  38. "cache-control": "no-cache"
  39. }
  40. };
  41. var req = http.request(options, function (res) {
  42. var chunks = [];
  43. res.on("data", function (chunk) {
  44. chunks.push(chunk);
  45. });
  46. res.on("end", function () {
  47. var body = Buffer.concat(chunks);
  48. console.log(body.toString());
  49. });
  50. });
  51. req.write(JSON.stringify({ key: 'aft223' }));
  52. req.end();
  53. };
  54. let getAllKeysTest = () => {
  55. var http = require("http");
  56. var options = {
  57. "method": "GET",
  58. "hostname": "localhost",
  59. "port": "3000",
  60. "path": [
  61. "cache"
  62. ],
  63. "headers": {
  64. "User-Agent": "PostmanRuntime/7.20.1",
  65. "Accept": "*/*",
  66. "Cache-Control": "no-cache",
  67. "Postman-Token": "32a09eac-ea40-4622-bda8-8960ff5166cc,c9bbb80e-d512-45fd-89db-a5c1a7654bc9",
  68. "Host": "localhost:3000",
  69. "Accept-Encoding": "gzip, deflate",
  70. "Connection": "keep-alive",
  71. "cache-control": "no-cache"
  72. }
  73. };
  74. var req = http.request(options, function (res) {
  75. var chunks = [];
  76. res.on("data", function (chunk) {
  77. chunks.push(chunk);
  78. });
  79. res.on("end", function () {
  80. var body = Buffer.concat(chunks);
  81. console.log(body.toString());
  82. });
  83. });
  84. req.end();
  85. }
  86. createKeyTest();
  87. getAllKeysTest();