mirror of
https://github.com/Permissionless-Software-Foundation/ipfs-bch-wallet-service.git
synced 2026-09-21 16:52:03 -07:00
Cleaned up console logs in tests
This commit is contained in:
+7
-11
@@ -53,17 +53,13 @@ async function createSystemUser () {
|
||||
|
||||
// Change the user type to admin
|
||||
user.type = 'admin'
|
||||
console.log(`user: ${JSON.stringify(user, null, 2)}`)
|
||||
// console.log(`user: ${JSON.stringify(user, null, 2)}`)
|
||||
|
||||
// Save the user model.
|
||||
try {
|
||||
await user.save()
|
||||
} catch (err) {
|
||||
console.error(`Error trying to save admin user: `, err)
|
||||
}
|
||||
await user.save()
|
||||
|
||||
console.log(`admin user created: ${JSON.stringify(result.body, null, 2)}`)
|
||||
console.log(`with password: ${context.password}`)
|
||||
// console.log(`admin user created: ${JSON.stringify(result.body, null, 2)}`)
|
||||
// console.log(`with password: ${context.password}`)
|
||||
|
||||
// Write out the system user information to a JSON file that external
|
||||
// applications like the Task Manager and the test scripts can access.
|
||||
@@ -126,7 +122,7 @@ async function loginAdmin () {
|
||||
try {
|
||||
// Read the exising file
|
||||
existingUser = await jsonFiles.readJSON(JSON_PATH)
|
||||
console.log(`existingUser: ${JSON.stringify(existingUser, null, 2)}`)
|
||||
// console.log(`existingUser: ${JSON.stringify(existingUser, null, 2)}`)
|
||||
|
||||
// Log in as the user.
|
||||
let options = {
|
||||
@@ -144,9 +140,9 @@ async function loginAdmin () {
|
||||
|
||||
return result
|
||||
} catch (err) {
|
||||
console.error(`Error in admin.js/loginAdmin().`, err)
|
||||
console.error(`Error in admin.js/loginAdmin().`)
|
||||
|
||||
console.error(`existingUser: ${JSON.stringify(existingUser, null, 2)}`)
|
||||
// console.error(`existingUser: ${JSON.stringify(existingUser, null, 2)}`)
|
||||
|
||||
throw err
|
||||
}
|
||||
|
||||
@@ -102,16 +102,17 @@ async function ensureTargetUserOrAdmin (ctx, next) {
|
||||
// console.log(`ctx.state.user: ${JSON.stringify(ctx.state.user, null, 2)}`)
|
||||
// Ensure the calling user and the target user are the same.
|
||||
if (ctx.state.user._id.toString() !== targetId.toString()) {
|
||||
console.log(`Calling user and target user do not match!`)
|
||||
console.log(`Calling user: ${ctx.state.user._id}`)
|
||||
console.log(`Target user: ${targetId}`)
|
||||
// console.log(`Calling user and target user do not match!`)
|
||||
// console.log(`Calling user: ${ctx.state.user._id}`)
|
||||
// console.log(`Target user: ${targetId}`)
|
||||
|
||||
// If they don't match, then the calling user better be an admin.
|
||||
if (ctx.state.user.type !== 'admin') {
|
||||
ctx.throw(401, 'not admin')
|
||||
} else {
|
||||
console.log(`It's ok. The user is an admin.`)
|
||||
}
|
||||
// else {
|
||||
// console.log(`It's ok. The user is an admin.`)
|
||||
// }
|
||||
}
|
||||
|
||||
return next()
|
||||
|
||||
@@ -13,7 +13,7 @@ const context = {}
|
||||
|
||||
describe('Users', () => {
|
||||
before(async () => {
|
||||
console.log(`config: ${JSON.stringify(config, null, 2)}`)
|
||||
// console.log(`config: ${JSON.stringify(config, null, 2)}`)
|
||||
|
||||
// Create a second test user.
|
||||
const userObj = {
|
||||
@@ -21,7 +21,7 @@ describe('Users', () => {
|
||||
password: 'pass2'
|
||||
}
|
||||
const testUser = await testUtils.createUser(userObj)
|
||||
console.log(`testUser2: ${JSON.stringify(testUser, null, 2)}`)
|
||||
// console.log(`testUser2: ${JSON.stringify(testUser, null, 2)}`)
|
||||
|
||||
context.user2 = testUser.user
|
||||
context.token2 = testUser.token
|
||||
@@ -29,7 +29,7 @@ describe('Users', () => {
|
||||
|
||||
// Get the JWT used to log in as the admin 'system' user.
|
||||
const adminJWT = await testUtils.getAdminJWT()
|
||||
console.log(`adminJWT: ${adminJWT}`)
|
||||
// console.log(`adminJWT: ${adminJWT}`)
|
||||
context.adminJWT = adminJWT
|
||||
|
||||
// const admin = await testUtils.loginAdminUser()
|
||||
@@ -535,7 +535,7 @@ describe('Users', () => {
|
||||
}
|
||||
|
||||
const result = await rp(options)
|
||||
console.log(`result: ${util.inspect(result.body)}`)
|
||||
// console.log(`result: ${util.inspect(result.body)}`)
|
||||
|
||||
assert.equal(result.body.success, true)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user