const getConstants = require('../../../src/constants').getConstants
const CONSTANTS = getConstants()
const cveIdYear = '2017'
const cveId = `CVE-${cveIdYear}-4024`

const secretariatHeader = {
  'content-type': 'application/json',
  'CVE-API-ORG': 'mitre',
  'CVE-API-USER': 'cpadro',
  'CVE-API-KEY': 'S96E4QT-SMT4YE3-KX03X6K-4615CED'
}

const owningOrgHeader = {
  'content-type': 'application/json',
  'CVE-API-ORG': 'cisco',
  'CVE-API-USER': 'alopez',
  'CVE-API-KEY': 'SVXPHM9-1VXM0A8-QMG8WN0-29MASSE'
}

const orgHeader = {
  'content-type': 'application/json',
  'CVE-API-ORG': 'siemens',
  'CVE-API-USER': 'rgonz',
  'CVE-API-KEY': '006YPCK-14R46D6-KR24W1K-PJG5BVP'
}

const secretariatOrg = {
  UUID: '15fd129f-af00-4d8c-8f7b-e19b0587223f',
  authority: {
    active_roles: [CONSTANTS.AUTH_ROLE_ENUM.CNA, CONSTANTS.AUTH_ROLE_ENUM.SECRETARIAT]
  },
  name: 'The MITRE Corporation',
  policies: {
    id_quota: 1000
  },
  short_name: 'mitre',
  inUse: false
}

const secretariatUser = {
  UUID: 'e13186d5-ce3d-4fd9-aecd-8698c26897f2',
  org_UUID: secretariatOrg.UUID,
  name: {
    first: 'Cristina',
    last: 'Padro'
  },
  authority: {
    active_roles: []
  },
  secret: '$argon2i$v=19$m=4096,t=3,p=1$+qGHEfH5h4/tk404iWBxFw$xV96/b4NvQVvlZIq57wTS8s7gfKzsfMXRiOyf3ffgcw',
  username: 'cpadro',
  active: true
}

const owningOrg = {
  UUID: '88c02595-c8f7-4864-a0e7-e09b3e1da691',
  authority: {
    active_roles: [CONSTANTS.AUTH_ROLE_ENUM.CNA]
  },
  name: 'Cisco',
  policies: {
    id_quota: 1000
  },
  short_name: 'cisco',
  inUse: false
}

const owningOrgUser = {
  UUID: '1fcbf829-81ae-4b53-a61d-9fa04711447f',
  org_UUID: owningOrg.UUID,
  name: {
    first: 'Armando',
    last: 'Lopez',
    middle: 'Jose'
  },
  authority: {
    active_roles: []
  },
  secret: '$argon2i$v=19$m=4096,t=3,p=1$bHTrVB/WVMI+yscYe1Y1aQ$RdQkx9w9sME6z5W/2tyHu/6WcYGvi1JeY3KLbr+ioBg',
  username: 'alopez',
  active: true
}

const org = {
  UUID: 'c0a1d017-faa5-4608-92ff-5c938da17eff',
  authority: {
    active_roles: [CONSTANTS.AUTH_ROLE_ENUM.CNA]
  },
  name: 'Siemens',
  policies: {
    id_quota: 500
  },
  short_name: 'siemens',
  inUse: false
}

const orgUser = {
  UUID: '4121968f-cc2d-4680-b9b0-39e98a2182f6',
  owningOrg: org.UUID,
  name: {
    first: 'Rebecca',
    last: 'Gonzalez',
    middle: 'Andrea'
  },
  authority: {
    active_roles: []
  },
  secret: '$argon2i$v=19$m=4096,t=3,p=1$xADSBGahsOCJfJNGTMMviA$UtHmBfxsw5C6BeKpi7elbxKinDl1FnWZ+i5NdoOb02g',
  username: 'rgonz',
  active: true
}

const nonExistentOrg = {
  UUID: '794715e2-ded9-4a16-8dfd-9a062a63e1d5',
  authority: {
    active_roles: [CONSTANTS.AUTH_ROLE_ENUM.CNA]
  },
  name: 'The Oval Office',
  policies: {
    id_quota: 5
  },
  short_name: 'oval',
  inUse: false
}

const cveReserved = {
  _id: 1,
  cve_id: cveId,
  cve_year: cveIdYear,
  state: CONSTANTS.CVE_STATES.RESERVED,
  owning_cna: owningOrg.UUID,
  requested_by: {
    cna: owningOrgUser.org_UUID,
    user: owningOrgUser.UUID
  },
  time: {
    modified: '2012-03-04T12:34:56.789Z'
  }
}

const cveRejected = {
  _id: 1,
  cve_id: cveId,
  cve_year: cveIdYear,
  state: CONSTANTS.CVE_STATES.REJECTED,
  owning_cna: owningOrg.UUID,
  requested_by: {
    cna: owningOrgUser.org_UUID,
    user: owningOrgUser.UUID
  },
  time: {
    modified: '2012-03-04T12:34:56.789Z'
  }
}

const cvePublished = {
  _id: 1,
  cve_id: cveId,
  cve_year: cveIdYear,
  state: CONSTANTS.CVE_STATES.PUBLISHED,
  owning_cna: owningOrg.UUID,
  requested_by: {
    cna: owningOrgUser.org_UUID,
    user: owningOrgUser.UUID
  },
  time: {
    modified: '2012-03-04T12:34:56.789Z'
  }
}

const cveDummy1 = {
  _id: 1,
  cve_id: 'CVE-2019-5012',
  cve_year: '2019',
  state: CONSTANTS.CVE_STATES.RESERVED,
  owning_cna: owningOrg.UUID,
  requested_by: {
    cna: secretariatUser.org_UUID,
    user: secretariatUser.UUID
  },
  time: {
    modified: '2012-03-04T12:34:56.789Z'
  }
}

const cveDummy2 = {
  _id: 1,
  cve_id: 'CVE-2018-5111',
  cve_year: '2018',
  state: CONSTANTS.CVE_STATES.REJECTED,
  owning_cna: secretariatOrg.UUID,
  requested_by: {
    cna: secretariatUser.org_UUID,
    user: secretariatUser.UUID
  },
  time: {
    modified: '2012-03-04T12:34:56.789Z'
  }
}

const cveDummy3 = {
  _id: 1,
  cve_id: 'CVE-2020-2004',
  cve_year: '2020',
  state: CONSTANTS.CVE_STATES.PUBLISHED,
  owning_cna: secretariatOrg.UUID,
  requested_by: {
    cna: secretariatUser.org_UUID,
    user: secretariatUser.UUID
  },
  time: {
    modified: '2012-03-04T12:34:56.789Z'
  }
}

const cveDummy4 = {
  _id: 1,
  cve_id: 'CVE-2020-20026',
  cve_year: '2020',
  state: CONSTANTS.CVE_STATES.PUBLISHED,
  owning_cna: org.UUID,
  requested_by: {
    cna: secretariatUser.org_UUID,
    user: secretariatUser.UUID
  },
  time: {
    modified: '2012-03-04T12:34:56.789Z'
  }
}

const cveDummy5 = {
  _id: 1,
  cve_id: 'CVE-2020-20030',
  cve_year: '2020',
  state: CONSTANTS.CVE_STATES.AVAILABLE,
  owning_cna: 'N/A',
  requested_by: {
    cna: 'N/A',
    user: 'N/A'
  },
  time: {
    modified: '2012-03-04T12:34:56.789Z'
  }
}

module.exports = {
  secretariatHeader,
  owningOrgHeader,
  orgHeader,
  secretariatOrg,
  secretariatUser,
  owningOrg,
  owningOrgUser,
  org,
  orgUser,
  nonExistentOrg,
  cveReserved,
  cveRejected,
  cvePublished,
  cveDummy1,
  cveDummy2,
  cveDummy3,
  cveDummy4,
  cveDummy5,
  cveIdYear,
  cveId
}
