Skip to content

Commit 6bae486

Browse files
committed
re-generating openap.json
2 parents 8bb075a + 2416327 commit 6bae486

File tree

8 files changed

+542
-282
lines changed

8 files changed

+542
-282
lines changed

api-docs/openapi.json

Lines changed: 147 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1889,16 +1889,86 @@
18891889
},
18901890
"/registry/org": {
18911891
"get": {
1892-
"description": "",
1892+
"tags": [
1893+
"Registry Organization"
1894+
],
1895+
"summary": "Retrieves all registry organizations (accessible to Secretariat)",
1896+
"description": " <h2>Access Control</h2> <p>User must belong to an organization with the <b>Secretariat</b> role</p> <h2>Expected Behavior</h2> <p><b>Secretariat:</b> Retrieves information about all registry organizations</p>",
1897+
"operationId": "registryOrgAll",
1898+
"parameters": [
1899+
{
1900+
"$ref": "#/components/parameters/pageQuery"
1901+
},
1902+
{
1903+
"$ref": "#/components/parameters/apiEntityHeader"
1904+
},
1905+
{
1906+
"$ref": "#/components/parameters/apiUserHeader"
1907+
},
1908+
{
1909+
"$ref": "#/components/parameters/apiSecretHeader"
1910+
}
1911+
],
18931912
"responses": {
1913+
"200": {
1914+
"description": "Returns information about all registry organizations, along with pagination fields if results span multiple pages of data",
1915+
"content": {
1916+
"application/json": {
1917+
"schema": {
1918+
"$ref": "../schemas/registry-org/list-registry-orgs-response.json"
1919+
}
1920+
}
1921+
}
1922+
},
18941923
"400": {
1895-
"description": "Bad Request"
1924+
"description": "Bad Request",
1925+
"content": {
1926+
"application/json": {
1927+
"schema": {
1928+
"$ref": "../schemas/errors/bad-request.json"
1929+
}
1930+
}
1931+
}
18961932
},
18971933
"401": {
1898-
"description": "Unauthorized"
1934+
"description": "Not Authenticated",
1935+
"content": {
1936+
"application/json": {
1937+
"schema": {
1938+
"$ref": "../schemas/errors/generic.json"
1939+
}
1940+
}
1941+
}
18991942
},
19001943
"403": {
1901-
"description": "Forbidden"
1944+
"description": "Forbidden",
1945+
"content": {
1946+
"application/json": {
1947+
"schema": {
1948+
"$ref": "../schemas/errors/generic.json"
1949+
}
1950+
}
1951+
}
1952+
},
1953+
"404": {
1954+
"description": "Not Found",
1955+
"content": {
1956+
"application/json": {
1957+
"schema": {
1958+
"$ref": "../schemas/errors/generic.json"
1959+
}
1960+
}
1961+
}
1962+
},
1963+
"500": {
1964+
"description": "Internal Server Error",
1965+
"content": {
1966+
"application/json": {
1967+
"schema": {
1968+
"$ref": "../schemas/errors/generic.json"
1969+
}
1970+
}
1971+
}
19021972
}
19031973
}
19041974
},
@@ -1965,23 +2035,92 @@
19652035
},
19662036
"/registry/org/{identifier}": {
19672037
"get": {
1968-
"description": "",
2038+
"tags": [
2039+
"Registry Organization"
2040+
],
2041+
"summary": "Retrieves information about the registry organization specified by short name or UUID (accessible to all registered users)",
2042+
"description": " <h2>Access Control</h2> <p>All registered users can access this endpoint</p> <h2>Expected Behavior</h2> <p><b>Regular, CNA & Admin Users:</b> Retrieves registry organization record for the specified shortname or UUID if it is the user's organization</p> <p><b>Secretariat:</b> Retrieves information about any registry organization</p>",
2043+
"operationId": "registryOrgSingle",
19692044
"parameters": [
19702045
{
19712046
"name": "identifier",
19722047
"in": "path",
19732048
"required": true,
19742049
"schema": {
19752050
"type": "string"
1976-
}
2051+
},
2052+
"description": "The shortname or UUID of the registry organization"
2053+
},
2054+
{
2055+
"$ref": "#/components/parameters/apiEntityHeader"
2056+
},
2057+
{
2058+
"$ref": "#/components/parameters/apiUserHeader"
2059+
},
2060+
{
2061+
"$ref": "#/components/parameters/apiSecretHeader"
19772062
}
19782063
],
19792064
"responses": {
2065+
"200": {
2066+
"description": "Returns the registry organization information",
2067+
"content": {
2068+
"application/json": {
2069+
"schema": {
2070+
"$ref": "../schemas/registry-org/get-registry-org-response.json"
2071+
}
2072+
}
2073+
}
2074+
},
19802075
"400": {
1981-
"description": "Bad Request"
2076+
"description": "Bad Request",
2077+
"content": {
2078+
"application/json": {
2079+
"schema": {
2080+
"$ref": "../schemas/errors/bad-request.json"
2081+
}
2082+
}
2083+
}
19822084
},
19832085
"401": {
1984-
"description": "Unauthorized"
2086+
"description": "Not Authenticated",
2087+
"content": {
2088+
"application/json": {
2089+
"schema": {
2090+
"$ref": "../schemas/errors/generic.json"
2091+
}
2092+
}
2093+
}
2094+
},
2095+
"403": {
2096+
"description": "Forbidden",
2097+
"content": {
2098+
"application/json": {
2099+
"schema": {
2100+
"$ref": "../schemas/errors/generic.json"
2101+
}
2102+
}
2103+
}
2104+
},
2105+
"404": {
2106+
"description": "Not Found",
2107+
"content": {
2108+
"application/json": {
2109+
"schema": {
2110+
"$ref": "../schemas/errors/generic.json"
2111+
}
2112+
}
2113+
}
2114+
},
2115+
"500": {
2116+
"description": "Internal Server Error",
2117+
"content": {
2118+
"application/json": {
2119+
"schema": {
2120+
"$ref": "../schemas/errors/generic.json"
2121+
}
2122+
}
2123+
}
19852124
}
19862125
}
19872126
}

src/controller/org.controller/index.js

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,72 @@ const getConstants = require('../../../src/constants').getConstants
1212
const CONSTANTS = getConstants()
1313

1414
router.get('/registry/org',
15+
/*
16+
#swagger.tags = ['Registry Organization']
17+
#swagger.operationId = 'registryOrgAll'
18+
#swagger.summary = "Retrieves all registry organizations (accessible to Secretariat)"
19+
#swagger.description = "
20+
<h2>Access Control</h2>
21+
<p>User must belong to an organization with the <b>Secretariat</b> role</p>
22+
<h2>Expected Behavior</h2>
23+
<p><b>Secretariat:</b> Retrieves information about all registry organizations</p>"
24+
#swagger.parameters['$ref'] = [
25+
'#/components/parameters/pageQuery',
26+
'#/components/parameters/apiEntityHeader',
27+
'#/components/parameters/apiUserHeader',
28+
'#/components/parameters/apiSecretHeader'
29+
]
30+
#swagger.responses[200] = {
31+
description: 'Returns information about all registry organizations, along with pagination fields if results span multiple pages of data',
32+
content: {
33+
"application/json": {
34+
schema: {
35+
$ref: '../schemas/registry-org/list-registry-orgs-response.json'
36+
}
37+
}
38+
}
39+
}
40+
#swagger.responses[400] = {
41+
description: 'Bad Request',
42+
content: {
43+
"application/json": {
44+
schema: { $ref: '../schemas/errors/bad-request.json' }
45+
}
46+
}
47+
}
48+
#swagger.responses[401] = {
49+
description: 'Not Authenticated',
50+
content: {
51+
"application/json": {
52+
schema: { $ref: '../schemas/errors/generic.json' }
53+
}
54+
}
55+
}
56+
#swagger.responses[403] = {
57+
description: 'Forbidden',
58+
content: {
59+
"application/json": {
60+
schema: { $ref: '../schemas/errors/generic.json' }
61+
}
62+
}
63+
}
64+
#swagger.responses[404] = {
65+
description: 'Not Found',
66+
content: {
67+
"application/json": {
68+
schema: { $ref: '../schemas/errors/generic.json' }
69+
}
70+
}
71+
}
72+
#swagger.responses[500] = {
73+
description: 'Internal Server Error',
74+
content: {
75+
"application/json": {
76+
schema: { $ref: '../schemas/errors/generic.json' }
77+
}
78+
}
79+
}
80+
*/
1581
mw.useRegistry(),
1682
mw.validateUser,
1783
mw.onlySecretariat,
@@ -41,6 +107,73 @@ router.get('/registry/org/:shortname/id_quota',
41107
controller.ORG_ID_QUOTA)
42108

43109
router.get('/registry/org/:identifier',
110+
/*
111+
#swagger.tags = ['Registry Organization']
112+
#swagger.operationId = 'registryOrgSingle'
113+
#swagger.summary = "Retrieves information about the registry organization specified by short name or UUID (accessible to all registered users)"
114+
#swagger.description = "
115+
<h2>Access Control</h2>
116+
<p>All registered users can access this endpoint</p>
117+
<h2>Expected Behavior</h2>
118+
<p><b>Regular, CNA & Admin Users:</b> Retrieves registry organization record for the specified shortname or UUID if it is the user's organization</p>
119+
<p><b>Secretariat:</b> Retrieves information about any registry organization</p>"
120+
#swagger.parameters['identifier'] = { description: 'The shortname or UUID of the registry organization' }
121+
#swagger.parameters['$ref'] = [
122+
'#/components/parameters/apiEntityHeader',
123+
'#/components/parameters/apiUserHeader',
124+
'#/components/parameters/apiSecretHeader'
125+
]
126+
#swagger.responses[200] = {
127+
description: 'Returns the registry organization information',
128+
content: {
129+
"application/json": {
130+
schema: {
131+
$ref: '../schemas/registry-org/get-registry-org-response.json'
132+
}
133+
}
134+
}
135+
}
136+
#swagger.responses[400] = {
137+
description: 'Bad Request',
138+
content: {
139+
"application/json": {
140+
schema: { $ref: '../schemas/errors/bad-request.json' }
141+
}
142+
}
143+
}
144+
#swagger.responses[401] = {
145+
description: 'Not Authenticated',
146+
content: {
147+
"application/json": {
148+
schema: { $ref: '../schemas/errors/generic.json' }
149+
}
150+
}
151+
}
152+
#swagger.responses[403] = {
153+
description: 'Forbidden',
154+
content: {
155+
"application/json": {
156+
schema: { $ref: '../schemas/errors/generic.json' }
157+
}
158+
}
159+
}
160+
#swagger.responses[404] = {
161+
description: 'Not Found',
162+
content: {
163+
"application/json": {
164+
schema: { $ref: '../schemas/errors/generic.json' }
165+
}
166+
}
167+
}
168+
#swagger.responses[500] = {
169+
description: 'Internal Server Error',
170+
content: {
171+
"application/json": {
172+
schema: { $ref: '../schemas/errors/generic.json' }
173+
}
174+
}
175+
}
176+
*/
44177
mw.useRegistry(),
45178
mw.validateUser,
46179
parseError,

src/controller/org.controller/org.controller.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ async function registryUpdateOrg (req, res, next) {
356356
return res.status(404).json(error.orgDnePathParam(shortNameUrlParameter))
357357
}
358358

359-
if (Object.hasOwn(queryParametersJson, 'new_short_name') && !(await orgRepository.orgExists(queryParametersJson.new_short_name, { session }))) {
359+
if (Object.hasOwn(queryParametersJson, 'new_short_name') && (await orgRepository.orgExists(queryParametersJson.new_short_name, { session }))) {
360360
await session.abortTransaction()
361361
return res.status(403).json(error.duplicateShortname(queryParametersJson.new_short_name))
362362
}
@@ -405,13 +405,13 @@ async function updateOrg (req, res, next) {
405405
return res.status(404).json(error.orgDnePathParam(shortNameUrlParameter))
406406
}
407407

408-
if (Object.hasOwn(queryParametersJson, 'new_short_name') && !(await orgRepository.orgExists(queryParametersJson.new_short_name, { session }))) {
408+
if (Object.hasOwn(queryParametersJson, 'new_short_name') && (await orgRepository.orgExists(queryParametersJson.new_short_name, { session }))) {
409409
return res.status(403).json(error.duplicateShortname(queryParametersJson.new_short_name))
410410
}
411411

412412
const updatedOrg = await orgRepository.updateOrg(shortNameUrlParameter, queryParametersJson, { session }, true)
413413

414-
const userRepo = req.ctx.repositories.getUserRepository()
414+
const userRepo = req.ctx.repositories.getBaseUserRepository()
415415
responseMessage = { message: `${updatedOrg.short_name} organization was successfully updated.`, updated: updatedOrg } // Clarify message
416416
const payload = { action: 'update_org', change: `${updatedOrg.short_name} organization was successfully updated.`, org: updatedOrg }
417417
payload.user_UUID = await userRepo.getUserUUID(req.ctx.user, updatedOrg.UUID)

test/integration-tests/org/registryOrgAsOrgAdmin.js

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -311,20 +311,6 @@ describe('Testing Registry Org as org admin', () => {
311311
expect(res.body.error).to.equal('NOT_ORG_ADMIN_OR_SECRETARIAT')
312312
})
313313
})
314-
// This test seems obe?
315-
it.skip('Registry: Services prevents org admins from creating a user with conflicts in the organization the user belongs to (org in the path is diff from the org in the json body)', async () => {
316-
await chai.request(app)
317-
.post(`/api/registry/org/${shortName}/user`)
318-
.set(adminHeaders)
319-
.send({
320-
username: 'BLARG',
321-
org_UUID: 'test'
322-
})
323-
.then((res, err) => {
324-
expect(err).to.be.undefined
325-
expect(res).to.have.status(400)
326-
})
327-
})
328314
it('Registry: Services api does not allow org admins to update their own orgs', async () => {
329315
await chai.request(app)
330316
.post('/api/registry/org')

0 commit comments

Comments
 (0)