Skip to content
Open
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
3 changes: 2 additions & 1 deletion schemas/registry-org/BaseOrg.json
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@
"format": "date"
},
"status": {
"type": "string"
"type": "string",
"enum": ["active", "inactive", "pending"]
}
},
"additionalProperties": false
Expand Down
3 changes: 2 additions & 1 deletion schemas/registry-org/create-registry-org-request.json
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@
"format": "date"
},
"status": {
"type": "string"
"type": "string",
"enum": ["active", "inactive", "pending"]
}
},
"description": "Additional partner metadata (restricted)"
Expand Down
3 changes: 2 additions & 1 deletion schemas/registry-org/get-registry-org-response.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@
"format": "date"
},
"status": {
"type": "string"
"type": "string",
"enum": ["active", "inactive", "pending"]
}
},
"description": "Additional partner metadata (restricted)"
Expand Down
3 changes: 2 additions & 1 deletion schemas/registry-org/list-registry-orgs-response.json
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@
"format": "date"
},
"status": {
"type": "string"
"type": "string",
"enum": ["active", "inactive", "pending"]
}
},
"description": "Additional partner metadata (restricted)"
Expand Down
3 changes: 2 additions & 1 deletion schemas/registry-org/update-registry-org-request.json
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,8 @@
"format": "date"
},
"status": {
"type": "string"
"type": "string",
"enum": ["active", "inactive", "pending"]
}
},
"description": "Additional partner metadata (restricted)"
Expand Down
2 changes: 1 addition & 1 deletion src/model/baseorg.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const schema = {
cve_website_update_needed: Boolean,
partner_active_date: String,
partner_inactive_date: String,
status: String
status: { type: String, enum: ['active', 'inactive', 'pending'] }
},
advisory_locations: [String],
advisory_location_require_credentials: Boolean,
Expand Down
39 changes: 39 additions & 0 deletions test/unit-tests/org/baseOrgRepositoryTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,43 @@ describe('Testing BaseOrgRepository', () => {
select
])
})

it('accepts every supported program data status', () => {
const repository = new BaseOrgRepository()

for (const status of ['active', 'inactive', 'pending']) {
const org = {
short_name: 'example-org',
id_quota: 1,
authority: ['CNA'],
program_data: { status }
}

expect(repository.validateOrg(org).isValid, status).to.equal(true)
expect(new BaseOrgModel({ program_data: { status } }).validateSync(), status).to.equal(undefined)
}
})

it('rejects an unsupported program data status', () => {
const repository = new BaseOrgRepository()
const org = {
short_name: 'example-org',
id_quota: 1,
authority: ['CNA'],
program_data: { status: 'archived' }
}

const schemaResult = repository.validateOrg(org)
expect(schemaResult.isValid).to.equal(false)
expect(schemaResult.errors).to.deep.include({
instancePath: '/program_data/status',
schemaPath: '/BaseOrg#/properties/program_data/properties/status/enum',
keyword: 'enum',
params: { allowedValues: ['active', 'inactive', 'pending'] },
message: 'must be equal to one of the allowed values'
})

const validationError = new BaseOrgModel({ program_data: { status: 'archived' } }).validateSync()
expect(validationError.errors['program_data.status'].kind).to.equal('enum')
})
})
Loading