Skip to content

Commit

Permalink
Merge pull request #30 from coveo/feat-securitycache-refresh-single-p…
Browse files Browse the repository at this point in the history
…rovider

feat(securitycache): refresh single provider
  • Loading branch information
dmgauthier authored Oct 25, 2019
2 parents f64531b + 9e1c702 commit 839be1f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/resources/SecurityCache/SecurityCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
} from './SecurityCacheInterfaces';

export default class SecurityCache extends Ressource {
static baseUrl = `/rest/organizations/${API.orgPlaceholder}`;
static baseUrl = `rest/organizations/${API.orgPlaceholder}`;
static cacheUrl = `/${SecurityCache.baseUrl}/securitycache`;
static providersUrl = `/${SecurityCache.baseUrl}/securityproviders`;

Expand Down Expand Up @@ -39,6 +39,10 @@ export default class SecurityCache extends Ressource {
return this.api.post(`${SecurityCache.cacheUrl}/refresh`);
}

refreshProvider(providerId: string) {
return this.api.post(`${SecurityCache.cacheUrl}/${providerId}/refresh`);
}

listProviders() {
return this.api.get<SecurityProviderModelWithStatus>(SecurityCache.providersUrl);
}
Expand Down
6 changes: 6 additions & 0 deletions src/resources/SecurityCache/tests/SecurityCache.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ describe('securityCache', () => {
expect(api.post).toHaveBeenCalledTimes(1);
expect(api.post).toHaveBeenCalledWith(`${SecurityCache.cacheUrl}/refresh`);
});

it('should make a POST call to the security Provider refresh url', () => {
securityCache.refreshProvider('PROVIDER_ID');
expect(api.post).toHaveBeenCalledTimes(1);
expect(api.post).toHaveBeenCalledWith(`${SecurityCache.cacheUrl}/PROVIDER_ID/refresh`);
});
});

describe('status', () => {
Expand Down

0 comments on commit 839be1f

Please sign in to comment.