Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F9582298
field-type.hashed-text.test.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
field-type.hashed-text.test.js
View Options
var
Sealious
=
require
(
"sealious"
);
var
crypto
=
require
(
'crypto'
);
module
.
exports
=
{
test_start
:
function
()
{
var
field_type_hashed_text
=
Sealious
.
ChipManager
.
get_chip
(
"field_type"
,
"hashed-text"
);
describe
(
"FieldType.HashedText"
,
function
()
{
it
(
"should return the description of the field type"
,
function
(
done
)
{
if
(
typeof
field_type_hashed_text
.
declaration
.
get_description
()
===
"string"
)
done
();
else
done
(
new
Error
(
"But it didn't"
));
});
it
(
"accepts given password ('pas1sw24rd1')"
,
function
(
done
)
{
field_type_hashed_text
.
is_proper_value
(
new
Sealious
.
Context
(),
{},
"pas1sw24rd1"
)
.
then
(
function
()
{
done
();
})
.
catch
(
function
(
error
)
{
done
(
new
Error
(
error
));
})
});
it
(
"accepts given password ('pas1sw24rd1')"
,
function
(
done
)
{
field_type_hashed_text
.
is_proper_value
(
new
Sealious
.
Context
(),
{
digits
:
3
},
"pas1sw24rd1"
)
.
then
(
function
()
{
done
();
})
.
catch
(
function
(
error
)
{
done
(
new
Error
(
error
));
})
});
it
(
"accepts given password ('PAs1sW24rD1')"
,
function
(
done
)
{
field_type_hashed_text
.
is_proper_value
(
new
Sealious
.
Context
(),
{
capitals
:
3
},
"PAs1sW24rD1"
)
.
then
(
function
()
{
done
();
})
.
catch
(
function
(
error
)
{
done
(
new
Error
(
error
));
})
});
it
(
"accepts given password ('PaSw0rd23')"
,
function
(
done
)
{
field_type_hashed_text
.
is_proper_value
(
new
Sealious
.
Context
(),
{
capitals
:
2
,
digits
:
3
},
"PaSw0rd23"
)
.
then
(
function
()
{
done
();
})
.
catch
(
function
(
error
)
{
done
(
new
Error
(
error
));
})
});
it
(
"resolved with a hash (algorithm: 'md5', salt: '')"
,
function
(
done
)
{
field_type_hashed_text
.
encode
(
new
Sealious
.
Context
(),
{},
"test"
)
.
then
(
function
(
result
){
crypto
.
pbkdf2
(
"test"
,
""
,
4096
,
64
,
"md5"
,
function
(
err
,
key
){
if
(
err
)
done
(
new
Error
(
err
));
key
.
toString
(
'hex'
)
===
result
?
done
()
:
done
(
new
Error
(
"Wrong hash"
))
});
})
.
catch
(
function
(
error
){
done
(
new
Error
(
error
))
})
})
})
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Oct 11, 06:31 (4 h, 12 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
983884
Default Alt Text
field-type.hashed-text.test.js (1 KB)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline
Log In to Comment