Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
persona
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hexang 息壤平台
persona
Commits
be238b68
Commit
be238b68
authored
13 years ago
by
Lloyd Hilaiel
Browse files
Options
Downloads
Patches
Plain Diff
test adding emails to accounts
parent
256b8263
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
browserid/lib/db.js
+5
-1
5 additions, 1 deletion
browserid/lib/db.js
browserid/tests/db-test.js
+56
-13
56 additions, 13 deletions
browserid/tests/db-test.js
browserid/tests/lib/wsapi.js
+3
-2
3 additions, 2 deletions
browserid/tests/lib/wsapi.js
with
64 additions
and
16 deletions
browserid/lib/db.js
+
5
−
1
View file @
be238b68
...
...
@@ -46,6 +46,8 @@ exports.onReady = function(f) {
},
0
);
};
// XXX: g_staged and g_stagedEmails should be moved into persistent/fast storage.
// half created user accounts (pending email verification)
// OR
// half added emails (pending verification)
...
...
@@ -101,6 +103,7 @@ exports.emailKnown = function(email, cb) {
});
};
// XXX: should be moved to async.
exports
.
isStaged
=
function
(
email
)
{
return
g_stagedEmails
.
hasOwnProperty
(
email
);
};
...
...
@@ -187,6 +190,7 @@ exports.stageUser = function(obj) {
};
/* takes an argument object including email, pass, and pubkey. */
// XXX: change to async
exports
.
stageEmail
=
function
(
existing_email
,
new_email
,
pubkey
)
{
var
secret
=
generateSecret
();
// overwrite previously staged users
...
...
@@ -264,7 +268,7 @@ exports.checkAuth = function(email, cb) {
db
.
execute
(
"
SELECT users.password FROM emails, users WHERE users.id = emails.user AND emails.address = ?
"
,
[
email
],
function
(
error
,
rows
)
{
cb
(
rows
.
length
!==
1
?
undefined
:
rows
[
0
].
password
);
cb
(
rows
.
length
!==
1
?
undefined
:
rows
[
0
].
password
);
});
};
...
...
This diff is collapsed.
Click to expand it.
browserid/tests/db-test.js
+
56
−
13
View file @
be238b68
#!/usr/bin/env node
const
assert
=
require
(
'
assert
'
),
vows
=
require
(
'
vows
'
),
db
=
require
(
'
../lib/db.js
'
),
temp
=
require
(
'
temp
'
),
fs
=
require
(
'
fs
'
),
path
=
require
(
'
path
'
);
const
assert
=
require
(
'
assert
'
),
vows
=
require
(
'
vows
'
),
db
=
require
(
'
../lib/db.js
'
),
temp
=
require
(
'
temp
'
),
fs
=
require
(
'
fs
'
),
path
=
require
(
'
path
'
);
var
suite
=
vows
.
describe
(
'
db
'
);
// disable vows (often flakey?) async error behavior
suite
.
options
.
error
=
false
;
db
.
dbPath
=
temp
.
path
({
suffix
:
'
.sqlite
'
});
...
...
@@ -51,7 +54,7 @@ suite.addBatch({
return
secret
=
db
.
stageUser
({
email
:
'
lloyd@nowhe.re
'
,
pubkey
:
'
fakepublickey
'
,
p
as
s
:
'
fakepasswordhash
'
h
as
h
:
'
fakepasswordhash
'
});
},
"
staging returns a valid secret
"
:
function
(
r
)
{
...
...
@@ -137,18 +140,58 @@ suite.addBatch({
topic
:
function
()
{
db
.
pubkeysForEmail
(
'
lloyd@nowhe.re
'
,
this
.
callback
);
},
"
returns all public keys properly
"
:
function
(
r
,
e
)
{
"
returns all public keys properly
"
:
function
(
r
)
{
assert
.
isArray
(
r
);
assert
.
strictEqual
(
r
.
length
,
3
);
}
}
});
suite
.
addBatch
({
"
checkAuth returns
"
:
{
topic
:
function
()
{
db
.
checkAuth
(
'
lloyd@nowhe.re
'
,
this
.
callback
);
},
"
the correct password
"
:
function
(
r
)
{
assert
.
strictEqual
(
r
,
"
fakepasswordhash
"
);
}
}
});
suite
.
addBatch
({
"
staging an email
"
:
{
topic
:
function
()
{
return
db
.
stageEmail
(
'
lloyd@nowhe.re
'
,
'
lloyd@somewhe.re
'
,
'
fakepubkey4
'
);
},
"
yields a valid secret
"
:
function
(
secret
)
{
assert
.
isString
(
secret
);
assert
.
strictEqual
(
secret
.
length
,
48
);
},
"
makes email addr via isStaged
"
:
{
topic
:
function
()
{
return
db
.
isStaged
(
'
lloyd@somewhe.re
'
);
},
"
visible
"
:
function
(
r
)
{
assert
.
isTrue
(
r
);
}
},
"
and verifying it
"
:
{
topic
:
function
(
secret
)
{
db
.
gotVerificationSecret
(
secret
,
this
.
callback
);
},
"
returns no error
"
:
function
(
r
)
{
assert
.
isUndefined
(
r
);
},
"
makes email addr via knownEmail
"
:
{
topic
:
function
()
{
db
.
emailKnown
(
'
lloyd@somewhe.re
'
,
this
.
callback
);
},
"
visible
"
:
function
(
r
)
{
assert
.
isTrue
(
r
);
}
},
"
makes email addr via isStaged
"
:
{
topic
:
function
()
{
return
db
.
isStaged
(
'
lloyd@somewhe.re
'
);
},
"
not visible
"
:
function
(
r
)
{
assert
.
isFalse
(
r
);
}
}
}
}
});
// XXX: remaining APIs to test
// exports.addEmailToAccount
// exports.cancelAccount
// exports.checkAuth
// exports.checkAuthHash
// exports.emailsBelongToSameAccount
// exports.getSyncResponse
// exports.removeEmail
...
...
@@ -160,8 +203,8 @@ suite.addBatch({
fs
.
unlink
(
db
.
dbPath
,
this
.
callback
);
},
"
and unlink should not error
"
:
function
(
err
)
{
assert
.
strictEqual
(
err
,
undefined
);
},
assert
.
isNull
(
err
);
},
"
and the file
"
:
{
topic
:
function
()
{
path
.
exists
(
db
.
dbPath
,
this
.
callback
);
...
...
This diff is collapsed.
Click to expand it.
browserid/tests/lib/wsapi.js
+
3
−
2
View file @
be238b68
const
http
=
require
(
'
http
'
),
querystring
=
require
(
'
querystring
'
);
const
http
=
require
(
'
http
'
),
querystring
=
require
(
'
querystring
'
);
// wsapi abstractions trivial cookie jar
var
cookieJar
=
{};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment