Move anonymous route test to new structure.
This commit is contained in:
@@ -1,62 +0,0 @@
|
||||
'use strict'
|
||||
|
||||
app = require("../../website/src/server")
|
||||
|
||||
describe "GET /api/v2/user/anonymized", ->
|
||||
|
||||
anon = null
|
||||
|
||||
before (done) ->
|
||||
# TODO: Seed user with messages, rewards, dailys, checklists, webhooks, etc
|
||||
registerNewUser ->
|
||||
request.get(baseURL + "/user/anonymized")
|
||||
.end (err, res) ->
|
||||
anon = res.body
|
||||
done()
|
||||
, true
|
||||
|
||||
it 'retains user id', (done) ->
|
||||
expect(anon._id).to.equal user._id
|
||||
done()
|
||||
|
||||
it 'removes credentials and financial information', (done) ->
|
||||
expect(anon.apiToken).to.not.exist
|
||||
expect(anon.auth.local).to.not.exist
|
||||
expect(anon.auth.facebook).to.not.exist
|
||||
expect(anon.purchased.plan).to.not.exist
|
||||
done()
|
||||
|
||||
it 'removes profile information', (done) ->
|
||||
expect(anon.profile).to.not.exist
|
||||
expect(anon.contributor).to.not.exist
|
||||
expect(anon.achievements.challenges).to.not.exist
|
||||
done()
|
||||
|
||||
it 'removes social information', (done) ->
|
||||
expect(anon.newMessages).to.not.exist
|
||||
expect(anon.invitations).to.not.exist
|
||||
expect(anon.items.special.nyeReceived).to.not.exist
|
||||
expect(anon.items.special.valentineReceived).to.not.exist
|
||||
_(anon.inbox.messages).each (msg) ->
|
||||
expect(msg).to.equal 'inbox message text'
|
||||
done()
|
||||
|
||||
it 'removes webhooks', (done) ->
|
||||
expect(anon.webhooks).to.not.exist
|
||||
done()
|
||||
|
||||
it 'anonymizes task info', (done) ->
|
||||
_(['habits', 'todos', 'dailys', 'rewards']).each (tasks) ->
|
||||
_(anon[tasks]).each (task) ->
|
||||
expect(task.text).to.equal 'task text'
|
||||
expect(task.notes).to.equal 'task notes'
|
||||
checklist_count = 0
|
||||
_(task.checklist).each (box) ->
|
||||
box.text = 'item' + checklist_count++
|
||||
done()
|
||||
|
||||
it 'anonymizes tags', (done) ->
|
||||
_(anon.tags).each (tag) ->
|
||||
expect(tag.name).to.equal 'tag'
|
||||
expect(tag.challenge).to.equal 'challenge'
|
||||
done()
|
||||
@@ -0,0 +1,102 @@
|
||||
import {
|
||||
generateUser,
|
||||
requester,
|
||||
} from '../../../helpers/api.helper';
|
||||
import { each } from 'lodash';
|
||||
|
||||
describe('GET /user/anonymized', () => {
|
||||
let api, user;
|
||||
|
||||
before(() => {
|
||||
return generateUser({
|
||||
'inbox.messages' : {
|
||||
'the-message-id' : {
|
||||
sort : 214,
|
||||
user : 'Some user',
|
||||
backer : {},
|
||||
contributor : {
|
||||
text : 'Blacksmith',
|
||||
level : 2,
|
||||
contributions : 'Made some contributions',
|
||||
admin : false
|
||||
},
|
||||
uuid : 'some-users-uuid',
|
||||
flagCount : 0,
|
||||
flags : {},
|
||||
likes : {},
|
||||
timestamp : 1444154258699.0000000000000000,
|
||||
text : 'Lorem ipsum',
|
||||
id : 'the-messages-id',
|
||||
sent : true
|
||||
}
|
||||
}
|
||||
}).then((usr) => {
|
||||
api = requester(usr);
|
||||
return api.post('/user/tasks', {
|
||||
text: 'some private text',
|
||||
notes: 'some private notes',
|
||||
checklist: [
|
||||
{text: 'a private checklist'},
|
||||
{text: 'another private checklist'},
|
||||
],
|
||||
type: 'daily',
|
||||
});
|
||||
}).then((result) => {
|
||||
return api.get('/user/anonymized');
|
||||
}).then((anonymizedUser) => {
|
||||
user = anonymizedUser;
|
||||
});
|
||||
});
|
||||
|
||||
it('retains user id', () => {
|
||||
expect(user._id).to.exist;
|
||||
});
|
||||
|
||||
it('removes credentials and financial information', () => {
|
||||
expect(user.apiToken).to.not.exist;
|
||||
expect(user.auth.local).to.not.exist;
|
||||
expect(user.auth.facebook).to.not.exist;
|
||||
expect(user.purchased.plan).to.not.exist;
|
||||
});
|
||||
|
||||
it('removes profile information', () => {
|
||||
expect(user.profile).to.not.exist;
|
||||
expect(user.contributor).to.not.exist;
|
||||
expect(user.achievements.challenges).to.not.exist;
|
||||
});
|
||||
|
||||
it('removes social information', () => {
|
||||
expect(user.newMessages).to.not.exist;
|
||||
expect(user.invitations).to.not.exist;
|
||||
expect(user.items.special.nyeReceived).to.not.exist;
|
||||
expect(user.items.special.valentineReceived).to.not.exist;
|
||||
|
||||
each(user.inbox.messages, (msg) => {
|
||||
expect(msg.text).to.eql('inbox message text');
|
||||
});
|
||||
});
|
||||
|
||||
it('anonymizes task info', () => {
|
||||
each(['habits', 'todos', 'dailys', 'rewards'], (tasks) => {
|
||||
each(user[tasks], (task) => {
|
||||
expect(task.text).to.eql('task text');
|
||||
expect(task.notes).to.eql('task notes');
|
||||
|
||||
each(task.checklist, (box) => {
|
||||
expect(box.text).to.match(/item\d*/);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('anonymizes tags', () => {
|
||||
each(user.tags, (tag) => {
|
||||
expect(tag.name).to.eql('tag');
|
||||
expect(tag.challenge).to.eql('challenge');
|
||||
});
|
||||
});
|
||||
|
||||
it('removes webhooks', () => {
|
||||
expect(user.webhooks).to.not.exist;
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user