@@ -6,6 +6,10 @@ const expect = chai.expect
66const constants = require ( '../constants.js' )
77const app = require ( '../../../src/index.js' )
88
9+ const registryFlag = {
10+ registry : true
11+ }
12+
913describe ( 'Testing Org post endpoint' , ( ) => {
1014 context ( 'Positive Tests' , ( ) => {
1115 it ( 'Allows creation of org' , async ( ) => {
@@ -37,9 +41,45 @@ describe('Testing Org post endpoint', () => {
3741 expect ( res . body . created . authority ) . to . deep . equal ( constants . testOrg . authority )
3842 } )
3943 } )
44+ it ( 'Allows creation of an org with registry enabled' , async ( ) => {
45+ await chai . request ( app )
46+ . post ( '/api/org' )
47+ . set ( constants . headers )
48+ . query ( registryFlag )
49+ . send ( constants . testRegistryOrg )
50+ . then ( ( res , err ) => {
51+ expect ( err ) . to . be . undefined
52+ expect ( res ) . to . have . status ( 200 )
53+
54+ expect ( res . body ) . to . haveOwnProperty ( 'message' )
55+ expect ( res . body . message ) . to . equal ( constants . testRegistryOrg . short_name + ' organization was successfully created.' )
56+
57+ expect ( res . body ) . to . haveOwnProperty ( 'created' )
58+
59+ expect ( res . body . created ) . to . haveOwnProperty ( 'UUID' )
60+
61+ expect ( res . body . created ) . to . haveOwnProperty ( 'short_name' )
62+ expect ( res . body . created . short_name ) . to . equal ( constants . testRegistryOrg . short_name )
63+
64+ expect ( res . body . created ) . to . haveOwnProperty ( 'long_name' )
65+ expect ( res . body . created . long_name ) . to . equal ( constants . testRegistryOrg . long_name )
66+
67+ expect ( res . body . created ) . to . haveOwnProperty ( 'cve_program_org_function' )
68+ expect ( res . body . created . cve_program_org_function ) . to . equal ( constants . testRegistryOrg . cve_program_org_function )
69+
70+ expect ( res . body . created ) . to . haveOwnProperty ( 'contact_info' )
71+ expect ( res . body . created . contact_info ) . to . include ( constants . testRegistryOrg . contact_info )
72+
73+ expect ( res . body . created ) . to . haveOwnProperty ( 'authority' )
74+ expect ( res . body . created . authority ) . to . deep . equal ( constants . testRegistryOrg . authority )
75+
76+ expect ( res . body . created ) . to . haveOwnProperty ( 'hard_quota' )
77+ expect ( res . body . created . hard_quota ) . to . equal ( constants . testRegistryOrg . hard_quota )
78+ } )
79+ } )
4080 } )
41- context ( 'Negitive Test ' , ( ) => {
42- it ( 'Should fail to create an org that already exists ' , async ( ) => {
81+ context ( 'Negative Tests ' , ( ) => {
82+ it ( 'Should fail to create an org that already exists' , async ( ) => {
4383 await chai . request ( app )
4484 . post ( '/api/org' )
4585 . set ( { ...constants . headers } )
@@ -48,6 +88,20 @@ describe('Testing Org post endpoint', () => {
4888 expect ( err ) . to . be . undefined
4989 expect ( res ) . to . have . status ( 400 )
5090
91+ expect ( res . body ) . to . haveOwnProperty ( 'error' )
92+ expect ( res . body . error ) . to . equal ( 'ORG_EXISTS' )
93+ } )
94+ } )
95+ it ( 'Should fail to create an org that already exists with registry enabled' , async ( ) => {
96+ await chai . request ( app )
97+ . post ( '/api/org' )
98+ . set ( { ...constants . headers } )
99+ . query ( registryFlag )
100+ . send ( constants . existingRegistryOrg )
101+ . then ( ( res , err ) => {
102+ expect ( err ) . to . be . undefined
103+ expect ( res ) . to . have . status ( 400 )
104+
51105 expect ( res . body ) . to . haveOwnProperty ( 'error' )
52106 expect ( res . body . error ) . to . equal ( 'ORG_EXISTS' )
53107 } )
0 commit comments