Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

Commit

Permalink
[ACS-5845] remove Alfresco Compatibility usage (#1627)
Browse files Browse the repository at this point in the history
* remove unused mock api

* migrate to latest api

* migrate to latest api

* migrate to latest api

* migrate to latest api

* migrate to latest api

* typing fixes
  • Loading branch information
DenysVuika committed Aug 16, 2023
1 parent e274913 commit 8cc1d4c
Show file tree
Hide file tree
Showing 17 changed files with 166 additions and 373 deletions.
23 changes: 23 additions & 0 deletions src/api/content-rest-api/api/nodes.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,29 @@ parameter are returned in addition to those specified in the **fields** paramete
pathParams, queryParams, headerParams, formParams, postBody,
contentTypes, accepts, returnType);
}

/**
* Create a folder
*
* @param name - folder name
* @param relativePath - The relativePath specifies the folder structure to create relative to the node identified by nodeId.
* @param nodeId default value root.The identifier of a node where add the folder. You can also use one of these well-known aliases: -my- | -shared- | -root-
* @param opts Optional parameters
*
* @returns A promise that is resolved if the folder is created and {error} if rejected.
*/
createFolder(name: string, relativePath: string, nodeId: string, opts?: any): Promise<NodeEntry> {
nodeId = nodeId || '-root-';

const nodeBody = new NodeBodyCreate({
name,
relativePath,
nodeType: 'cm:folder'
});

return this.createNode(nodeId, nodeBody, opts);
}

/**
* Create secondary child
*
Expand Down
3 changes: 1 addition & 2 deletions test/alfrescoApiClient.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
* limitations under the License.
*/

import { AlfrescoApiCompatibility as AlfrescoApi, AlfrescoApiConfig } from '../index';
import { DateAlfresco } from '../index';
import { AlfrescoApiConfig, AlfrescoApi, DateAlfresco } from '../index';
import { EcmAuthMock } from '../test/mockObjects';

const chai = require('chai');
Expand Down
23 changes: 15 additions & 8 deletions test/auth.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@
*/

import { expect } from 'chai';
import { AlfrescoApiConfig } from '../src/alfrescoApiConfig';
import { AlfrescoApiCompatibility as AlfrescoApi } from '../src/alfrescoApiCompatibility';
import { EcmAuthMock, BpmAuthMock, NodeMock, ProfileMock } from '../test/mockObjects';
import { NodesApi, UserProfileApi, AlfrescoApiConfig, AlfrescoApi } from '../index';

const NOOP = () => { /* empty */ };
const ECM_HOST = 'http://127.0.0.1:8080';
Expand All @@ -33,6 +32,7 @@ describe('Auth', () => {
describe('ECM Provider config', () => {
let authResponseEcmMock: EcmAuthMock;
let nodeMock: NodeMock;
let nodesApi: NodesApi;

beforeEach(() => {
authResponseEcmMock = new EcmAuthMock(ECM_HOST);
Expand All @@ -42,11 +42,14 @@ describe('Auth', () => {
describe('With Authentication', () => {
let alfrescoJsApi: AlfrescoApi;


beforeEach(() => {
alfrescoJsApi = new AlfrescoApi({
hostEcm: ECM_HOST
} as AlfrescoApiConfig);
})

nodesApi = new NodesApi(alfrescoJsApi);
});

describe('login', () => {

Expand Down Expand Up @@ -207,7 +210,8 @@ describe('Auth', () => {

it('should 401 invalidate the ticket', (done) => {
nodeMock.get401CreationFolder();
alfrescoJsApi.nodes.createFolder('newFolder', null, null).then(NOOP, () => {

nodesApi.createFolder('newFolder', null, null).then(NOOP, () => {
expect(alfrescoJsApi.contentAuth.authentications.basicAuth.password).to.be.equal(null);
done();
});
Expand All @@ -217,7 +221,7 @@ describe('Auth', () => {
it('should 401 invalidate the session and logout', (done) => {
nodeMock.get401CreationFolder();

alfrescoJsApi.nodes.createFolder('newFolder', null, null).then(NOOP, () => {
nodesApi.createFolder('newFolder', null, null).then(NOOP, () => {
expect(alfrescoJsApi.isLoggedIn()).to.be.equal(false);
done();
});
Expand All @@ -230,7 +234,7 @@ describe('Auth', () => {

nodeMock.get401CreationFolder();

alfrescoJsApi.nodes.createFolder('newFolder', null, null).then(NOOP);
nodesApi.createFolder('newFolder', null, null).then(NOOP);
});
});

Expand All @@ -241,6 +245,7 @@ describe('Auth', () => {
let profileMock: ProfileMock;
let authResponseBpmMock: BpmAuthMock;
let alfrescoJsApi: AlfrescoApi;
let profileApi: UserProfileApi;

beforeEach(() => {
profileMock = new ProfileMock(BPM_HOST);
Expand All @@ -250,6 +255,8 @@ describe('Auth', () => {
hostBpm: BPM_HOST,
provider: 'BPM'
} as AlfrescoApiConfig);

profileApi = new UserProfileApi(alfrescoJsApi);
});

describe('With Authentication', () => {
Expand Down Expand Up @@ -360,7 +367,7 @@ describe('Auth', () => {
it('should 401 invalidate the ticket', (done) => {
profileMock.get401getProfile();

alfrescoJsApi.activiti.profileApi.getProfile().then(NOOP, () => {
profileApi.getProfile().then(NOOP, () => {
expect(alfrescoJsApi.processAuth.authentications.basicAuth.ticket).to.be.equal(null);
done();
});
Expand All @@ -370,7 +377,7 @@ describe('Auth', () => {
it('should 401 invalidate the session and logout', (done) => {
profileMock.get401getProfile();

alfrescoJsApi.activiti.profileApi.getProfile().then(() => NOOP, () => {
profileApi.getProfile().then(() => NOOP, () => {
expect(alfrescoJsApi.isLoggedIn()).to.be.equal(false);
done();
});
Expand Down
3 changes: 1 addition & 2 deletions test/changeConfig.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
*/

import { expect } from 'chai';
import { AlfrescoApiConfig } from '../src/alfrescoApiConfig';
import { AlfrescoApiCompatibility as AlfrescoApi } from '../src/alfrescoApiCompatibility';
import { AlfrescoApiConfig, AlfrescoApi } from '../index';
import { EcmAuthMock, BpmAuthMock } from '../test/mockObjects';

describe('Change config', () => {
Expand Down
50 changes: 0 additions & 50 deletions test/compatibilityTestApi.spec.ts

This file was deleted.

8 changes: 0 additions & 8 deletions test/mockObjects/base.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,10 @@ export class BaseMock {
this.host = host || 'http://127.0.0.1:8080';
}

get200GenericResponse(scriptSlug: string): void {
nock(this.host, { encodedQueryParams: true }).get(scriptSlug).reply(200);
}

put200GenericResponse(scriptSlug: string): void {
nock(this.host, { encodedQueryParams: true }).put(scriptSlug).reply(200);
}

rec(): void {
nock.recorder.rec();
}

play(): void {
nock.recorder.play();
}
Expand Down
14 changes: 0 additions & 14 deletions test/mockObjects/content-services/groups.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,18 +140,4 @@ export class GroupsMock extends BaseMock {
},
});
}

get401Response(): void {
nock(this.host, { encodedQueryParams: true })
.get('/alfresco/api/-default-/public/alfresco/versions/1/groups')
.reply(401, {
error: {
errorKey: 'framework.exception.ApiDefault',
statusCode: 401,
briefSummary: '05210059 Authentication failed for Web Script org/alfresco/api/ResourceWebScript.get',
stackTrace: 'For security reasons the stack trace is no longer displayed, but the property is kept for previous versions.',
descriptionURL: 'https://api-explorer.alfresco.com',
},
});
}
}
Loading

0 comments on commit 8cc1d4c

Please sign in to comment.