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/  Your IP : 104.23.197.31   [ Reverse IP ]
Web Server : nginx/1.18.0
System : Linux ip-172-31-29-104 5.15.0-1075-aws #82~20.04.1-Ubuntu SMP Thu Dec 19 05:24:09 UTC 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.3-4ubuntu2.29
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Domains : 2 Domains
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/app/eseso/api/node_modules/node-ses/test/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /var/app/eseso/api/node_modules/node-ses/test/index.js
'use strict';

// use mocha for test

var assert = require('assert')
  , ses = require('../')
  , crypto = require('crypto');

function create () {
  return new ses.Email({
      key: 'key'
    , secret: 'secret'
    , from: 'from'
    , subject: 'subject'
    , message: 'message'
    , altText: 'alt'
    , to: ['to@example.com', 'one@example.com']
    , cc: 'cc@example.com'
    , bcc: ['bcc@example.com', 'yoyo@example.com']
    , replyTo: 'bcc@example.com'
  });
}

function createRaw (){
  return new ses.Email({
      action : 'SendRawEmail'
    , key: 'key'
    , secret: 'secret'
    , from: 'from'
    , rawMessage: 'rawMessage'
  });
}

describe('node-ses', function(){
  it('should have createClient and Email exports', function (){
    assert.equal('function', typeof ses.createClient);
    assert.equal('function', typeof ses.Email);
  });

  it('should have a version', function(){
    assert(ses.version);
  });
});

describe('createClient', function(){
  var client = ses.createClient({
      key: 'mykey'
    , secret: 'mysecret'
  });

  it('should have a key', function(){
    assert.ok(client.key);
  });

  it('should have a secret', function(){
    assert.ok(client.secret);
  });

  it('should have an amazon property', function(){
    assert.ok(client.amazon);
  });

  it('amazon should default correctly', function(){
    var amazon = 'https://email.us-east-1.amazonaws.com';
    assert.equal(client.amazon, amazon);
  });

  it('amazon should be overiddable', function(){
    var client = ses.createClient({
        amazon: 'http://www.google.com'
      , key: 1
      , secret: 2
    });
    assert.equal(client.amazon, 'http://www.google.com');
  });

  it('should not require options', function(){
    var client = ses.createClient();
    assert.equal(client.key, undefined);
  });

  it('should require a key', function(){
    try {
      ses.createClient();
    } catch (err) {
      if (!/key is required/.test(err)) {
        throw err;
      }
    }
  });

  it('should require a secret', function(){
    try {
      ses.createClient({ key: 1 });
    } catch (err) {
      if (!/secret is required/.test(err)) {
        throw err;
      }
    }
  })

  describe('sendemail', function(){
    it('should be a function', function(){
      assert.equal('function', typeof client.sendemail);
    });
  });

  describe('sendEmail', function(){
    it('should be a function', function(){
      assert.equal('function', typeof client.sendEmail);
    });
  });

  describe('sendRawEmail', function(){
    it('should be a function', function(){
      assert.equal('function', typeof client.sendRawEmail);
    });
  });
});

describe('sendEmail', function(){
  var email = create();

  it('should have key', function(){
    assert.equal('key', email.key);
  });

  it('should have secret', function(){
    assert.equal('secret', email.secret);
  });

  it('should have from', function(){
    assert.equal('from', email.from);
  });

  it('should have subject', function(){
    assert.equal('subject', email.subject);
  });

  it('should have message', function(){
    assert.equal('message', email.message);
  });

  it('should have altText', function(){
    assert.equal('alt', email.altText);
  });

  describe('#extractRecipient', function(){
    it('should default to an array', function(){
      email.extractRecipient({ to: 'hi' }, 'from');
      assert(Array.isArray(email.from));
      assert.equal(0, email.from.length);
    });

    it('should convert to an array', function (){
      email.extractRecipient({ to: 'hi' }, 'to');
      assert(Array.isArray(email.from));
      assert.equal(1, email.to.length);
      assert.equal('hi', email.to[0]);
    });

    it('should leave arrays untouched', function(){
      email.extractRecipient({ yep: ['hi'] }, 'yep');
      assert(Array.isArray(email.yep));
      assert.equal(1, email.yep.length);
      assert.equal('hi', email.yep[0]);
    });
  });

  describe('#addMessage', function(){
    var email = create();

    it('should be a function', function(){
      assert.equal('function', typeof email.addMessage);
    });

    it('should add subject,message,altText', function(){
      var msg = email.addMessage({});
      assert(msg['Message.Subject.Data']);
      assert(msg['Message.Subject.Charset']);
      assert(msg['Message.Body.Html.Data']);
      assert(msg['Message.Body.Html.Charset']);
      assert(msg['Message.Body.Text.Data']);
      assert(msg['Message.Body.Text.Charset']);

      assert.equal(msg['Message.Subject.Data'], 'subject');
      assert.equal(msg['Message.Subject.Charset'], 'UTF-8');
      assert.equal(msg['Message.Body.Html.Data'], 'message');
      assert.equal(msg['Message.Body.Html.Charset'], 'UTF-8');
      assert.equal(msg['Message.Body.Text.Data'], 'alt');
      assert.equal(msg['Message.Body.Text.Charset'], 'UTF-8');
    });
  });

  describe('#addDestination', function(){
    var email = create();
    it('should be a function', function(){
      assert.equal('function', typeof email.addDestination);
    });

    it('should add Destination data', function(){
      var msg = email.addDestination({});
      assert(msg['Destination.ToAddresses.member.1']);
      assert(msg['Destination.ToAddresses.member.2']);
      assert(msg['Destination.CcAddresses.member.1']);
      assert(msg['Destination.BccAddresses.member.1']);
      assert(msg['Destination.BccAddresses.member.2']);
      // todo values
      assert.equal(msg['Destination.ToAddresses.member.1'], 'to@example.com');
      assert.equal(msg['Destination.ToAddresses.member.2'], 'one@example.com');
      assert.equal(msg['Destination.CcAddresses.member.1'], 'cc@example.com');
      assert.equal(msg['Destination.BccAddresses.member.1'], 'bcc@example.com');
      assert.equal(msg['Destination.BccAddresses.member.2'], 'yoyo@example.com');
    });
  });

  describe('#addReplyTo', function(){
    var email = create();

    it('should be a function', function(){
      assert.equal('function', typeof email.addReplyTo);
    });

    it('should add replyTo data', function(){
      var msg = email.addReplyTo({});
      assert(msg['ReplyToAddresses.member.1']);
      assert.equal(msg['ReplyToAddresses.member.1'], 'bcc@example.com');
    });
  });

  describe('#validate', function(){
    var email = create();

    it('should be a function', function(){
      assert.equal('function', typeof email.validate);
    });

    it('should pass', function(){
      assert.equal(undefined, email.validate());
    });

    it('should fail with To, Cc or Bcc is required', function(){
      email.to = [];
      email.cc = [];
      email.bcc = [];
      assert.equal('To, Cc or Bcc is required', email.validate());

      email.cc = ['works'];
      assert.equal(undefined, email.validate());
      email.cc = [];

      email.bcc = ['works'];
      assert.equal(undefined, email.validate());
      email.bcc = [];

      email.to = ['works'];
      assert.equal(undefined, email.validate());
    });

    it('should fail with From is required', function(){
      delete email.from;
      assert.equal('From is required', email.validate());
      email.from = null;
      assert.equal('From is required', email.validate());
      email.from = '';
      assert.equal('From is required', email.validate());
      email.from = 'yup@asdf.com';
      assert.equal(undefined, email.validate());
    });

    it('should fail with Subject is required', function(){
      delete email.subject;
      assert.equal('Subject is required', email.validate());
      email.subject = null;
      assert.equal('Subject is required', email.validate());
      email.subject = '';
      assert.equal('Subject is required', email.validate());
      email.subject = 'spammer';
      assert.equal(undefined, email.validate());
    });
  });

  describe('#data', function(){
    var email = create();

    it('should be a function', function(){
      assert.equal('function', typeof email.data);
    });

    it('should contain the formatted emails data', function(){
      var d = email.data({});
      assert(d.Action);
      assert.equal(d.Action, 'SendEmail');
      assert(d.AWSAccessKeyId);
      assert.equal(email.key, d.AWSAccessKeyId);
      assert(d.Source);
      assert.equal(email.from, d.Source);
      assert(d['Destination.ToAddresses.member.1']);
      assert(d['Destination.CcAddresses.member.1']);
      assert(d['Destination.BccAddresses.member.1']);
      assert(d['Message.Subject.Data']);
      assert(d['Message.Subject.Charset']);
      assert(d['Message.Body.Html.Data']);
      assert(d['Message.Body.Html.Charset']);
      assert(d['Message.Body.Text.Data']);
      assert(d['Message.Body.Text.Charset']);
      assert(d['ReplyToAddresses.member.1']);
    });
  });

  describe('#send', function(){
    var email = create();

    email.amazon = ses.amazon;

    it('should be a function', function(){
      assert.equal('function', typeof email.send);
    });

    it('should callback an error', function(done){
      this.timeout(20000);
      var calledTimes = 0;
      email.send(function (err) {
        calledTimes++;
        assert.equal(calledTimes,1,'callback was called only once');
        assert(err);
        assert(err.Message);
        assert(/Non-whitespace/.test(err.Message));
        // Wait to see if the code is accidentally going to run the test before declaring done.
        setTimeout(done,1000);
      });
    });

    if (process.env.NODE_SES_KEY && process.env.NODE_SES_SECRET && process.env.NODE_SES_EMAIL) {
      it('should succeed and return the response from aws as object', function(done){
        var client = ses.createClient({
            key: process.env.NODE_SES_KEY
          , secret: process.env.NODE_SES_SECRET
        });
        this.timeout(20000);

        client.sendemail({
            from: process.env.NODE_SES_EMAIL
          , subject: 'testing node-ses'
          , message: 'this is a test'
          , altText: 'this is an alt txt'
          , to: process.env.NODE_SES_EMAIL
          , cc: process.env.NODE_SES_EMAIL
          , bcc: process.env.NODE_SES_EMAIL
          , replyTo: process.env.NODE_SES_EMAIL
        }, function (err, data) {
          assert(!err);
          assert(data);
          assert(typeof(data) === 'object');
          assert(data.SendEmailResponse);
          assert(data.SendEmailResponse.ResponseMetadata);
          done();
        });
      });
    } else {
      console.error('You are not testing with Amazons SES service');
    }
  });
});

describe('_processResponse', function () {
  var email = create();

  it('should errback with error Type:NodeSesInternal error if there is an error with the HTTP request', function(done) {
      email._processResponse({ message: 'BOOM'}, undefined, undefined, function (error) {
          assert.deepEqual(error, {
            Type: 'NodeSesInternal',
            Code: 'RequestError',
            Message: {
              message : 'BOOM'
            }
          });
          done();
      })
  });

  it('Should errback w/XmlError if error response cannot be parsed', done => {
      var res = { statusCode : 500 };
      var data = 'BOOM';
      email._processResponse(undefined,  res , data, function (error) {
          assert.deepEqual(error, {
            Type: 'NodeSesInternal',
            Code: 'XmlError',
            Message:  null,
          });
          done();
      })
  });
});

describe('sendRawEmail', function(){
  var email = createRaw();

  it('should have key', function(){
    assert.equal('key', email.key);
  });

  it('should have secret', function(){
    assert.equal('secret', email.secret);
  });

  it('should have from', function(){
    assert.equal('from', email.from);
  });

  it('should have rawMessage', function () {
    assert.equal('rawMessage', email.rawMessage);
  });

  describe('#headers', function(){
    var email = createRaw();

    it('should be a function', function(){
      assert.equal('function', typeof email.headers);
    });

  });

  describe('#validate', function(){
    var email = createRaw();

    it('should be a function', function(){
      assert.equal('function', typeof email.validate);
    });

    it('should pass', function(){
      assert.equal(undefined, email.validate());
    });

    it('should fail with From is required', function(){
      delete email.from;
      assert.equal('From is required', email.validate());
      email.from = null;
      assert.equal('From is required', email.validate());
      email.from = '';
      assert.equal('From is required', email.validate());
      email.from = 'yup@asdf.com';
      assert.equal(undefined, email.validate());
    });

    it('should fail with Raw message is required', function(){
      delete email.rawMessage;
      assert.equal('Raw message is required', email.validate());
      email.rawMessage = null;
      assert.equal('Raw message is required', email.validate());
      email.rawMessage = '';
      assert.equal('Raw message is required', email.validate());
      email.rawMessage = 'rawMessage';
      assert.equal(undefined, email.validate());
    });
  });

  describe('#data', function(){
    var email = createRaw();

    it('should be a function', function(){
      assert.equal('function', typeof email.data);
    });

    it('should contain the formatted emails data', function(){
      var d = email.data();
      assert(d.Action);
      assert.equal(d.Action, 'SendRawEmail');
      assert(d.AWSAccessKeyId);
      assert.equal(email.key, d.AWSAccessKeyId);
      assert(d.Source);
      assert.equal(email.from, d.Source);
      assert(d['RawMessage.Data']);
    });
  });

  describe('#send raw', function(){
    var email = createRaw();

    email.amazon = ses.amazon;

    it('should be a function', function(){
      assert.equal('function', typeof email.send);
    });

    it('should callback an error', function(done){
      this.timeout(20000);
      var calledTimes = 0;
      email.send(function (err) {
        calledTimes++;
        assert.equal(calledTimes,1,'callback was called only once');
        assert(err);
        //assert(err.Message);
        //assert(/^The security token included in the request is invalid/.test(err.Message));
        // Wait to see if the code is accidentally going to run the test before declaring done.
        setTimeout(done,2000);
      });
    });

    if (process.env.NODE_SES_KEY && process.env.NODE_SES_SECRET) {
      it('should succeed', function(done){
        var client = ses.createClient({
            key: process.env.NODE_SES_KEY
          , secret: process.env.NODE_SES_SECRET
        });

        client.sendRawEmail({
            from: process.env.NODE_SES_EMAIL
            , rawMessage: [
              'From: <'+process.env.NODE_SES_EMAIL+'>'
            , 'To: <'+process.env.NODE_SES_EMAIL+'>'
            , 'Subject: greetings'
            , 'Content-Type: multipart/mixed;'
            , '    boundary="_003_97DCB304C5294779BEBCFC8357FCC4D2"'
            , 'MIME-Version: 1.0'
            , ''
            , '--_003_97DCB304C5294779BEBCFC8357FCC4D2'
            , 'Content-Type: text/plain; charset="us-ascii"'
            , 'Content-Transfer-Encoding: quoted-printable'
            , 'Hi Aaron,'
            , ''
            , 'Sample code file from tests in node-ses.'
            , ''
            , 'Cheers,'
            , '@brozeph'
            , ''
            , '--_003_97DCB304C5294779BEBCFC8357FCC4D2'
            , 'Content-Type: text/plain; name="code.txt"'
            , 'Content-Description: code.txt'
            , 'Content-Disposition: attachment; filename="code.txt"; size=4;'
            , '    creation-date="Mon, 03 Aug 2015 11:39:39 GMT";'
            , '    modification-date="Mon, 03 Aug 2015 11:39:39 GMT"'
            , 'Content-Transfer-Encoding: base64'
            , ''
            , 'ZWNobyBoZWxsbyB3b3JsZAo='
            , ''
            , '--_003_97DCB304C5294779BEBCFC8357FCC4D2'
            , ''
          ].join('\r\n')
        }, function (err, data) {
          assert(!err);
          assert(data);
          done();
        });
      });
    } else {
      console.error('You are not testing with Amazons SES service');
    }
  });
});

Anon7 - 2022
AnonSec Team