How to use callbackURL method in mountebank

Best JavaScript code snippet using mountebank

tests.js

Source:tests.js Github

copy

Full Screen

1/* global $, bean */2/**3 * Mocha config4 */5mocha.timeout(60000);6mocha.ui('bdd');7mocha.reporter('html');8mocha.globals(['jQuery*', '__auth0jp*', 'Auth0*']);9/**10 * Define some support variables11 */12var placeholderSupport = ('placeholder' in document.createElement('input'));13var placeholderSupportPrefix = placeholderSupport ? '' : 'not ';14/**15 * Test Auth0Lock16 */17describe('Auth0Lock', function () {18 var domain = 'abc.auth0.com';19 var clientID = '123456789';20 var callbackURL = 'http://myapp.com/callback';21 var widget, client, getClientConfiguration;22 beforeEach(function (done) {23 getClientConfiguration = Auth0Lock.prototype.getClientConfiguration;24 Auth0Lock.prototype.getClientConfiguration = function (cb) {25 var $client = {26 id: clientID,27 strategies: [{28 'name': 'facebook',29 'connections': [{ 'name': 'facebook', 'domain': '' }]30 }, {31 'name': 'twitter',32 'connections': [{ 'name': 'twitter', 'domain': '' }]33 }, {34 'name': 'google-oauth2',35 'connections': [{ 'name': 'google-oauth2', 'domain': '' }]36 }, {37 'name': 'adfs',38 'connections': [{ 'name': 'contoso', 'domain': 'contoso.com' }]39 }, {40 'name': 'auth0-adldap',41 'connections': [{ 'name': 'adldap', 'domain': 'litware.com' }]42 }, {43 'name': 'auth0',44 'connections': [45 { 'name': 'dbTest', 'domain': '',46 'showSignup': true, 'showForgot': true },47 { 'name': 'Username-Password-Authentication', 'domain': '' }48 ]49 }, {50 'name': 'google-apps',51 'connections': [52 { 'name': 'google-app1', 'domain': '' },53 { 'name': 'google-app2', 'domain': '' },54 { 'name': 'google-app3', 'domain': '' }55 ]56 }57 ]58 };59 if ('function' === typeof done) {60 cb($client);61 }62 };63 widget = new Auth0Lock(clientID, domain);64 client = widget.$auth0;65 client.getSSOData = function (withAd, callback) {66 callback(null, { sso: false });67 };68 done();69 });70 afterEach(function (done) {71 global.window.location.hash = '';72 global.window.Auth0 = null;73 Auth0Lock.prototype.getClientConfiguration = getClientConfiguration;74 if (widget) {75 widget.hide(done);76 } else {77 $('#a0-lock').remove();78 done();79 }80 });81 describe('$dicts usage', function () {82 it('should expose at the instance level the $dicts object with dictionaries', function(done) {83 expect(widget.$dicts).to.not.be.empty();84 done();85 });86 it('should propagate the overriden properties on top of dict provided', function (done) {87 var title = "Helloooooooo";88 // override the original `en` dict89 widget.$dicts.en.signin.title = title;90 widget91 .once('signin ready', function () {92 expect(widget.options.i18n.t('signin:title')).to.be(title);93 done();94 })95 .show({96 dict: 'en'97 })98 });99 });100 it('should setup client with callbackOnLocationHash', function (done) {101 widget102 .once('signin ready', function() {103 expect(client._callbackOnLocationHash).to.be(true);104 done();105 })106 .show({107 responseType: 'token'108 });109 });110 it('should setup client with callbackURL', function (done) {111 widget112 .once('ready', function() {113 expect(client._callbackURL).to.be(callbackURL);114 done();115 })116 .show({117 callbackURL: callbackURL118 });119 });120 it('should setup client to use JSONP', function (done) {121 widget122 .once('ready', function() {123 expect(client._useJSONP).to.be(true);124 done();125 })126 .show({127 forceJSONP: true128 });129 });130 it('should remove widget when user close it', function (done) {131 widget132 .once('ready', function () {133 bean.fire($('#a0-lock a.a0-close')[0], 'click');134 })135 .once('hidden', function () {136 expect($('#a0-lock').length).to.equal(0);137 done();138 })139 .show({140 callbackURL: callbackURL,141 responseType: 'token'142 });143 });144 it('should show only notloggedin view if SSO data is not present', function (done) {145 widget146 .once('ready', function () {147 expect($('#a0-lock .a0-notloggedin')).to.not.be.empty();148 expect($('#a0-lock .a0-loggedin')).to.be.empty();149 expect($('#a0-lock .a0-signup')).to.be.empty();150 expect($('#a0-lock .a0-reset')).to.be.empty();151 done();152 })153 .show({154 callbackURL: callbackURL,155 responseType: 'token'156 });157 });158 it('should show only loggedin view with SSO data (social) if it is present', function (done) {159 client.getSSOData = function (withAd, callback) {160 callback(null, {161 sso: true,162 lastUsedUsername: 'john@gmail.com',163 lastUsedConnection: { strategy: 'google-oauth2', name: 'google-oauth2' }164 });165 };166 widget167 .once('ready', function () {168 expect($('#a0-lock .a0-notloggedin')).to.be.empty();169 expect($('#a0-lock .a0-loggedin')).to.not.be.empty();170 expect($('#a0-lock .a0-signup')).to.be.empty();171 expect($('#a0-lock .a0-reset')).to.be.empty();172 expect($('#a0-lock .a0-loggedin .a0-strategy [data-strategy]').attr('title')).to.equal('john@gmail.com (Google)');173 done();174 })175 .show({176 callbackURL: callbackURL,177 responseType: 'token'178 });179 });180 it('should not show loggedin view with SSO data (social) if it is not listed/enabled', function (done) {181 client.getSSOData = function (withAd, callback) {182 callback(null, {183 sso: true,184 lastUsedUsername: 'john@gmail.com',185 lastUsedConnection: { strategy: 'google-oauth2', name: 'google-oauth2' }186 });187 };188 widget189 .once('ready', function () {190 expect($('#a0-lock .a0-notloggedin')).to.not.be.empty();191 expect($('#a0-lock .a0-loggedin')).to.be.empty();192 expect($('#a0-lock .a0-signup')).to.be.empty();193 expect($('#a0-lock .a0-reset')).to.be.empty();194 done();195 })196 .show({197 callbackURL: callbackURL,198 responseType: 'token',199 connections: ['facebook']200 });201 });202 it('should use only specified connections', function (done) {203 widget204 .once('ready', function () {205 expect(widget.$client.strategies.length).to.equal(4);206 expect(widget.$client.strategies[0].name).to.equal('twitter');207 expect(widget.$client.strategies[0].connections.length).to.equal(1);208 expect(widget.$client.strategies[0].connections[0].name).to.equal('twitter');209 expect(widget.$client.strategies[1].name).to.equal('google-oauth2');210 expect(widget.$client.strategies[1].connections.length).to.equal(1);211 expect(widget.$client.strategies[1].connections[0].name).to.equal('google-oauth2');212 expect(widget.$client.strategies[2].name).to.equal('auth0');213 expect(widget.$client.strategies[2].connections.length).to.equal(1);214 expect(widget.$client.strategies[2].connections[0].name).to.equal('dbTest');215 expect(widget.$client.strategies[3].name).to.equal('google-apps');216 expect(widget.$client.strategies[3].connections.length).to.equal(2);217 expect(widget.$client.strategies[3].connections[0].name).to.equal('google-app1');218 expect(widget.$client.strategies[3].connections[1].name).to.equal('google-app3');219 done();220 })221 .show({222 callbackURL: callbackURL,223 responseType: 'token',224 connections: ['twitter', 'google-oauth2', 'invalid-connection', 'google-app1', 'dbTest', 'google-app3']225 });226 });227 it('should fireup loggedin submit on submit in loggedin mode', function (done) {228 client.getSSOData = function (withAd, callback) {229 callback(null, {230 sso: true,231 lastUsedUsername: 'john@gmail.com',232 lastUsedConnection: { strategy: 'google-oauth2', name: 'google-oauth2' }233 });234 };235 client.login = function () {};236 widget237 .once('loggedin submit', function(opts) {238 expect(opts).to.not.be(undefined);239 done();240 })241 .once('ready', function () {242 bean.fire($('.a0-googleplus')[0], 'click');243 })244 .show({245 callbackURL: callbackURL,246 responseType: 'token'247 });248 });249 describe('When assetsUrl option is not specified', function () {250 beforeEach(function() {251 this.widget = new Auth0Lock(clientID, 'abc.contoso.com');252 });253 it('should use domain as assetsUrl if domain is not *.auth0.com', function () {254 expect(this.widget.$options.assetsUrl).to.equal('https://abc.contoso.com/');255 });256 it('should use default assetsUrl if domain is *.auth0.com', function () {257 this.widget = new Auth0Lock(clientID, 'abc.auth0.com:3000');258 expect(this.widget.$options.assetsUrl).to.equal('https://cdn.auth0.com/');259 });260 it('should use EU assetsUrl if domain is *.eu.auth0.com', function () {261 this.widget = new Auth0Lock(clientID, 'abc.eu.auth0.com:3000');262 expect(this.widget.$options.assetsUrl).to.equal('https://cdn.eu.auth0.com/');263 });264 });265 describe('When assetsUrl option is specified', function () {266 it('should use provided assetsUrl and ignore defaults', function () {267 this.widget = new Auth0Lock(clientID, 'abc.contoso.com', {268 assetsUrl: 'https://sdk.myauth0-custom.com/'269 });270 expect(this.widget.$options.assetsUrl).to.equal('https://sdk.myauth0-custom.com/');271 });272 });273 describe('Sign In', function () {274 it('should signin with social connection', function (done) {275 client.login = function (options) {276 expect(options.connection).to.equal('google-oauth2');277 expect(options.username).to.be(undefined);278 done();279 };280 widget281 .once('ready', function () {282 bean.fire($('#a0-lock .a0-notloggedin .a0-iconlist [data-strategy="google-oauth2"]')[0], 'click');283 })284 .show({285 callbackURL: callbackURL,286 responseType: 'token'287 });288 });289 it('should signin with social connection specifying state', function (done) {290 client.login = function (options) {291 expect(options.state).to.equal('foo');292 expect(options.connection).to.equal('google-oauth2');293 expect(options.username).to.be(undefined);294 done();295 };296 widget297 .once('ready', function () {298 bean.fire($('#a0-lock .a0-notloggedin .a0-iconlist [data-strategy="google-oauth2"]')[0], 'click');299 })300 .show({301 callbackURL: callbackURL,302 responseType: 'token',303 authParams: { state: 'foo' }304 });305 });306 it('should signin with social connection specifying connection_scope if one is provided', function (done) {307 var connection_scopes = {308 'twitter': ['grant1', 'grant2'],309 'google-oauth2': ['grant3'] };310 var connections = ['twitter', 'google-oauth2'];311 client.login = function (options) {312 expect(options.connection).to.equal('twitter');313 expect(options.username).to.be(undefined);314 expect(options.connection_scope.length).to.equal(2);315 expect(options.connection_scope[0]).to.equal('grant1');316 expect(options.connection_scope[1]).to.equal('grant2');317 expect(options.connection_scopes).to.not.be.empty();318 done();319 };320 widget321 .once('ready', function () {322 bean.fire($('#a0-lock .a0-notloggedin .a0-iconlist [data-strategy="twitter"]')[0], 'click');323 })324 .show({ callbackURL: callbackURL, responseType: 'token', connections: connections, authParams: { connection_scopes: connection_scopes }});325 });326 it('should signin with social connection with undefined connection_scope if one is not provided (does not throw)', function (done) {327 var connection_scopes = {328 'twitter': ['grant1', 'grant2'] };329 var connections = ['twitter', 'google-oauth2'];330 client.login = function (options) {331 expect(options.connection).to.equal('google-oauth2');332 expect(options.username).to.be(undefined);333 expect(options.connection_scope).to.be(undefined);334 expect(options.connection_scopes).to.not.be.empty();335 done();336 };337 widget338 .once('ready', function () {339 bean.fire($('#a0-lock .a0-notloggedin .a0-iconlist [data-strategy="google-oauth2"]')[0], 'click');340 })341 .show({ callbackURL: callbackURL, responseType: 'token', connections: connections, authParams: { connection_scopes: connection_scopes }});342 });343 it('should signin with database connection (auth0 strategy)', function (done) {344 client.login = function (options) {345 expect(options.connection).to.equal('dbTest');346 expect(options.username).to.equal('john@fabrikam.com');347 expect(options.password).to.equal('xyz');348 done();349 };350 widget351 .once('ready', function () {352 $('#a0-lock .a0-notloggedin .a0-emailPassword .a0-email input').val('john@fabrikam.com');353 $('#a0-lock .a0-notloggedin .a0-emailPassword .a0-password input').val('xyz');354 $('#a0-lock .a0-notloggedin .a0-emailPassword .a0-action button.a0-primary').trigger('click');355 })356 .show({ callbackURL: callbackURL, responseType: 'token', authParams: { state: 'foo' }});357 });358 it('should signin with database connection (auth0 strategy) specifying state authParam', function (done) {359 client.login = function (options) {360 expect(options.state).to.equal('foo');361 expect(options.connection).to.equal('dbTest');362 expect(options.username).to.equal('john@fabrikam.com');363 expect(options.password).to.equal('xyz');364 done();365 };366 widget367 .once('ready', function () {368 $('#a0-lock .a0-notloggedin .a0-emailPassword .a0-email input').val('john@fabrikam.com');369 $('#a0-lock .a0-notloggedin .a0-emailPassword .a0-password input').val('xyz');370 $('#a0-lock .a0-notloggedin .a0-emailPassword .a0-action button.a0-primary').trigger('click');371 })372 .show({ callbackURL: callbackURL, responseType: 'token', authParams: { state: 'foo' }});373 });374 it('should signin with adldap connection (auth0-adldap strategy)', function (done) {375 client.login = function (options) {376 expect(options.connection).to.equal('adldap');377 expect(options.username).to.equal('peter');378 expect(options.password).to.equal('zzz');379 done();380 };381 widget382 .once('ready', function() {383 $('#a0-lock .a0-notloggedin .a0-emailPassword .a0-email input').val('peter@litware.com');384 $('#a0-lock .a0-notloggedin .a0-emailPassword .a0-password input').val('zzz');385 $('#a0-lock .a0-notloggedin .a0-emailPassword .a0-action button.a0-primary').trigger('click');386 })387 .show({388 callbackURL: callbackURL,389 responseType: 'token',390 defaultUserPasswordConnection: 'adldap'391 });392 });393 it('should signin with enterprise connection', function (done) {394 client.login = function (options) {395 expect(options.connection).to.equal('contoso');396 expect(options.username).to.be(undefined);397 done();398 };399 widget400 .once('ready', function () {401 $('#a0-lock .a0-notloggedin .a0-emailPassword .a0-email input').val('mary@contoso.com');402 // we need this to check if password is ignored or not in validation403 bean.fire($('#a0-lock .a0-notloggedin .a0-emailPassword .a0-email input')[0], 'input');404 $('#a0-lock .a0-notloggedin .a0-emailPassword .a0-action button.a0-primary').trigger('click');405 })406 .show({407 callbackURL: callbackURL,408 responseType: 'token'409 });410 });411 it('should signin with enterprise connection specifying authParams', function (done) {412 client.login = function (options) {413 expect(options.state).to.equal('foo');414 expect(options.connection).to.equal('contoso');415 expect(options.username).to.be(undefined);416 done();417 };418 widget419 .once('ready', function () {420 $('#a0-lock .a0-notloggedin .a0-emailPassword .a0-email input').val('mary@contoso.com');421 // we need this to check if password is ignored or not in validation422 bean.fire($('#a0-lock .a0-notloggedin .a0-emailPassword .a0-email input')[0], 'input');423 $('#a0-lock .a0-notloggedin .a0-emailPassword .a0-action button.a0-primary').trigger('click');424 })425 .show({ callbackURL: callbackURL, responseType: 'token', authParams: { state: 'foo' }});426 });427 it('should send extra authParams to login', function (done) {428 client.login = function (options) {429 expect(options.access_type).to.equal('offline');430 done();431 };432 widget433 .once('ready', function () {434 bean.fire($('#a0-lock .a0-notloggedin .a0-iconlist [data-strategy="google-oauth2"]')[0], 'click');435 })436 .show({ callbackURL: callbackURL, responseType: 'token', authParams: { access_type: 'offline' } });437 });438 it('should emit signin submit event when signin is starting', function (done) {439 client.login = function (options) {440 expect(options.login_hint).to.equal('john@fabrikam.com');441 done();442 };443 widget444 .once('ready', function () {445 $('#a0-lock .a0-notloggedin .a0-emailPassword .a0-email input').val('john@fabrikam.com');446 $('#a0-lock .a0-notloggedin .a0-emailPassword .a0-password input').val('xyz');447 $('#a0-lock .a0-notloggedin .a0-emailPassword .a0-action button.a0-primary').trigger('click');448 })449 .on('signin submit', function (options, context) {450 if (!options.authParams) {451 options.authParams = {};452 }453 options.authParams.login_hint = context.email;454 })455 .show({ callbackURL: callbackURL, responseType: 'token', authParams: { state: 'foo' }});456 });457 it('should emit signin error event when email is empty', function (done) {458 widget459 .once('ready', function () {460 $('#a0-lock .a0-notloggedin .a0-emailPassword .a0-password input').val('xyz');461 $('#a0-lock .a0-notloggedin .a0-emailPassword .a0-action button.a0-primary').trigger('click');462 })463 .on('signin error', function (err) {464 expect(err.message).to.be('email empty');465 done();466 })467 .show({ callbackURL: callbackURL, responseType: 'token', authParams: { state: 'foo' }});468 });469 it('should emit signin error event when email is invalid', function (done) {470 widget471 .once('ready', function () {472 $('#a0-lock .a0-notloggedin .a0-emailPassword .a0-email input').val('john.@#$@fabrikam.com');473 $('#a0-lock .a0-notloggedin .a0-emailPassword .a0-password input').val('xyz');474 $('#a0-lock .a0-notloggedin .a0-emailPassword .a0-action button.a0-primary').trigger('click');475 })476 .on('signin error', function (err) {477 expect(err.message).to.be('email invalid');478 done();479 })480 .show({ callbackURL: callbackURL, responseType: 'token', authParams: { state: 'foo' }});481 });482 it('should emit signin error event when password is empty', function (done) {483 widget484 .once('ready', function () {485 $('#a0-lock .a0-notloggedin .a0-emailPassword .a0-email input').val('john@fabrikam.com');486 $('#a0-lock .a0-notloggedin .a0-emailPassword .a0-action button.a0-primary').trigger('click');487 })488 .on('signin error', function (err) {489 expect(err.message).to.be('password empty');490 done();491 })492 .show({ callbackURL: callbackURL, responseType: 'token', authParams: { state: 'foo' }});493 });494 it('should emit submit envent when logging with social connections', function (done) {495 client.login = function () {};496 widget497 .once('signin submit', function(opts) {498 expect(opts).to.not.be(undefined);499 done();500 })501 .once('ready', function () {502 bean.fire($('#a0-lock .a0-notloggedin .a0-iconlist [data-strategy="google-oauth2"]')[0], 'click');503 })504 .show({505 callbackURL: callbackURL,506 responseType: 'token'507 });508 });509 it('should emit signin error event when password is empty', function (done) {510 widget511 .once('ready', function () {512 $('#a0-lock .a0-notloggedin .a0-emailPassword .a0-email input').val('john@fabrikam.com');513 $('#a0-lock .a0-notloggedin .a0-emailPassword .a0-action button.a0-primary').trigger('click');514 })515 .on('signin error', function (err) {516 expect(err.message).to.be('password empty');517 done();518 })519 .show({ callbackURL: callbackURL, responseType: 'token', authParams: { state: 'foo' }});520 });521 describe('when requires_username is enabled', function() {522 beforeEach(function() {523 this.options = this.options || {};524 // Mock `_isUsernameRequired` so it asumes database has enabled525 // requires_username on it's configuration526 this.options._isUsernameRequired = function() { return true; };527 });528 it('should invalidate an empty username', function (done) {529 var auth0 = widget;530 var password = '12345';531 auth0532 .once('signin ready', function() {533 $('#a0-signin_easy_password').val(password);534 $('#a0-signin_easy_repeat_password').val(password);535 bean.fire($('.a0-signin form')[0], 'submit');536 expect($('.a0-email .a0-error-input')).to.not.be.empty();537 done();538 })539 .showSignin(this.options);540 });541 it('should invalidate an invalid username', function (done) {542 var auth0 = widget;543 var username = '1.1.1.1';544 var password = '12345';545 auth0546 .once('signin ready', function() {547 $('#a0-signin_easy_email').val(username);548 $('#a0-signin_easy_password').val(password);549 $('#a0-signin_easy_repeat_password').val(password);550 bean.fire($('.a0-signin form')[0], 'submit');551 expect($('.a0-email .a0-error-input')).to.not.be.empty();552 expect($('.a0-email .a0-error-input .a0-error-message')).to.not.be.empty();553 expect($('.a0-error-message').text()).to.equal(auth0.options.i18n.t('invalid'));554 done();555 })556 .showSignin(this.options);557 });558 it('should emit signin error event when username is invalid', function (done) {559 var auth0 = widget;560 var username = '1.1.1.1';561 var password = '12345';562 auth0563 .once('signin ready', function() {564 $('#a0-signin_easy_email').val(username);565 $('#a0-signin_easy_password').val(password);566 $('#a0-signin_easy_repeat_password').val(password);567 bean.fire($('.a0-signin form')[0], 'submit');568 })569 .once('signin error', function(err) {570 expect(err.message).to.be('username invalid');571 done();572 })573 .showSignin(this.options);574 });575 it('should still invalidate an invalid email', function (done) {576 var auth0 = widget;577 var email = 'pepo@example';578 var password = '12345';579 auth0580 .once('signin ready', function() {581 $('#a0-signin_easy_email').val(email);582 $('#a0-signin_easy_password').val(password);583 $('#a0-signin_easy_repeat_password').val(password);584 bean.fire($('.a0-signin form')[0], 'submit');585 expect($('.a0-email .a0-error-input')).to.not.be.empty();586 expect($('.a0-email .a0-error-input .a0-error-message')).to.not.be.empty();587 expect($('.a0-error-message').text()).to.equal(auth0.options.i18n.t('invalid'));588 done();589 })590 .showSignin(this.options);591 });592 it('should send valid username on submit', function (done) {593 var auth0 = widget;594 var username = 'pepe';595 var password = '12345';596 client.login = function(options) {597 expect(options.username).to.equal(username);598 expect(options.password).to.equal(password);599 done();600 };601 auth0602 .once('signin ready', function() {603 $('#a0-signin_easy_email').val(username);604 $('#a0-signin_easy_password').val(password);605 $('#a0-signin_easy_repeat_password').val(password);606 bean.fire($('.a0-signin form')[0], 'submit');607 })608 .showSignin(this.options);609 });610 it('should still send valid email on submit', function (done) {611 var auth0 = widget;612 var email = 'pepo@example.com';613 var password = '12345';614 client.login = function(options) {615 expect(options.username).to.equal(email);616 expect(options.password).to.equal(password);617 done();618 };619 auth0620 .once('signin ready', function() {621 $('#a0-signin_easy_email').val(email);622 $('#a0-signin_easy_password').val(password);623 $('#a0-signin_easy_repeat_password').val(password);624 bean.fire($('.a0-signin form')[0], 'submit');625 })626 .showSignin(this.options);627 });628 });629 });630 describe('Sign Up with database connection', function () {631 it('should show only signup view when user clicks on signup button', function (done) {632 widget633 .once('signin ready', function () {634 bean.fire($('#a0-lock .a0-notloggedin .a0-emailPassword .a0-action a.a0-sign-up')[0], 'click');635 })636 .once('signup ready', function (){637 expect($('#a0-lock .a0-notloggedin')).to.be.empty();638 expect($('#a0-lock .a0-loggedin')).to.be.empty();639 expect($('#a0-lock .a0-reset')).to.be.empty();640 expect($('#a0-lock .a0-signup')).to.not.be.empty();641 done();642 })643 .show({644 callbackURL: callbackURL,645 responseType: 'token'646 });647 });648 it('should call auth0.a0-signup', function (done) {649 client.signup = function (options) {650 expect(options.connection).to.equal('dbTest');651 expect(options.username).to.equal('john@fabrikam.com');652 expect(options.password).to.equal('xyz');653 done();654 };655 widget656 .once('signin ready', function () {657 bean.fire($('#a0-lock .a0-notloggedin .a0-emailPassword .a0-action a.a0-sign-up')[0], 'click');658 })659 .once('signup ready', function () {660 $('#a0-lock .a0-signup .a0-emailPassword .a0-email input').val('john@fabrikam.com');661 $('#a0-lock .a0-signup .a0-emailPassword .a0-password input').val('xyz');662 $('#a0-lock .a0-signup .a0-emailPassword .a0-action button.a0-primary').trigger('click');663 })664 .show({665 callbackURL: callbackURL,666 responseType: 'token'667 });668 });669 });670 describe('Change Password with database connection', function () {671 it('should show reset view when user clicks on change password button', function (done) {672 widget673 .once('signin ready', function () {674 bean.fire($('#a0-lock .a0-notloggedin .a0-emailPassword .a0-action a.a0-forgot-pass')[0], 'click');675 })676 .once('reset ready',function () {677 expect($('#a0-lock .a0-notloggedin')).to.be.empty();678 expect($('#a0-lock .a0-loggedin')).to.be.empty();679 expect($('#a0-lock .a0-signup')).to.be.empty();680 expect($('#a0-lock .a0-reset')).to.not.be.empty();681 done();682 })683 .show({684 callbackURL: callbackURL,685 responseType: 'token'686 });687 });688 it('should call auth0.changePassword', function (done) {689 client.changePassword = function (options) {690 expect(options.connection).to.equal('dbTest');691 expect(options.username).to.equal('john@fabrikam.com');692 expect(options.password).to.equal('xyz');693 done();694 };695 widget696 .once('ready', function () {697 bean.fire($('#a0-lock .a0-notloggedin .a0-emailPassword .a0-action a.a0-forgot-pass')[0], 'click');698 })699 .once('reset ready', function () {700 $('#a0-lock .a0-reset .a0-emailPassword .a0-email input').val('john@fabrikam.com');701 $('#a0-lock .a0-reset .a0-emailPassword .a0-password input').val('xyz');702 $('#a0-lock .a0-reset .a0-emailPassword .a0-repeatPassword input').val('xyz');703 $('#a0-lock .a0-reset .a0-emailPassword .a0-action button.a0-primary').trigger('click');704 })705 .show({706 callbackURL: callbackURL,707 responseType: 'token'708 });709 });710 });711 describe('placeholder fallback support', function() {712 it('should have a0-no-placeholder-support class when not supported (' + placeholderSupportPrefix + 'supported)', function(done) {713 widget714 .once('ready', function() {715 var hasClass = $('#a0-lock .a0-overlay').hasClass('a0-no-placeholder-support');716 expect(hasClass).to.be(!placeholderSupport);717 if (!placeholderSupport) {718 var $fallback = $('#a0-lock .a0-no-placeholder-support .a0-sad-placeholder');719 expect($fallback).to.not.be.empty();720 expect($fallback.css('display')).to.equal('block');721 }722 done();723 })724 .show();725 });726 it('should not have a0-no-placeholder-support class when supported (' + placeholderSupportPrefix + 'supported)', function(done) {727 widget728 .once('ready', function() {729 var hasClass = $('#a0-lock .a0-overlay').hasClass('a0-no-placeholder-support');730 expect(!hasClass).to.be(placeholderSupport);731 if (placeholderSupport) {732 var $fallback = $('#a0-lock .a0-no-placeholder-support .a0-sad-placeholder');733 expect($fallback).to.be.empty();734 expect($('#a0-lock .a0-sad-placeholder').css('display')).to.equal('none');735 }736 done();737 })738 .show();739 });740 });...

Full Screen

Full Screen

GraphPanel.js

Source:GraphPanel.js Github

copy

Full Screen

1function svg_left(svgElement,callbackUrl) {2 svg_translate(svgElement, -20, 0);3 svg_wicket_call(callbackUrl, "transform", "translate(-20,0)")4}5function svg_right(svgElement,callbackUrl) {6 svg_translate(svgElement, 20, 0)7 svg_wicket_call(callbackUrl, "transform", "translate(20,0)")8}9function svg_up(svgElement,callbackUrl) {10 svg_translate(svgElement, 0, -20)11 svg_wicket_call(callbackUrl, "transform", "translate(0,-20)")12}13function svg_down(svgElement,callbackUrl) {14 svg_translate(svgElement, 0, 20)15 svg_wicket_call(callbackUrl, "transform", "translate(0,20)")16}17function svg_zoomIn(svgElement,callbackUrl) {18 svg_setScale(svgElement, 1.25, 1.25);19 svg_wicket_call(callbackUrl, "transform", "scale(1.25, 1.25)")20}21function svg_zoomOut(svgElement,callbackUrl) {22 svg_setScale(svgElement, 0.75, 0.75);23 svg_wicket_call(callbackUrl, "transform", "scale(0.75, 0.75)")24}25function svg_reset(svgElement,callbackUrl) { // restore first 3 transforms (generated by GraphViz)26 var transformList = getTransformList(svgElement);27 var xform0 = transformList.getItem(0);28 var xform1 = transformList.getItem(1);29 var xform2 = transformList.getItem(2);30 transformList.clear();31 transformList.appendItem(xform0);32 transformList.appendItem(xform1);33 transformList.appendItem(xform2);34 svg_wicket_call(callbackUrl, "transform", "clear")35}36function svg_translate(svgElement, x, y) {37 var xform = getSVGTransform(svgElement);38 xform.setTranslate(x, y);39 getTransformList(svgElement).appendItem(xform);40}41function svg_setScale(svgElement, x, y) {42 var xform = getSVGTransform(svgElement);43 xform.setScale(x, y);44 getTransformList(svgElement).appendItem(xform);45}46function getTransformList(svgElement) {47 var graphNode = getGraphNode(svgElement)48 return graphNode.transform.baseVal;49}50function getGraphNode(svgElement) {51 return getSVGElement(svgElement).childNodes[1]52}53function getSVGTransform(svgElement) {54 return getSVGElement(svgElement).createSVGTransform();55}56function getSVGElement(svgElement) {57 return document.getElementById(svgElement);58}59function svg_wicket_call(callbackUrl, arg, val) {60 // alert("Calling back to " + callbackUrl + " with " + arg + "=" + val)61 wicketAjaxGet(callbackUrl + '&' + arg + '=' + val, function() { }, function() { });...

Full Screen

Full Screen

config.js

Source:config.js Github

copy

Full Screen

1var path = require('path')2 , rootPath = path.normalize(__dirname);3module.exports = {4 development: {5 db: 'mongodb://USER:PASSWORD@ADDRESS:PORT',6 root: rootPath,7 app: {8 name: 'NAME'9 },10 facebook: {11 clientID: "CLIENT_ID",12 clientSecret: "CLIENT_SECRET",13 callbackURL: "/auth/facebook/callback"14 },15 twitter: {16 clientID: "CLIENT_ID",17 clientSecret: "CLIENT_SECRET",18 callbackURL: "/auth/twitter/callback"19 },20 google: {21 clientID: "CLIENT_ID",22 clientSecret: "CLIENT_SECRET",23 callbackURL: "/auth/google/callback"24 },25 linkedin: {26 clientID: "CLIENT_ID",27 clientSecret: "CLIENT_SECRET",28 callbackURL: "/auth/linkedin/callback"29 },30 foursquare: {31 clientID: "CLIENT_ID",32 clientSecret: "CLIENT_SECRET",33 callbackURL: "/auth/foursquare/callback"34 },35 yahoo: {36 clientID: "CLIENT_ID",37 clientSecret: "CLIENT_SECRET",38 callbackURL: "/auth/yahoo/callback"39 },40 windowslive: {41 clientID: "CLIENT_ID",42 clientSecret: "CLIENT_SECRET",43 callbackURL: "/auth/windowslive/callback"44 }45 },46 production: {47 db: 'mongodb://USER:PASSWORD@ADDRESS:PORT',48 root: rootPath,49 app: {50 name: 'NAME'51 },52 facebook: {53 clientID: "CLIENT_ID",54 clientSecret: "CLIENT_SECRET",55 callbackURL: "/auth/facebook/callback"56 },57 twitter: {58 clientID: "CLIENT_ID",59 clientSecret: "CLIENT_SECRET",60 callbackURL: "/auth/twitter/callback"61 },62 google: {63 clientID: "CLIENT_ID",64 clientSecret: "CLIENT_SECRET",65 callbackURL: "/auth/google/callback"66 },67 linkedin: {68 clientID: "CLIENT_ID",69 clientSecret: "CLIENT_SECRET",70 callbackURL: "/auth/linkedin/callback"71 },72 foursquare: {73 clientID: "CLIENT_ID",74 clientSecret: "CLIENT_SECRET",75 callbackURL: "/auth/foursquare/callback"76 },77 yahoo: {78 clientID: "CLIENT_ID",79 clientSecret: "CLIENT_SECRET",80 callbackURL: "/auth/yahoo/callback"81 },82 windowslive: {83 clientID: "CLIENT_ID",84 clientSecret: "CLIENT_SECRET",85 callbackURL: "/auth/windowslive/callback"86 }87 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var request = require('request');2var imposter = {3 {4 {5 "is": {6 "headers": {7 },8 "body": {9 }10 }11 }12 }13};14var options = {15};16request(options, function (error, response, body) {17 console.log(body);18});19var request = require('request-promise');20var imposter = {21 {22 {23 "is": {24 "headers": {25 },26 "body": {27 }28 }29 }30 }31};32var options = {33};34request(options).then(function (body) {35 console.log(body);36});37var request = require('request-promise');38var imposter = {39 {40 {41 "is": {42 "headers": {43 },44 "body": {45 }46 }47 }48 }49};50var options = {51};52async function createImposter() {53 const body = await request(options);54 console.log(body);55}56createImposter();

Full Screen

Using AI Code Generation

copy

Full Screen

1var request = require('request');2var options = {3 headers: {4 },5 json: {6 {7 {8 "is": {9 "headers": {10 },11 "body": {12 }13 }14 }15 }16 }17};18request(options, function (error, response, body) {19 if (!error && response.statusCode == 201) {20 console.log(body);21 }22});23var request = require('request');24var options = {25 headers: {26 },27 json: {28 {29 {30 "equals": {31 }32 }33 {34 "is": {35 "headers": {36 },37 "body": {38 }39 }40 }41 }42 }43};44request(options, function (error, response, body) {45 if (!error && response.statusCode == 201) {46 console.log(body);47 }48});49var request = require('request');50var options = {51 headers: {52 },53 json: {

Full Screen

Using AI Code Generation

copy

Full Screen

1var mb = require('mountebank');2var port = 2525;3var imposterPort = 3000;4var imposter = {5 {6 {7 equals: {8 }9 }10 {11 is: {12 headers: {13 },14 }15 }16 }17};18mb.create(port, imposter, function (error, imposter) {19 if (error) {20 console.error('error creating imposter', error);21 process.exit(1);22 }23});

Full Screen

Using AI Code Generation

copy

Full Screen

1var request = require('request');2var assert = require('assert');3var mb = require('mountebank');4var port = 2525;5var host = 'localhost';6var imposterPort = 3000;7var mbProcess;8mb.create({port: port, pidfile: 'mb.pid', logfile: 'mb.log', ipWhitelist: '*'}, function (error, process) {9 if (error) {10 console.error('Could not start mountebank', error);11 process.exit(1);12 }13 mbProcess = process;14 process.createImposter({port: imposterPort, protocol: 'http', stubs: [15 {16 {17 is: {18 }19 }20 }21 ]}, function (error, imposter) {22 if (error) {23 console.error('Could not create imposter', error);24 process.exit(1);25 }26 console.log('Imposter created at %s', imposterURL);27 request.get(imposterURL, function (error, response, body) {28 if (error) {29 console.error('Error making request', error);30 process.exit(1);31 }32 console.log('Got response %s', response.statusCode);33 assert.strictEqual(response.statusCode, 200);34 assert.strictEqual(body, 'Hello, World!');35 console.log('Success!');36 process.exit(0);37 });38 });39});40var request = require('request');41var assert = require('assert');42var mb = require('mountebank');43var port = 2525;44var host = 'localhost';45var imposterPort = 3000;46var mbProcess;47mb.create({port: port, pidfile: 'mb.pid', logfile: 'mb.log', ipWhitelist: '*'}, function (error, process) {48 if (error) {49 console.error('Could not start mountebank', error);50 process.exit(1);

Full Screen

Using AI Code Generation

copy

Full Screen

1var mb = require('mountebank').create();2mb.start({port: 2525}, function () {3 mb.post('/imposters', {4 {5 {6 is: {7 }8 }9 }10 }, function (error, response) {11 console.log('POST /imposters response: ' + JSON.stringify(response.body));12 });13});14POST /imposters response: {"protocol":"http","port":3000,"numberOfRequests":0,"stubs":[{"responses":[{"is":{"statusCode":200,"body":"Hello from mountebank!"}}]}]}15[{"protocol":"http","port":3000,"numberOfRequests":1,"stubs":[{"responses":[{"is":{"statusCode":200,"body":"Hello from mountebank!"}}]}],"_links":{"self":{"href":"/imposters/3000"}},"requests":[{"protocol":"http","method":"GET","path":"/","query":{},"headers":{"host":"localhost:3000","user-agent":"curl/7.43

Full Screen

Using AI Code Generation

copy

Full Screen

1var mb = require('mountebank');2var Q = require('q');3var request = require('request');4var assert = require('assert');5var port = 2525;6 {7 {8 {9 is: {10 }11 }12 }13 }14];15mb.start({port: port, allowInjection: true})16 .then(function (mb) {17 return mb.post('/imposters', {imposters: imposters});18 })19 .then(function (response) {20 var deferred = Q.defer();21 assert.equal(body, 'Hello World');22 deferred.resolve();23 });24 return deferred.promise;25 })26 .then(function () {27 return mb.stop();28 })29 .done();30var mb = require('mountebank');31var Q = require('q');32var request = require('request');33var assert = require('assert');34var port = 2525;35 {36 {37 {38 is: {39 }40 }41 }42 }43];44mb.start({port: port, allowInjection: true})45 .then(function (mb) {46 return mb.post('/imposters', {imposters: imposters});47 })48 .then(function (response) {49 var deferred = Q.defer();50 assert.equal(body, 'Hello World');51 deferred.resolve();52 });

Full Screen

Using AI Code Generation

copy

Full Screen

1var request = require('request');2var assert = require('assert');3var imposter = 2525;4var mbUrlWithImposter = mbUrl + '/imposters';5var mbUrlWithImposterPort = mbUrlWithImposter + '/' + imposter;6var mbUrlWithImposterPortRequests = mbUrlWithImposterPort + '/requests';7var postImposter = {8 'stubs': [{9 'responses': [{10 'is': {11 }12 }]13 }]14};15request.post({16}, function (error, response, body) {17 assert.equal(response.statusCode, 201);18 request.get({19 }, function (error, response, body) {20 assert.equal(body, 'Hello World!');21 request.get({22 }, function (error, response, body) {23 var requests = JSON.parse(body).imposters[0].requests;24 assert.equal(requests.length, 1);25 assert.equal(requests[0].path, '/test');26 request.del({27 }, function (error, response, body) {28 assert.equal(response.statusCode, 200);29 });30 });31 });32});33var request = require('request');34var assert = require('assert');35var imposter = 2525;36var mbUrlWithImposter = mbUrl + '/imposters';37var mbUrlWithImposterPort = mbUrlWithImposter + '/' + imposter;38var mbUrlWithImposterPortRequests = mbUrlWithImposterPort + '/requests';39var postImposter = {40 'stubs': [{41 'responses': [{42 'is': {43 }44 }]45 }]46};47request.post({

Full Screen

Using AI Code Generation

copy

Full Screen

1var http = require('http');2var request = require('request');3var mb = require('mountebank');4var mbPort = 2525;5var mbHost = 'localhost';6var imposterPort = 3000;7var imposterPath = '/test';8var imposterProtocol = 'http';9var imposter = {10 {11 {12 is: {13 headers: {14 },15 }16 }17 }18};19mb.create({port: mbPort}, function (error, mbServer) {20 if (error) {21 console.error('Failed to start mountebank', error);22 process.exit(1);23 }24 mbServer.createImposter(imposter, function (error, imposter) {25 if (error) {26 console.error('Failed to create imposter', error);27 process.exit(1);28 }29 request.get(imposterUrl + imposterPath, function (error, response, body) {30 if (error) {31 console.error('Failed to make request', error);32 process.exit(1);33 }34 console.log(response.statusCode);35 console.log(body);36 mbServer.close();37 });38 });39});40var http = require('http');41var request = require('request');42var mb = require('mountebank');43var mbPort = 2525;44var mbHost = 'localhost';45var imposterPort = 3000;46var imposterPath = '/test';47var imposterProtocol = 'http';48var imposter = {49 {50 {

Full Screen

Using AI Code Generation

copy

Full Screen

1var mb = require('mountebank');2var host = 'localhost';3var port = 2525;4var protocol = 'http';5mb.create({ port: port, pidfile: 'mb.pid' }, function(error) {6 if (error) {7 console.log('Error creating server', error);8 }9 else {10 console.log('Server created');11 }12});13mb.post('/imposters', {14 stubs: [{15 responses: [{16 is: {17 }18 }]19 }]20}, function(error, response) {21 if (error) {22 console.log('Error creating stub', error);23 }24 else {25 console.log('Stub created');26 }27});28mb.get('/imposters', function(error, response) {29 if (error) {30 console.log('Error retrieving imposters', error);31 }32 else {33 console.log('Imposters retrieved');34 console.log(response.body);35 }36});37mb.get('/imposters/3000', function(error, response) {38 if (error) {39 console.log('Error retrieving imposters', error);40 }41 else {42 console.log('Imposters retrieved');43 console.log(response.body);44 }45});46mb.get('/imposters/3000/requests', function(error, response) {47 if (error) {48 console.log('Error retrieving requests', error);49 }50 else {51 console.log('Requests retrieved');52 console.log(response.body);53 }54});55mb.del('/imposters', function(error, response) {56 if (error) {57 console.log('Error deleting imposters', error);58 }59 else {60 console.log('Imposters deleted');61 }62});63mb.del('/imposters/3000', function(error, response) {64 if (error) {65 console.log('Error deleting imposters', error);66 }67 else {68 console.log('Imposters deleted');69 }70});71mb.del('/imposters/3000/requests', function(error, response) {72 if (error) {73 console.log('Error deleting requests', error);74 }75 else {76 console.log('Requests deleted');

Full Screen

Using AI Code Generation

copy

Full Screen

1var request = require('request');2var fs = require('fs');3var path = require('path');4var config = require('./config');5var uuid = require('node-uuid');6var assert = require('assert');7var imposter = {8 stubs: [{9 predicates: [{10 equals: {11 }12 }],13 responses: [{14 is: {15 headers: {16 },17 }18 }]19 }]20};21var imposter2 = {22 stubs: [{23 predicates: [{24 equals: {25 }26 }],27 responses: [{28 is: {29 headers: {30 },31 }32 }]33 }]34};35var imposter3 = {36 stubs: [{37 predicates: [{38 equals: {39 }40 }],41 responses: [{42 is: {43 headers: {44 },45 }46 }]47 }]48};49var imposter4 = {50 stubs: [{51 predicates: [{52 equals: {53 }54 }],55 responses: [{56 is: {57 headers: {58 },59 }60 }]61 }]62};63var imposter5 = {64 stubs: [{65 predicates: [{66 equals: {67 }68 }],69 responses: [{70 is: {

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run mountebank automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful