Fix credential library mocks (#2161)

* fix: 🐛 vault cred library mocks
This commit is contained in:
Dharini Jeeva authored and GitHub committed 2024-02-27 09:41:28 -08:00
1 parent 47d7ceccf7
commit 3fc865d226
2 files changed
+17 -3

No files matched your search

+17 -1
View File
@@ -632,7 +632,23 @@ function routes() {
{ queryParams: { credential_store_id: credentialStoreId } },
) => credentialLibraries.where({ credentialStoreId }),
);
this.get('/credential-libraries/:id');
this.get(
'/credential-libraries/:id',
function ({ credentialLibraries }, { params: { id } }) {
const library = credentialLibraries.find(id);
// BE API only updates these fields if there's an update mask, otherwise they remain unmodified
// but we don't need this flow in our mocks, so we are deleting fields with null value
const { credentialMappingOverrides } = library;
if (Object.keys(credentialMappingOverrides || {}).length) {
Object.keys(credentialMappingOverrides).forEach((key) => {
if (credentialMappingOverrides[key] === null) {
delete credentialMappingOverrides[key];
}
});
}
return library;
},
);
this.post(
'/credential-libraries',
function ({ credentialStores, credentialLibraries }) {