Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ Format based on [Keep a Changelog](http://keepachangelog.com/)
### Security
### Migrations

## [2.2.1]
### Fixes
- Ensures order on personaIdentifier IFIs

## [2.2.0]
### Added
- Override system email address ([#1029](https://github.com/LearningLocker/learninglocker/pull/1029)) (thanks to [@eashman](https://github.com/eashman))
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.2.0
2.2.1
36 changes: 36 additions & 0 deletions api/src/routes/tests/personaController/postIdentifier-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ describe('personaController postIdentifier', () => {

beforeEach(async () => {
await personaService.clearService();
await personaService.migrate();
token = await createOrgToken();
});

Expand Down Expand Up @@ -47,4 +48,39 @@ describe('personaController postIdentifier', () => {
expect(result.body.ifi.key).to.equal('account');
expect(result.body.persona).to.equal(persona.id);
});

it('should not be able to duplicate an identifier', async () => {
const { persona } = await personaService.createPersona({
organisation: testId,
name: 'Dave'
});

const ifi = {
key: 'account',
value: {
homePage: 'http://example.org',
name: 'test'
}
};

await personaService.createIdentifier({
organisation: testId,
persona: persona.id,
ifi
});

await apiApp.post(routes.PERSONA_IDENTIFIER)
.set('Authorization', `Bearer ${token}`)
.send({
ifi: {
key: ifi.key,
value: {
name: ifi.value.name,
homePage: ifi.value.homePage,
}
},
persona: persona.id
})
.expect(400);
});
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import highland from 'highland';
import logger from 'lib/logger';
import isPlainObject from 'lodash/isPlainObject';
import has from 'lodash/has';
import { getConnection } from 'lib/connections/mongoose';
import { MongoError, ObjectID } from 'mongodb';

Expand All @@ -24,7 +26,11 @@ const processStream = stream =>

const createNewIdent = (doc) => {
const { key, value } = doc.uniqueIdentifier;

const newKey = /^statement\.actor\./.test(key) ? key.replace('statement.actor.', '') : key;
const newValue = (isPlainObject(value) && has(value, 'homePage') && has(value, 'name'))
? { homePage: value.homePage, name: value.name }
: value;

return {
_id: doc._id,
Expand All @@ -34,7 +40,7 @@ const createNewIdent = (doc) => {
persona: doc.persona,
ifi: {
key: newKey,
value,
value: newValue,
}
};
};
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "learning_locker",
"description": "An open source learning record store",
"license": "GPL-3.0",
"version": "2.2.0",
"version": "2.2.1",
"repository": {
"type": "git",
"url": "https://github.com/LearningLocker/learninglocker"
Expand Down Expand Up @@ -50,7 +50,7 @@
"dependencies": {
"@google-cloud/pubsub": "^0.16.1",
"@google-cloud/storage": "^1.5.2",
"@learninglocker/persona-service": "^1.6.8",
"@learninglocker/persona-service": "^1.6.9",
"@learninglocker/xapi-statements": "^5.0.9",
"@learninglocker/xapi-validation": "^2.1.5",
"@newrelic/native-metrics": "^2.1.0",
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@
string-format-obj "^1.0.0"
through2 "^2.0.0"

"@learninglocker/persona-service@^1.6.8":
version "1.6.8"
resolved "https://registry.yarnpkg.com/@learninglocker/persona-service/-/persona-service-1.6.8.tgz#a95811a14698387cb288080870dbdbb8ddd902de"
"@learninglocker/persona-service@^1.6.9":
version "1.6.9"
resolved "https://registry.yarnpkg.com/@learninglocker/persona-service/-/persona-service-1.6.9.tgz#60518ca809e6ae3179b56ac90706aa2f6794e28b"
dependencies:
aws-sdk "^2.0.1"
bluebird "^3.5.0"
Expand Down