Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IMN-213 Fix document update based on descriptor state in catalog-process #185

Merged
merged 110 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
fcef976
Renaming
taglioni-r Jan 11, 2024
57789f5
Implement more tests
taglioni-r Jan 11, 2024
9fe8914
Use retrieveDescriptor
taglioni-r Jan 11, 2024
a64efaf
Implement more tests
taglioni-r Jan 11, 2024
0e46486
Implement more tests
taglioni-r Jan 11, 2024
6b61497
Minor refactor
taglioni-r Jan 15, 2024
d94ed28
Implement tests
taglioni-r Jan 15, 2024
ccd3fdc
Implement more tests
taglioni-r Jan 16, 2024
96daa0d
Add to do
taglioni-r Jan 16, 2024
183b1c6
Merge branch 'main' into IMN-145-implement-remaining-tests-in-catalog…
taglioni-r Jan 16, 2024
45ec14a
Implement more tests
taglioni-r Jan 17, 2024
be84946
Fix in catalog readModelService
taglioni-r Jan 17, 2024
3d7d12a
Remove not needed check
taglioni-r Jan 17, 2024
c68f015
Implement more tests
taglioni-r Jan 18, 2024
ebaa361
Add missing error
taglioni-r Jan 18, 2024
f55fbd1
Add missing error
taglioni-r Jan 18, 2024
719af1c
Add missing error
taglioni-r Jan 18, 2024
c50049d
Implement more tests
taglioni-r Jan 18, 2024
b02b13b
Remove error
taglioni-r Jan 18, 2024
ae6d93d
Improve data coherence
taglioni-r Jan 18, 2024
6a23fa1
Fix descriptor version
taglioni-r Jan 19, 2024
44e2f51
Implement more tests
taglioni-r Jan 19, 2024
7852f3a
Remove console log
taglioni-r Jan 19, 2024
aecdecf
Improve data coherence
taglioni-r Jan 19, 2024
26fe35a
Merge branch 'main' into IMN-145-implement-remaining-tests-in-catalog…
taglioni-r Jan 22, 2024
b18320b
Use retrieveDescriptor
taglioni-r Jan 11, 2024
8bb624b
Minor refactor
taglioni-r Jan 15, 2024
38804b4
Fix in catalog readModelService
taglioni-r Jan 17, 2024
863ae92
Remove not needed check
taglioni-r Jan 17, 2024
e7bfde5
Add missing error
taglioni-r Jan 18, 2024
a8db816
Add missing error
taglioni-r Jan 18, 2024
d4f7ced
Add missing error
taglioni-r Jan 18, 2024
986ff04
Remove error
taglioni-r Jan 18, 2024
cff3ffb
Fix descriptor version
taglioni-r Jan 19, 2024
a76a369
Fix tests
taglioni-r Jan 22, 2024
4ec69d1
Refactor
taglioni-r Jan 22, 2024
56bf3e8
Fix test
taglioni-r Jan 22, 2024
606bfb9
Merge branch 'main' into refactor-and-bug-fixing-in-catalog-process
taglioni-r Jan 22, 2024
523f905
Fix after merge
taglioni-r Jan 22, 2024
149edf2
Merge branch 'main' into IMN-145-implement-remaining-tests-in-catalog…
taglioni-r Jan 22, 2024
70e22b8
Merge branch 'refactor-and-bug-fixing-in-catalog-process' into IMN-14…
taglioni-r Jan 22, 2024
2721cd0
refactor string ids
taglioni-r Jan 22, 2024
c99a5ae
Improve check on version number
taglioni-r Jan 22, 2024
b0ef45b
Edit test name
taglioni-r Jan 23, 2024
23e82ee
Fix business logic
taglioni-r Jan 24, 2024
0eb90fe
Fix tests and add coverage
taglioni-r Jan 24, 2024
55fee87
Add error in mapper
taglioni-r Jan 24, 2024
2e84b4f
Update business logic
taglioni-r Jan 24, 2024
cab9a4d
Update tests
taglioni-r Jan 24, 2024
74c938d
Add check in business logic
taglioni-r Jan 25, 2024
9d70bea
Fix previous tests
taglioni-r Jan 25, 2024
ac01572
Add new tests
taglioni-r Jan 25, 2024
fdd55d2
Add error in mapper
taglioni-r Jan 25, 2024
e044962
Fix business logic
taglioni-r Jan 26, 2024
1d1f57b
Fix previous tests
taglioni-r Jan 26, 2024
16d1692
Add test coverage
taglioni-r Jan 26, 2024
0afbc38
Fix business logic
taglioni-r Jan 26, 2024
6dd6a9f
Add test
taglioni-r Jan 26, 2024
6453f9d
Fix test
taglioni-r Jan 26, 2024
7e4b54b
Refactor
taglioni-r Jan 26, 2024
ec16e8f
Refactor
taglioni-r Jan 26, 2024
01a3934
Minor fix
taglioni-r Jan 29, 2024
3decd5b
Merge branch 'IMN-207_add-name-check-on-eservice-update' into IMN-195…
taglioni-r Jan 29, 2024
fd803aa
Merge branch 'IMN-195_fix-document-upload-based-on-descriptor-state' …
taglioni-r Jan 29, 2024
d80c3e9
Merge branch 'IMN-209_fix-document-delete-based-on-descriptor-state' …
taglioni-r Jan 29, 2024
34fa7c1
Add error in mapper
taglioni-r Jan 29, 2024
087d815
Minor fixes
taglioni-r Jan 29, 2024
8b36438
Merge branch 'IMN-209_fix-document-delete-based-on-descriptor-state' …
taglioni-r Jan 29, 2024
2985836
Fix
taglioni-r Jan 29, 2024
a207156
Fix
taglioni-r Jan 29, 2024
c5b63af
Fix
taglioni-r Jan 29, 2024
aa1699c
Merge branch 'IMN-207_add-name-check-on-eservice-update' into IMN-195…
taglioni-r Jan 29, 2024
0bb951c
Merge branch 'IMN-195_fix-document-upload-based-on-descriptor-state' …
taglioni-r Jan 29, 2024
d568d3f
Fix error title
taglioni-r Jan 31, 2024
c65501f
Fix business logic
taglioni-r Jan 31, 2024
a7884ae
Fix tests
taglioni-r Jan 31, 2024
5b8a70b
Add test coverage
taglioni-r Jan 31, 2024
e4e9606
Change status code
taglioni-r Jan 31, 2024
3e3ff7d
Fix
taglioni-r Jan 31, 2024
14b0e1c
Merge branch 'IMN-209_fix-document-delete-based-on-descriptor-state' …
taglioni-r Jan 31, 2024
b53c504
Fix
taglioni-r Jan 31, 2024
58db97d
Merge branch 'IMN-211_add-check-for-duplicate-interface' into IMN-213…
taglioni-r Jan 31, 2024
a7016bd
Fix case where the update doesn't change the name
taglioni-r Feb 2, 2024
c59cdd7
Merge branch 'IMN-145-implement-remaining-tests-in-catalog-process' i…
taglioni-r Feb 2, 2024
306cc90
Refactor
taglioni-r Feb 5, 2024
5c1cfb3
Improve timing in tests
taglioni-r Feb 5, 2024
2618c67
Refactor
taglioni-r Feb 5, 2024
7f03293
Merge branch 'main' into refactor-and-bug-fixing-in-catalog-process
taglioni-r Feb 7, 2024
ff07c48
Merge branch 'refactor-and-bug-fixing-in-catalog-process' into IMN-14…
taglioni-r Feb 7, 2024
3ab8534
Merge branch 'IMN-145-implement-remaining-tests-in-catalog-process' i…
taglioni-r Feb 7, 2024
4b0e795
Fix after merge
taglioni-r Feb 7, 2024
544256b
Merge branch 'IMN-200_fix-name-of-cloned-eservice' into IMN-207_add-n…
taglioni-r Feb 7, 2024
8c22f22
Improve logic to avoid not needed queries
taglioni-r Feb 12, 2024
dbc0a2b
Merge branch 'main' into refactor-and-bug-fixing-in-catalog-process
taglioni-r Feb 12, 2024
fffc812
Merge branch 'main' into refactor-and-bug-fixing-in-catalog-process
taglioni-r Feb 13, 2024
d66dd39
Merge branch 'refactor-and-bug-fixing-in-catalog-process' into IMN-14…
taglioni-r Feb 13, 2024
44ded25
Refactor and fix id
taglioni-r Feb 13, 2024
e62e021
Merge branch 'IMN-145-implement-remaining-tests-in-catalog-process' i…
taglioni-r Feb 13, 2024
a30937b
Merge branch 'IMN-200_fix-name-of-cloned-eservice' into IMN-207_add-n…
taglioni-r Feb 13, 2024
dfc10f0
Merge branch 'main' into refactor-and-bug-fixing-in-catalog-process
taglioni-r Feb 13, 2024
7c2a4e7
Merge branch 'refactor-and-bug-fixing-in-catalog-process' into IMN-14…
taglioni-r Feb 13, 2024
33d126a
Merge branch 'IMN-145-implement-remaining-tests-in-catalog-process' i…
taglioni-r Feb 13, 2024
c9f9ea1
Merge branch 'IMN-200_fix-name-of-cloned-eservice' into IMN-207_add-n…
taglioni-r Feb 13, 2024
dc34445
Merge branch 'IMN-207_add-name-check-on-eservice-update' into IMN-195…
taglioni-r Feb 13, 2024
7cb6cd8
Merge branch 'IMN-195_fix-document-upload-based-on-descriptor-state' …
taglioni-r Feb 13, 2024
881cc3a
Merge branch 'IMN-209_fix-document-delete-based-on-descriptor-state' …
taglioni-r Feb 13, 2024
4c99a20
Merge branch 'IMN-211_add-check-for-duplicate-interface' into IMN-213…
taglioni-r Feb 13, 2024
9a3b7bc
Merge branch 'main' into IMN-213_fix-document-update-based-on-descrip…
taglioni-r Feb 13, 2024
6bf00e6
Fix ids
taglioni-r Feb 13, 2024
2b16d43
Merge branch 'main' into IMN-213_fix-document-update-based-on-descrip…
taglioni-r Feb 13, 2024
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
4 changes: 4 additions & 0 deletions packages/catalog-process/src/services/catalogService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,10 @@ export async function updateDocumentLogic({

const descriptor = retrieveDescriptor(descriptorId, eService);

if (descriptor.state !== descriptorState.draft) {
throw notValidDescriptor(descriptor.id, descriptor.state);
}

const document = (
descriptor ? [...descriptor.docs, descriptor.interface] : []
).find((doc) => doc != null && doc.id === documentId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2125,6 +2125,98 @@ describe("database test", async () => {
eServiceDescriptorNotFound(eService.id, mockDescriptor.id)
);
});
it("should throw notValidDescriptor if the descriptor is in Published state", async () => {
const descriptor: Descriptor = {
...mockDescriptor,
interface: mockDocument,
state: descriptorState.published,
};
const eService: EService = {
...mockEService,
descriptors: [descriptor],
};
await addOneEService(eService, postgresDB, eservices);
expect(
catalogService.updateDocument(
eService.id,
descriptor.id,
generateId(),
{ prettyName: "updated prettyName" },
getMockAuthData(eService.producerId)
)
).rejects.toThrowError(
notValidDescriptor(descriptor.id, descriptorState.published)
);
});
it("should throw notValidDescriptor if the descriptor is in Suspended state", async () => {
const descriptor: Descriptor = {
...mockDescriptor,
interface: mockDocument,
state: descriptorState.suspended,
};
const eService: EService = {
...mockEService,
descriptors: [descriptor],
};
await addOneEService(eService, postgresDB, eservices);
expect(
catalogService.updateDocument(
eService.id,
descriptor.id,
generateId(),
{ prettyName: "updated prettyName" },
getMockAuthData(eService.producerId)
)
).rejects.toThrowError(
notValidDescriptor(descriptor.id, descriptorState.suspended)
);
});
it("should throw notValidDescriptor if the descriptor is in Archived state", async () => {
const descriptor: Descriptor = {
...mockDescriptor,
interface: mockDocument,
state: descriptorState.archived,
};
const eService: EService = {
...mockEService,
descriptors: [descriptor],
};
await addOneEService(eService, postgresDB, eservices);
expect(
catalogService.updateDocument(
eService.id,
descriptor.id,
generateId(),
{ prettyName: "updated prettyName" },
getMockAuthData(eService.producerId)
)
).rejects.toThrowError(
notValidDescriptor(descriptor.id, descriptorState.archived)
);
});
it("should throw notValidDescriptor if the descriptor is in Deprecated state", async () => {
const descriptor: Descriptor = {
...mockDescriptor,
interface: mockDocument,
state: descriptorState.deprecated,
};
const eService: EService = {
...mockEService,
descriptors: [descriptor],
};
await addOneEService(eService, postgresDB, eservices);
expect(
catalogService.updateDocument(
eService.id,
descriptor.id,
generateId(),
{ prettyName: "updated prettyName" },
getMockAuthData(eService.producerId)
)
).rejects.toThrowError(
notValidDescriptor(descriptor.id, descriptorState.deprecated)
);
});
it("should throw eServiceDocumentNotFound if the document doesn't exist", async () => {
const descriptor: Descriptor = {
...mockDescriptor,
Expand Down
Loading