Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

new test for GH-1631; non-ascii in password #1653

Closed
wants to merge 2 commits into from

2 participants

@jrgm
Collaborator

@lloyd Here you go. The test obviously will fail without the pull request in GH-1649.

tests/simple-stage-user-utf8-password.js
((35 lines not shown))
+ },
+ {
+ email: 'testuser2@' + TEST_DOMAIN,
+ password: 'поддельный пароль', // Russian 'fake password' (34 bytes UTF-8)
+ }];
+
+function makeBatch(site, user) {
+ var batch = {
+ "staging an account": {
+ topic: wsapi.post('/wsapi/stage_user', {
+ site: site,
+ email: user.email,
+ pass: user.password,
+ }),
+ "is 200 OK": function(err, r) {
+ if (err) console.log(err);
@jrgm Collaborator
jrgm added a note

Oops, that was a debug statement I left in unintentionally. I can update the pull request tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@lloyd

r+. I pulled these changes into the issue1631 branch and merged them together. closing this PR down.

@lloyd lloyd closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 29, 2012
  1. @jrgm
  2. @jrgm

    remove debug statement

    jrgm authored
This page is out of date. Refresh to see the latest.
Showing with 82 additions and 0 deletions.
  1. +82 −0 tests/simple-stage-user-utf8-password.js
View
82 tests/simple-stage-user-utf8-password.js
@@ -0,0 +1,82 @@
+#!/usr/bin/env node
+
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+require('./lib/test_env.js');
+
+const
+assert = require('assert'),
+vows = require('vows'),
+start_stop = require('./lib/start-stop.js'),
+wsapi = require('./lib/wsapi.js');
+
+var suite = vows.describe('simple-stage-user-utf8-password');
+
+// disable vows (often flakey?) async error behavior
+suite.options.error = false;
+
+start_stop.addStartupBatches(suite);
+
+const
+TEST_DOMAIN = 'example.domain',
+TEST_ORIGIN = 'http://127.0.0.1:10002',
+TEST_SITE = 'http://example.com:652';
+
+// This test simply stages a secondary user. It does so for two users,
+// one with a password that is only ascii, and the other with non-ascii
+// characters in the password (GH-1631).
+
+const test_users =
+ [{
+ email: 'testuser1@' + TEST_DOMAIN,
+ password: 'fakepass',
+ },
+ {
+ email: 'testuser2@' + TEST_DOMAIN,
+ password: 'поддельный пароль', // Russian 'fake password' (34 bytes UTF-8)
+ }];
+
+function makeBatch(site, user) {
+ var batch = {
+ "staging an account": {
+ topic: wsapi.post('/wsapi/stage_user', {
+ site: site,
+ email: user.email,
+ pass: user.password,
+ }),
+ "is 200 OK": function(err, r) {
+ assert.strictEqual(r.code, 200);
+ },
+ "and a token": {
+ topic: function() {
+ start_stop.waitForToken(this.callback);
+ },
+ "is obtained": function (t) {
+ assert.strictEqual(typeof t, 'string');
+ },
+ "and the token can be used": {
+ topic: function(token) {
+ wsapi.post('/wsapi/complete_user_creation', { token: token }).call(this);
+ },
+ "to verify email ownership": function(err, r) {
+ assert.equal(r.code, 200);
+ assert.strictEqual(JSON.parse(r.body).success, true);
+ token = undefined;
+ }
+ }
+ }
+ }
+ };
+ return batch;
+}
+
+suite.addBatch(makeBatch(TEST_SITE, test_users[0]));
+suite.addBatch(makeBatch(TEST_SITE, test_users[1]));
+
+start_stop.addShutdownBatches(suite);
+
+// run or export the suite.
+if (process.argv[1] === __filename) suite.run();
+else suite.export(module);
Something went wrong with that request. Please try again.