|
@@ -328,6 +328,19 @@ describe('UserGetter', function () {
|
|
|
},
|
|
},
|
|
|
]
|
|
]
|
|
|
it('should flag inReconfirmNotificationPeriod for all affiliations in period', function (done) {
|
|
it('should flag inReconfirmNotificationPeriod for all affiliations in period', function (done) {
|
|
|
|
|
+ const { maxConfirmationMonths } = institutionNonSSO
|
|
|
|
|
+ const confirmed1 = moment()
|
|
|
|
|
+ .subtract(maxConfirmationMonths + 2, 'months')
|
|
|
|
|
+ .toDate()
|
|
|
|
|
+ const lastDayToReconfirm1 = moment(confirmed1)
|
|
|
|
|
+ .add(maxConfirmationMonths, 'months')
|
|
|
|
|
+ .toDate()
|
|
|
|
|
+ const confirmed2 = moment()
|
|
|
|
|
+ .subtract(maxConfirmationMonths + 1, 'months')
|
|
|
|
|
+ .toDate()
|
|
|
|
|
+ const lastDayToReconfirm2 = moment(confirmed2)
|
|
|
|
|
+ .add(maxConfirmationMonths, 'months')
|
|
|
|
|
+ .toDate()
|
|
|
const user = {
|
|
const user = {
|
|
|
_id: '12390i',
|
|
_id: '12390i',
|
|
|
email: email1,
|
|
email: email1,
|
|
@@ -335,27 +348,20 @@ describe('UserGetter', function () {
|
|
|
{
|
|
{
|
|
|
email: email1,
|
|
email: email1,
|
|
|
reversedHostname: 'moc.noitailiffa-elpmaxe',
|
|
reversedHostname: 'moc.noitailiffa-elpmaxe',
|
|
|
- confirmedAt: moment()
|
|
|
|
|
- .subtract(
|
|
|
|
|
- institutionNonSSO.maxConfirmationMonths + 2,
|
|
|
|
|
- 'months'
|
|
|
|
|
- )
|
|
|
|
|
- .toDate(),
|
|
|
|
|
|
|
+ confirmedAt: confirmed1,
|
|
|
default: true,
|
|
default: true,
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
email: email2,
|
|
email: email2,
|
|
|
reversedHostname: 'moc.noitailiffa-elpmaxe',
|
|
reversedHostname: 'moc.noitailiffa-elpmaxe',
|
|
|
- confirmedAt: moment()
|
|
|
|
|
- .subtract(
|
|
|
|
|
- institutionNonSSO.maxConfirmationMonths + 1,
|
|
|
|
|
- 'months'
|
|
|
|
|
- )
|
|
|
|
|
- .toDate(),
|
|
|
|
|
|
|
+ confirmedAt: confirmed2,
|
|
|
},
|
|
},
|
|
|
],
|
|
],
|
|
|
}
|
|
}
|
|
|
- this.getUserAffiliations.resolves(affiliationsData)
|
|
|
|
|
|
|
+ const affiliations = [...affiliationsData]
|
|
|
|
|
+ affiliations[0].last_day_to_reconfirm = lastDayToReconfirm1
|
|
|
|
|
+ affiliations[1].last_day_to_reconfirm = lastDayToReconfirm2
|
|
|
|
|
+ this.getUserAffiliations.resolves(affiliations)
|
|
|
this.UserGetter.promises.getUser = sinon.stub().resolves(user)
|
|
this.UserGetter.promises.getUser = sinon.stub().resolves(user)
|
|
|
this.UserGetter.getUserFullEmails(
|
|
this.UserGetter.getUserFullEmails(
|
|
|
this.fakeUser._id,
|
|
this.fakeUser._id,
|
|
@@ -372,10 +378,18 @@ describe('UserGetter', function () {
|
|
|
)
|
|
)
|
|
|
})
|
|
})
|
|
|
it('should not flag affiliations outside of notification period', function (done) {
|
|
it('should not flag affiliations outside of notification period', function (done) {
|
|
|
- const aboutToBeWithinPeriod = moment()
|
|
|
|
|
- .subtract(institutionNonSSO.maxConfirmationMonths, 'months')
|
|
|
|
|
|
|
+ const { maxConfirmationMonths } = institutionNonSSO
|
|
|
|
|
+ const confirmed1 = new Date()
|
|
|
|
|
+ const lastDayToReconfirm1 = moment(confirmed1)
|
|
|
|
|
+ .add(maxConfirmationMonths, 'months')
|
|
|
|
|
+ .toDate()
|
|
|
|
|
+ const confirmed2 = moment()
|
|
|
|
|
+ .subtract(maxConfirmationMonths, 'months')
|
|
|
.add(15, 'days')
|
|
.add(15, 'days')
|
|
|
.toDate() // expires in 15 days
|
|
.toDate() // expires in 15 days
|
|
|
|
|
+ const lastDayToReconfirm2 = moment(confirmed2)
|
|
|
|
|
+ .add(maxConfirmationMonths, 'months')
|
|
|
|
|
+ .toDate()
|
|
|
const user = {
|
|
const user = {
|
|
|
_id: '12390i',
|
|
_id: '12390i',
|
|
|
email: email1,
|
|
email: email1,
|
|
@@ -383,17 +397,20 @@ describe('UserGetter', function () {
|
|
|
{
|
|
{
|
|
|
email: email1,
|
|
email: email1,
|
|
|
reversedHostname: 'moc.noitailiffa-elpmaxe',
|
|
reversedHostname: 'moc.noitailiffa-elpmaxe',
|
|
|
- confirmedAt: new Date(),
|
|
|
|
|
|
|
+ confirmedAt: confirmed1,
|
|
|
default: true,
|
|
default: true,
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
email: email2,
|
|
email: email2,
|
|
|
reversedHostname: 'moc.noitailiffa-elpmaxe',
|
|
reversedHostname: 'moc.noitailiffa-elpmaxe',
|
|
|
- confirmedAt: aboutToBeWithinPeriod,
|
|
|
|
|
|
|
+ confirmedAt: confirmed2,
|
|
|
},
|
|
},
|
|
|
],
|
|
],
|
|
|
}
|
|
}
|
|
|
- this.getUserAffiliations.resolves(affiliationsData)
|
|
|
|
|
|
|
+ const affiliations = [...affiliationsData]
|
|
|
|
|
+ affiliations[0].last_day_to_reconfirm = lastDayToReconfirm1
|
|
|
|
|
+ affiliations[1].last_day_to_reconfirm = lastDayToReconfirm2
|
|
|
|
|
+ this.getUserAffiliations.resolves(affiliations)
|
|
|
this.UserGetter.promises.getUser = sinon.stub().resolves(user)
|
|
this.UserGetter.promises.getUser = sinon.stub().resolves(user)
|
|
|
this.UserGetter.getUserFullEmails(
|
|
this.UserGetter.getUserFullEmails(
|
|
|
this.fakeUser._id,
|
|
this.fakeUser._id,
|
|
@@ -413,37 +430,14 @@ describe('UserGetter', function () {
|
|
|
|
|
|
|
|
describe('SSO institutions', function () {
|
|
describe('SSO institutions', function () {
|
|
|
it('should flag only linked email, if in notification period', function (done) {
|
|
it('should flag only linked email, if in notification period', function (done) {
|
|
|
|
|
+ const { maxConfirmationMonths } = institutionSSO
|
|
|
const email1 = 'email1@sso.bar'
|
|
const email1 = 'email1@sso.bar'
|
|
|
const email2 = 'email2@sso.bar'
|
|
const email2 = 'email2@sso.bar'
|
|
|
const email3 = 'email3@sso.bar'
|
|
const email3 = 'email3@sso.bar'
|
|
|
-
|
|
|
|
|
- const affiliationsData = [
|
|
|
|
|
- {
|
|
|
|
|
- email: email1,
|
|
|
|
|
- role: 'Prof',
|
|
|
|
|
- department: 'Maths',
|
|
|
|
|
- inferred: false,
|
|
|
|
|
- licence: 'pro_plus',
|
|
|
|
|
- institution: institutionSSO,
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- email: email2,
|
|
|
|
|
- role: 'Prof',
|
|
|
|
|
- department: 'Maths',
|
|
|
|
|
- inferred: false,
|
|
|
|
|
- licence: 'pro_plus',
|
|
|
|
|
- institution: institutionSSO,
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- email: email3,
|
|
|
|
|
- role: 'Prof',
|
|
|
|
|
- department: 'Maths',
|
|
|
|
|
- inferred: false,
|
|
|
|
|
- licence: 'pro_plus',
|
|
|
|
|
- institution: institutionSSO,
|
|
|
|
|
- },
|
|
|
|
|
- ]
|
|
|
|
|
-
|
|
|
|
|
|
|
+ const reconfirmedAt = new Date('2019-09-24')
|
|
|
|
|
+ const lastDayToReconfirm = moment(reconfirmedAt)
|
|
|
|
|
+ .add(maxConfirmationMonths, 'months')
|
|
|
|
|
+ .toDate()
|
|
|
const user = {
|
|
const user = {
|
|
|
_id: '12390i',
|
|
_id: '12390i',
|
|
|
email: email1,
|
|
email: email1,
|
|
@@ -452,21 +446,21 @@ describe('UserGetter', function () {
|
|
|
email: email1,
|
|
email: email1,
|
|
|
reversedHostname: 'rab.oss',
|
|
reversedHostname: 'rab.oss',
|
|
|
confirmedAt: new Date('2019-09-24'),
|
|
confirmedAt: new Date('2019-09-24'),
|
|
|
- reconfirmedAt: new Date('2019-09-24'),
|
|
|
|
|
|
|
+ reconfirmedAt: reconfirmedAt,
|
|
|
default: true,
|
|
default: true,
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
email: email2,
|
|
email: email2,
|
|
|
reversedHostname: 'rab.oss',
|
|
reversedHostname: 'rab.oss',
|
|
|
confirmedAt: new Date('2019-09-24'),
|
|
confirmedAt: new Date('2019-09-24'),
|
|
|
- reconfirmedAt: new Date('2019-09-24'),
|
|
|
|
|
|
|
+ reconfirmedAt: reconfirmedAt,
|
|
|
samlProviderId: institutionSSO.id,
|
|
samlProviderId: institutionSSO.id,
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
email: email3,
|
|
email: email3,
|
|
|
reversedHostname: 'rab.oss',
|
|
reversedHostname: 'rab.oss',
|
|
|
confirmedAt: new Date('2019-09-24'),
|
|
confirmedAt: new Date('2019-09-24'),
|
|
|
- reconfirmedAt: new Date('2019-09-24'),
|
|
|
|
|
|
|
+ reconfirmedAt: reconfirmedAt,
|
|
|
},
|
|
},
|
|
|
],
|
|
],
|
|
|
samlIdentifiers: [
|
|
samlIdentifiers: [
|
|
@@ -476,7 +470,36 @@ describe('UserGetter', function () {
|
|
|
},
|
|
},
|
|
|
],
|
|
],
|
|
|
}
|
|
}
|
|
|
- this.getUserAffiliations.resolves(affiliationsData)
|
|
|
|
|
|
|
+ const affiliations = [
|
|
|
|
|
+ {
|
|
|
|
|
+ email: email1,
|
|
|
|
|
+ role: 'Prof',
|
|
|
|
|
+ department: 'Maths!',
|
|
|
|
|
+ inferred: false,
|
|
|
|
|
+ licence: 'pro_plus',
|
|
|
|
|
+ institution: institutionSSO,
|
|
|
|
|
+ last_day_to_reconfirm: lastDayToReconfirm,
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ email: email2,
|
|
|
|
|
+ role: 'Prof',
|
|
|
|
|
+ department: 'Maths',
|
|
|
|
|
+ inferred: false,
|
|
|
|
|
+ licence: 'pro_plus',
|
|
|
|
|
+ institution: institutionSSO,
|
|
|
|
|
+ last_day_to_reconfirm: lastDayToReconfirm,
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ email: email3,
|
|
|
|
|
+ role: 'Prof',
|
|
|
|
|
+ department: 'Maths',
|
|
|
|
|
+ inferred: false,
|
|
|
|
|
+ licence: 'pro_plus',
|
|
|
|
|
+ institution: institutionSSO,
|
|
|
|
|
+ last_day_to_reconfirm: lastDayToReconfirm,
|
|
|
|
|
+ },
|
|
|
|
|
+ ]
|
|
|
|
|
+ this.getUserAffiliations.resolves(affiliations)
|
|
|
this.UserGetter.promises.getUser = sinon.stub().resolves(user)
|
|
this.UserGetter.promises.getUser = sinon.stub().resolves(user)
|
|
|
this.UserGetter.getUserFullEmails(
|
|
this.UserGetter.getUserFullEmails(
|
|
|
this.fakeUser._id,
|
|
this.fakeUser._id,
|
|
@@ -499,10 +522,19 @@ describe('UserGetter', function () {
|
|
|
|
|
|
|
|
describe('multiple institution affiliations', function () {
|
|
describe('multiple institution affiliations', function () {
|
|
|
it('should flag each institution', function (done) {
|
|
it('should flag each institution', function (done) {
|
|
|
|
|
+ const { maxConfirmationMonths } = institutionSSO
|
|
|
const email1 = 'email1@sso.bar'
|
|
const email1 = 'email1@sso.bar'
|
|
|
const email2 = 'email2@sso.bar'
|
|
const email2 = 'email2@sso.bar'
|
|
|
const email3 = 'email3@foo.bar'
|
|
const email3 = 'email3@foo.bar'
|
|
|
const email4 = 'email4@foo.bar'
|
|
const email4 = 'email4@foo.bar'
|
|
|
|
|
+ const confirmed1 = new Date('2019-09-24T20:25:08.503Z')
|
|
|
|
|
+ const lastDayToReconfirm1 = moment(confirmed1)
|
|
|
|
|
+ .add(maxConfirmationMonths, 'months')
|
|
|
|
|
+ .toDate()
|
|
|
|
|
+ const confirmed2 = new Date('2019-10-24T20:25:08.503Z')
|
|
|
|
|
+ const lastDayToReconfirm2 = moment(confirmed2)
|
|
|
|
|
+ .add(maxConfirmationMonths, 'months')
|
|
|
|
|
+ .toDate()
|
|
|
|
|
|
|
|
const affiliationsData = [
|
|
const affiliationsData = [
|
|
|
{
|
|
{
|
|
@@ -512,6 +544,7 @@ describe('UserGetter', function () {
|
|
|
inferred: false,
|
|
inferred: false,
|
|
|
licence: 'pro_plus',
|
|
licence: 'pro_plus',
|
|
|
institution: institutionSSO,
|
|
institution: institutionSSO,
|
|
|
|
|
+ last_day_to_reconfirm: lastDayToReconfirm1,
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
email: email2,
|
|
email: email2,
|
|
@@ -520,6 +553,7 @@ describe('UserGetter', function () {
|
|
|
inferred: false,
|
|
inferred: false,
|
|
|
licence: 'pro_plus',
|
|
licence: 'pro_plus',
|
|
|
institution: institutionSSO,
|
|
institution: institutionSSO,
|
|
|
|
|
+ last_day_to_reconfirm: lastDayToReconfirm1,
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
email: email3,
|
|
email: email3,
|
|
@@ -528,6 +562,7 @@ describe('UserGetter', function () {
|
|
|
inferred: false,
|
|
inferred: false,
|
|
|
licence: 'pro_plus',
|
|
licence: 'pro_plus',
|
|
|
institution: institutionNonSSO,
|
|
institution: institutionNonSSO,
|
|
|
|
|
+ last_day_to_reconfirm: lastDayToReconfirm2,
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
email: email4,
|
|
email: email4,
|
|
@@ -536,6 +571,7 @@ describe('UserGetter', function () {
|
|
|
inferred: false,
|
|
inferred: false,
|
|
|
licence: 'pro_plus',
|
|
licence: 'pro_plus',
|
|
|
institution: institutionNonSSO,
|
|
institution: institutionNonSSO,
|
|
|
|
|
+ last_day_to_reconfirm: lastDayToReconfirm1,
|
|
|
},
|
|
},
|
|
|
]
|
|
]
|
|
|
const user = {
|
|
const user = {
|
|
@@ -545,24 +581,24 @@ describe('UserGetter', function () {
|
|
|
{
|
|
{
|
|
|
email: email1,
|
|
email: email1,
|
|
|
reversedHostname: 'rab.oss',
|
|
reversedHostname: 'rab.oss',
|
|
|
- confirmedAt: '2019-09-24T20:25:08.503Z',
|
|
|
|
|
|
|
+ confirmedAt: confirmed1,
|
|
|
default: true,
|
|
default: true,
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
email: email2,
|
|
email: email2,
|
|
|
reversedHostname: 'rab.oss',
|
|
reversedHostname: 'rab.oss',
|
|
|
- confirmedAt: new Date('2019-09-24T20:25:08.503Z'),
|
|
|
|
|
|
|
+ confirmedAt: confirmed1,
|
|
|
samlProviderId: institutionSSO.id,
|
|
samlProviderId: institutionSSO.id,
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
email: email3,
|
|
email: email3,
|
|
|
reversedHostname: 'rab.oof',
|
|
reversedHostname: 'rab.oof',
|
|
|
- confirmedAt: new Date('2019-10-24T20:25:08.503Z'),
|
|
|
|
|
|
|
+ confirmedAt: confirmed2,
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
email: email4,
|
|
email: email4,
|
|
|
reversedHostname: 'rab.oof',
|
|
reversedHostname: 'rab.oof',
|
|
|
- confirmedAt: new Date('2019-09-24T20:25:08.503Z'),
|
|
|
|
|
|
|
+ confirmedAt: confirmed1,
|
|
|
},
|
|
},
|
|
|
],
|
|
],
|
|
|
samlIdentifiers: [
|
|
samlIdentifiers: [
|
|
@@ -572,6 +608,7 @@ describe('UserGetter', function () {
|
|
|
},
|
|
},
|
|
|
],
|
|
],
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
this.getUserAffiliations.resolves(affiliationsData)
|
|
this.getUserAffiliations.resolves(affiliationsData)
|
|
|
this.UserGetter.promises.getUser = sinon.stub().resolves(user)
|
|
this.UserGetter.promises.getUser = sinon.stub().resolves(user)
|
|
|
this.UserGetter.getUserFullEmails(
|
|
this.UserGetter.getUserFullEmails(
|
|
@@ -598,9 +635,31 @@ describe('UserGetter', function () {
|
|
|
|
|
|
|
|
describe('reconfirmedAt', function () {
|
|
describe('reconfirmedAt', function () {
|
|
|
it('only use confirmedAt when no reconfirmedAt', function (done) {
|
|
it('only use confirmedAt when no reconfirmedAt', function (done) {
|
|
|
|
|
+ const { maxConfirmationMonths } = institutionSSO
|
|
|
const email1 = 'email1@foo.bar'
|
|
const email1 = 'email1@foo.bar'
|
|
|
|
|
+ const reconfirmed1 = moment().subtract(
|
|
|
|
|
+ maxConfirmationMonths * 3,
|
|
|
|
|
+ 'months'
|
|
|
|
|
+ )
|
|
|
|
|
+ const lastDayToReconfirm1 = moment(reconfirmed1)
|
|
|
|
|
+ .add(maxConfirmationMonths, 'months')
|
|
|
|
|
+ .toDate()
|
|
|
const email2 = 'email2@foo.bar'
|
|
const email2 = 'email2@foo.bar'
|
|
|
|
|
+ const reconfirmed2 = moment().subtract(
|
|
|
|
|
+ maxConfirmationMonths * 2,
|
|
|
|
|
+ 'months'
|
|
|
|
|
+ )
|
|
|
|
|
+ const lastDayToReconfirm2 = moment(reconfirmed2)
|
|
|
|
|
+ .add(maxConfirmationMonths, 'months')
|
|
|
|
|
+ .toDate()
|
|
|
const email3 = 'email3@foo.bar'
|
|
const email3 = 'email3@foo.bar'
|
|
|
|
|
+ const reconfirmed3 = moment().subtract(
|
|
|
|
|
+ maxConfirmationMonths * 4,
|
|
|
|
|
+ 'months'
|
|
|
|
|
+ )
|
|
|
|
|
+ const lastDayToReconfirm3 = moment(reconfirmed3)
|
|
|
|
|
+ .add(maxConfirmationMonths, 'months')
|
|
|
|
|
+ .toDate()
|
|
|
|
|
|
|
|
const affiliationsData = [
|
|
const affiliationsData = [
|
|
|
{
|
|
{
|
|
@@ -610,6 +669,7 @@ describe('UserGetter', function () {
|
|
|
inferred: false,
|
|
inferred: false,
|
|
|
licence: 'pro_plus',
|
|
licence: 'pro_plus',
|
|
|
institution: institutionNonSSO,
|
|
institution: institutionNonSSO,
|
|
|
|
|
+ last_day_to_reconfirm: lastDayToReconfirm1,
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
email: email2,
|
|
email: email2,
|
|
@@ -618,6 +678,7 @@ describe('UserGetter', function () {
|
|
|
inferred: false,
|
|
inferred: false,
|
|
|
licence: 'pro_plus',
|
|
licence: 'pro_plus',
|
|
|
institution: institutionNonSSO,
|
|
institution: institutionNonSSO,
|
|
|
|
|
+ last_day_to_reconfirm: lastDayToReconfirm2,
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
email: email3,
|
|
email: email3,
|
|
@@ -626,6 +687,7 @@ describe('UserGetter', function () {
|
|
|
inferred: false,
|
|
inferred: false,
|
|
|
licence: 'pro_plus',
|
|
licence: 'pro_plus',
|
|
|
institution: institutionNonSSO,
|
|
institution: institutionNonSSO,
|
|
|
|
|
+ last_day_to_reconfirm: lastDayToReconfirm3,
|
|
|
},
|
|
},
|
|
|
]
|
|
]
|
|
|
const user = {
|
|
const user = {
|
|
@@ -639,10 +701,7 @@ describe('UserGetter', function () {
|
|
|
institutionSSO.maxConfirmationMonths * 2,
|
|
institutionSSO.maxConfirmationMonths * 2,
|
|
|
'months'
|
|
'months'
|
|
|
),
|
|
),
|
|
|
- reconfirmedAt: moment().subtract(
|
|
|
|
|
- institutionSSO.maxConfirmationMonths * 3,
|
|
|
|
|
- 'months'
|
|
|
|
|
- ),
|
|
|
|
|
|
|
+ reconfirmedAt: reconfirmed1,
|
|
|
default: true,
|
|
default: true,
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
@@ -652,10 +711,7 @@ describe('UserGetter', function () {
|
|
|
institutionSSO.maxConfirmationMonths * 3,
|
|
institutionSSO.maxConfirmationMonths * 3,
|
|
|
'months'
|
|
'months'
|
|
|
),
|
|
),
|
|
|
- reconfirmedAt: moment().subtract(
|
|
|
|
|
- institutionSSO.maxConfirmationMonths * 2,
|
|
|
|
|
- 'months'
|
|
|
|
|
- ),
|
|
|
|
|
|
|
+ reconfirmedAt: reconfirmed2,
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
email: email3,
|
|
email: email3,
|
|
@@ -664,10 +720,7 @@ describe('UserGetter', function () {
|
|
|
institutionSSO.maxConfirmationMonths * 4,
|
|
institutionSSO.maxConfirmationMonths * 4,
|
|
|
'months'
|
|
'months'
|
|
|
),
|
|
),
|
|
|
- reconfirmedAt: moment().subtract(
|
|
|
|
|
- institutionSSO.maxConfirmationMonths * 4,
|
|
|
|
|
- 'months'
|
|
|
|
|
- ),
|
|
|
|
|
|
|
+ reconfirmedAt: reconfirmed3,
|
|
|
},
|
|
},
|
|
|
],
|
|
],
|
|
|
}
|
|
}
|
|
@@ -695,8 +748,9 @@ describe('UserGetter', function () {
|
|
|
describe('before reconfirmation period expires and within reconfirmation notification period', function () {
|
|
describe('before reconfirmation period expires and within reconfirmation notification period', function () {
|
|
|
const email = 'leonard@example-affiliation.com'
|
|
const email = 'leonard@example-affiliation.com'
|
|
|
it('should flag the email', function (done) {
|
|
it('should flag the email', function (done) {
|
|
|
|
|
+ const { maxConfirmationMonths } = institutionNonSSO
|
|
|
const confirmedAt = moment()
|
|
const confirmedAt = moment()
|
|
|
- .subtract(institutionNonSSO.maxConfirmationMonths, 'months')
|
|
|
|
|
|
|
+ .subtract(maxConfirmationMonths, 'months')
|
|
|
.subtract(14, 'days')
|
|
.subtract(14, 'days')
|
|
|
.toDate() // expires in 14 days
|
|
.toDate() // expires in 14 days
|
|
|
const affiliationsData = [
|
|
const affiliationsData = [
|
|
@@ -707,6 +761,9 @@ describe('UserGetter', function () {
|
|
|
inferred: false,
|
|
inferred: false,
|
|
|
licence: 'pro_plus',
|
|
licence: 'pro_plus',
|
|
|
institution: institutionNonSSO,
|
|
institution: institutionNonSSO,
|
|
|
|
|
+ last_day_to_reconfirm: moment(confirmedAt)
|
|
|
|
|
+ .add(maxConfirmationMonths, 'months')
|
|
|
|
|
+ .toDate(),
|
|
|
},
|
|
},
|
|
|
]
|
|
]
|
|
|
const user = {
|
|
const user = {
|
|
@@ -844,6 +901,45 @@ describe('UserGetter', function () {
|
|
|
)
|
|
)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
+ it('should flag to show notification if v1 shows as reconfirmation upcoming but v2 does not', function (done) {
|
|
|
|
|
+ const email = 'abc123@test.com'
|
|
|
|
|
+ const { maxConfirmationMonths } = institutionNonSSO
|
|
|
|
|
+ const affiliationsData = [
|
|
|
|
|
+ {
|
|
|
|
|
+ email,
|
|
|
|
|
+ licence: 'free',
|
|
|
|
|
+ institution: institutionNonSSO,
|
|
|
|
|
+ last_day_to_reconfirm: moment()
|
|
|
|
|
+ .subtract(maxConfirmationMonths, 'months')
|
|
|
|
|
+ .add(3, 'day')
|
|
|
|
|
+ .toDate(),
|
|
|
|
|
+ },
|
|
|
|
|
+ ]
|
|
|
|
|
+ const user = {
|
|
|
|
|
+ _id: '12390i',
|
|
|
|
|
+ email,
|
|
|
|
|
+ emails: [
|
|
|
|
|
+ {
|
|
|
|
|
+ email,
|
|
|
|
|
+ confirmedAt: new Date(),
|
|
|
|
|
+ default: true,
|
|
|
|
|
+ },
|
|
|
|
|
+ ],
|
|
|
|
|
+ }
|
|
|
|
|
+ this.getUserAffiliations.resolves(affiliationsData)
|
|
|
|
|
+ this.UserGetter.promises.getUser = sinon.stub().resolves(user)
|
|
|
|
|
+ this.UserGetter.getUserFullEmails(
|
|
|
|
|
+ this.fakeUser._id,
|
|
|
|
|
+ (error, fullEmails) => {
|
|
|
|
|
+ expect(error).to.not.exist
|
|
|
|
|
+ expect(
|
|
|
|
|
+ fullEmails[0].affiliation.inReconfirmNotificationPeriod
|
|
|
|
|
+ ).to.equal(true)
|
|
|
|
|
+ done()
|
|
|
|
|
+ }
|
|
|
|
|
+ )
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
describe('cachedLastDayToReconfirm', function () {
|
|
describe('cachedLastDayToReconfirm', function () {
|
|
|
const email = 'abc123@test.com'
|
|
const email = 'abc123@test.com'
|
|
|
const confirmedAt = new Date('2019-07-11T18:25:01.639Z')
|
|
const confirmedAt = new Date('2019-07-11T18:25:01.639Z')
|