Advertisement
Guest User

Untitled

a guest
May 25th, 2018
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JSON 10.07 KB | None | 0 0
  1.  
  2. const chai = require("chai")
  3. const request = require('superagent')
  4.  
  5. describe("test-aws-lambda", function() {
  6.     it("should return results in correct format", function(done){
  7.         request
  8.         .post('https://census-toy.nceng.net/prod/toy-census?top=-1')
  9.         .send({ actionType: 'CountByGender',
  10.         users: [
  11.             {
  12.                 "gender": "female",
  13.                 "name": {
  14.                 "title": "miss",
  15.                 "first": "ronja",
  16.                 "last": "saarinen"
  17.                 },
  18.                 "location": {
  19.                 "street": "1505 mannerheimintie",
  20.                 "city": "lemi",
  21.                 "state": "central finland",
  22.                 "postcode": 24382
  23.                 },
  24.                 "email": "ronja.saarinen@example.com",
  25.                 "login": {
  26.                 "username": "heavytiger900",
  27.                 "password": "wibble",
  28.                 "salt": "u7y0THoZ",
  29.                 "md5": "b86cd36b377202147942266f768420cd",
  30.                 "sha1": "564961ace0b11b2da8e669b1bb29b1d2d8dc0f44",
  31.                 "sha256": "976e981e22c4216f67c675842a5b9555f5e11360050fcc2ee5aff1a869dd97a4"
  32.                 },
  33.                 "dob": "1984-04-14 06:57:26",
  34.                 "registered": "2009-11-27 19:33:36",
  35.                 "phone": "03-249-015",
  36.                 "cell": "040-071-55-88",
  37.                 "id": {
  38.                 "name": "HETU",
  39.                 "value": "984-652Y"
  40.                 },
  41.                 "picture": {
  42.                 "large": "https://randomuser.me/api/portraits/women/61.jpg",
  43.                 "medium": "https://randomuser.me/api/portraits/med/women/61.jpg",
  44.                 "thumbnail": "https://randomuser.me/api/portraits/thumb/women/61.jpg"
  45.                 },
  46.                 "nat": "FI"
  47.                 },
  48.                 {
  49.                 "gender": "female",
  50.                 "name": {
  51.                 "title": "mrs",
  52.                 "first": "ellie",
  53.                 "last": "hughes"
  54.                 },
  55.                 "location": {
  56.                 "street": "7060 bay view road",
  57.                 "city": "taupo",
  58.                 "state": "west coast",
  59.                 "postcode": 17628
  60.                 },
  61.                 "email": "ellie.hughes@example.com",
  62.                 "login": {
  63.                 "username": "redleopard375",
  64.                 "password": "camero",
  65.                 "salt": "i36Z5XzG",
  66.                 "md5": "0fe338231d860285d4a4a6f194d7d317",
  67.                 "sha1": "c1053334b0742c4d726918da7680de78753062ec",
  68.                 "sha256": "4c4964e952863bf5aefcb93e7d652f174ffa86077bd9fbd8c6b8aff75c105949"
  69.                 },
  70.                 "dob": "1954-03-04 03:22:15",
  71.                 "registered": "2004-06-12 23:28:34",
  72.                 "phone": "(953)-707-6029",
  73.                 "cell": "(193)-604-2253",
  74.                 "id": {
  75.                 "name": "",
  76.                 "value": null
  77.                 },
  78.                 "picture": {
  79.                 "large": "https://randomuser.me/api/portraits/women/33.jpg",
  80.                 "medium": "https://randomuser.me/api/portraits/med/women/33.jpg",
  81.                 "thumbnail": "https://randomuser.me/api/portraits/thumb/women/33.jpg"
  82.                 },
  83.                 "nat": "NZ"
  84.                 },
  85.                 {
  86.                 "gender": "female",
  87.                 "name": {
  88.                 "title": "mrs",
  89.                 "first": "ilona",
  90.                 "last": "geilen"
  91.                 },
  92.                 "location": {
  93.                 "street": "4511 hoefsmederijstraat",
  94.                 "city": "koggenland",
  95.                 "state": "limburg",
  96.                 "postcode": 97448
  97.                 },
  98.                 "email": "ilona.geilen@example.com",
  99.                 "login": {
  100.                 "username": "yellowgoose939",
  101.                 "password": "stick",
  102.                 "salt": "SMyWzS10",
  103.                 "md5": "5d127c7060ac872658e0879ed86f9af0",
  104.                 "sha1": "67c81741e4f0affc670a44fa4d58d1778d0bf1ae",
  105.                 "sha256": "1ef4dd5f7f84bb65ddef35995ae064a8b30eeb2aaf101bfc7e74cb82b3e5bdbe"
  106.                 },
  107.                 "dob": "1950-06-24 04:54:11",
  108.                 "registered": "2011-01-02 02:27:41",
  109.                 "phone": "(998)-114-7736",
  110.                 "cell": "(493)-378-8667",
  111.                 "id": {
  112.                 "name": "BSN",
  113.                 "value": "83572496"
  114.                 },
  115.                 "picture": {
  116.                 "large": "https://randomuser.me/api/portraits/women/89.jpg",
  117.                 "medium": "https://randomuser.me/api/portraits/med/women/89.jpg",
  118.                 "thumbnail": "https://randomuser.me/api/portraits/thumb/women/89.jpg"
  119.                 },
  120.                 "nat": "NL"
  121.             }]})                
  122.         .end((err, res) => {
  123.             console.log(res.body);
  124.             chai.expect(res.body).to.be.an('array');
  125.             chai.expect(res.body[0].value).to.equal(3);
  126.             chai.expect(res.body[0].name).to.equal("female");
  127.             done()
  128.         });
  129.     })
  130. })
  131.  
  132. describe("test-aws-lambda", function() {
  133.     it("should return results in correct format", function(done){
  134.         request
  135.         .post('https://census-toy.nceng.net/prod/toy-census')
  136.         .send({ actionType: 'CountPasswordComplexity',
  137.         users: [
  138.             {
  139.                 "gender": "male",
  140.                 "name": {
  141.                 "title": "mr",
  142.                 "first": "esat",
  143.                 "last": "körmükçü"
  144.                 },
  145.                 "location": {
  146.                 "street": "9679 vatan cd",
  147.                 "city": "adıyaman",
  148.                 "state": "mersin",
  149.                 "postcode": 15373
  150.                 },
  151.                 "email": "esat.körmükçü@example.com",
  152.                 "login": {
  153.                 "username": "tinypanda568",
  154.                 "password": "colombia!",
  155.                 "salt": "mFBwIrE9",
  156.                 "md5": "d9ec8f0945fda9a4b360e0b3e1f77663",
  157.                 "sha1": "5efba9ac45ebabcbe60328ff6d57714ecafc5038",
  158.                 "sha256": "5c6c83f8daa39a11ab395e8de60c5b7b7d826601cedb0479f7a01c9e5b68a7d0"
  159.                 },
  160.                 "dob": "1955-09-01 06:12:29",
  161.                 "registered": "2003-07-01 04:59:49",
  162.                 "phone": "(221)-821-5631",
  163.                 "cell": "(288)-834-8078",
  164.                 "id": {
  165.                 "name": "",
  166.                 "value": null
  167.                 },
  168.                 "picture": {
  169.                 "large": "https://randomuser.me/api/portraits/men/7.jpg",
  170.                 "medium": "https://randomuser.me/api/portraits/med/men/7.jpg",
  171.                 "thumbnail": "https://randomuser.me/api/portraits/thumb/men/7.jpg"
  172.                 },
  173.                 "nat": "TR"
  174.                 },
  175.                 {
  176.                 "gender": "male",
  177.                 "name": {
  178.                 "title": "monsieur",
  179.                 "first": "lucas",
  180.                 "last": "blanc"
  181.                 },
  182.                 "location": {
  183.                 "street": "6361 rue barrème",
  184.                 "city": "st-barthélemy vd",
  185.                 "state": "valais",
  186.                 "postcode": 5909
  187.                 },
  188.                 "email": "lucas.blanc@example.com",
  189.                 "login": {
  190.                 "username": "beautifulbutterfly504",
  191.                 "password": "server",
  192.                 "salt": "qu962MwJ",
  193.                 "md5": "3fc739751892db30574e769e6d5bfe8d",
  194.                 "sha1": "d3bdceb63e2dd258f02eebd9e2c088a5dc34696e",
  195.                 "sha256": "13270e598c5e68a73146107c9d5f7b15fcb108010dabae0b710e34615adcf266"
  196.                 },
  197.                 "dob": "1958-07-29 09:00:57",
  198.                 "registered": "2012-12-20 04:33:43",
  199.                 "phone": "(230)-955-1785",
  200.                 "cell": "(737)-618-1829",
  201.                 "id": {
  202.                 "name": "AVS",
  203.                 "value": "756.COYC.KWSQ.77"
  204.                 },
  205.                 "picture": {
  206.                 "large": "https://randomuser.me/api/portraits/men/95.jpg",
  207.                 "medium": "https://randomuser.me/api/portraits/med/men/95.jpg",
  208.                 "thumbnail": "https://randomuser.me/api/portraits/thumb/men/95.jpg"
  209.                 },
  210.                 "nat": "CH"
  211.                 },
  212.                 {
  213.                 "gender": "male",
  214.                 "name": {
  215.                 "title": "mr",
  216.                 "first": "aitor",
  217.                 "last": "nuñez"
  218.                 },
  219.                 "location": {
  220.                 "street": "6249 calle de pedro bosch",
  221.                 "city": "santander",
  222.                 "state": "la rioja",
  223.                 "postcode": 73424
  224.                 },
  225.                 "email": "aitor.nuñez@example.com",
  226.                 "login": {
  227.                 "username": "whitebear826",
  228.                 "password": "goblue@",
  229.                 "salt": "MYaHbwm3",
  230.                 "md5": "c0981a85ce8ce215b7e7a033aac56280",
  231.                 "sha1": "e880971cab792c4482b5f6f3ef073b02b82aea17",
  232.                 "sha256": "3af01d3153ed24cb03d25ce1986cbb44fab5f3c2b0784cce5bc6d4ff0d82229e"
  233.                 },
  234.                 "dob": "1978-02-12 11:45:36",
  235.                 "registered": "2010-05-15 22:02:57",
  236.                 "phone": "941-896-607",
  237.                 "cell": "668-466-874",
  238.                 "id": {
  239.                 "name": "DNI",
  240.                 "value": "70950695-D"
  241.                 },
  242.                 "picture": {
  243.                 "large": "https://randomuser.me/api/portraits/men/78.jpg",
  244.                 "medium": "https://randomuser.me/api/portraits/med/men/78.jpg",
  245.                 "thumbnail": "https://randomuser.me/api/portraits/thumb/men/78.jpg"
  246.                 },
  247.                 "nat": "ES"
  248.                 }]})                
  249.         .end((err, res) => {
  250.             console.log(res.body);
  251.             res.body.map(function(a){return a.password.length});
  252.             chai.expect(res.body).to.be.an('array');
  253.             chai.expect(res.body[0].value).to.equal(3);
  254.             chai.expect(res.body[0].name).to.equal("");
  255.             done()
  256.         });
  257.     })
  258. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement