@apistudio/apim-cli
Version:
CLI for API Management Products
586 lines (507 loc) • 26.6 kB
text/typescript
import { AssetValidator } from '../../src/service/validation-service.js';
import path from 'path';
import fs from 'fs';
import yaml from 'js-yaml';
import { YamlContent } from '../../src/model/interface.js';
jest.mock('@apic/studio-logger', () => ({
LoggerConfig: {
isLoggerEnabled: jest.fn(),
},
}));
jest.mock('../../src/service/log-wrapper.ts');
describe('Asset Validate', () => {
let assetValidator: AssetValidator;
beforeEach(() => {
assetValidator = new AssetValidator();
});
it('Test to validate the invalid Api Asset', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/invalidapi.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(false);
});
it('Test to validate the valid Tuple Asset', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/tuple.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(true);
});
it('Test to validate the invalid Scope Asset', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/invalidscope.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(false);
});
it('Test to validate the invalid Scope Asset - no path', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/invalidscope2.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(false);
});
// it('Test to validate the invalid Policy seq Asset', async () => {
// const assetPath = path.resolve(__dirname, '../assets/validate/invalid_policyseq.yaml');
// const buffer = fs.readFileSync(assetPath);
// const genObj = yaml.load(buffer.toString()) as YamlContent;
// const isValid = await assetValidator.validateAssets(genObj);
// expect(isValid).toBe(false);
// });
it('Test to validate the invalid Global Policy Asset', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/invalid_globalpolicy.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(false);
});
it('Test to validate the invalid Transport Policy Asset', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/invalid_transport.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(false);
});
it('Test to validate the invalid SetMediaType Policy Asset', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/invalid_setMediaType.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(false);
});
it('Test to validate the invalid Route Policy Asset', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/invalid_route.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(false);
});
it('Test to validate the invalid CustomHttpHeader Policy Asset', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/invalid_customHttpHeader.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(false);
});
it('Test to validate the invalid CustomHttpHeader Policy Asset - no value ', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/invalid_customHttpHeader3.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(false);
});
it('Test to validate the invalid CustomHttpHeader Policy Asset - no key', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/invalid_customHttpHeader2.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(false);
});
it('Test to validate the invalid SetContextVariable Asset', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/invalid_setContextVariable.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(false);
});
it('Test to validate the invalid SetContextVariable Asset - no variable name', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/invalid_setContextVariable2.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(false);
});
it('Test to validate the invalid IAM Asset', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/invalid_iam.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(false);
});
it('Test to validate the invalid IAM Asset - no condition', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/invalid_iam2.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(false);
});
it('Test to validate the invalid IAM Asset - both conditions', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/invalid_iam3.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(false);
});
it('Test to validate the invalid IAM Asset - no auth type in or', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/invalid_iam4.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(false);
});
it('Test to validate the invalid IAM Asset - no auth type in and', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/invalid_iam5.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(false);
});
it('Test to validate the invalid DataMasking Asset', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/invalid_datamasking.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(false);
});
it('Test to validate the invalid WebMethodsISService Asset - no name in service', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/invalid_wmisservice2.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(false);
});
it('Test to validate the invalid OutboundBasicAuth Asset', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/invalid_outboundbasicauth.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(false);
});
it('Test to validate the invalid OutboundBasicAuth Asset - Both Auth methods', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/invalid_outboundbasicauth2.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(false);
});
it('Test to validate the invalid OutboundBasicAuth Asset - Custom no usename/password', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/invalid_outboundbasicauth3.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(false);
});
it('Test to validate the invalid OutboundNTLMAuth Asset', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/invalid_outboundntlm.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(false);
});
it('Test to validate the invalid OutboundKerberos Asset - invalid UseIncomingHttpCred', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/invalid_outboundkerberos2.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(false);
});
it('Test to validate the invalid OutboundKerberos Asset - invalid useCustomCred', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/invalid_outboundkerberos3.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(false);
});
it('Test to validate the invalid OutboundKerberos Asset - invalid useDelegateIncomingCred', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/invalid_outboundkerberos4.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(false);
});
it('Test to validate the invalid OutboundOAuth2 Asset', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/invalid_outboundoauth.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(false);
});
it('Test to validate the invalid OutboundOAuth2 Asset - Multiple auth methods', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/invalid_outboundoauth2.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(false);
});
it('Test to validate the invalid OutboundOAuth2 Asset - No token specified', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/invalid_outboundoauth3.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(false);
});
it('Test to validate the invalid AuthorizeUser Asset', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/invalid_authorizeUser.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(false);
});
it('Test to validate the invalid InboundBulkHead Asset', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/invalid_inboundBulkHead.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(false);
});
it('Test to validate the invalid InboundBulkHead Asset - 2', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/invalid_inboundBulkHead2.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(false);
});
it('Test to validate the invalid InboundBulkHead Asset - 3', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/invalid_inboundBulkHead3.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(false);
});
it('Test to validate the invalid InboundMessaging Asset', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/invalid_inboundMessaging.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(false);
});
it('Test to validate the invalid InboundMessaging Asset 2', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/invalid_inboundMessaging2.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(false);
});
it('Test to validate the invalid InboundMessaging Asset 3', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/invalid_inboundMessaging3.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(false);
});
it('Test to validate the invalid MessageConfig Asset', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/invalid_messageConfig.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(false);
});
it('Test to validate the valid transport policy Asset', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/transport.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(true);
});
it('Test to validate the valid setMediaType policy Asset', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/setMediaType.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(true);
});
it('Test to validate the valid route Asset', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/route.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(true);
});
it('Test to validate the valid CustomHttpHeader Policy Asset', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/customHttpHeader.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(true);
});
it('Test to validate the valid Policy seq Asset', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/policyseq.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(true);
});
it('Test to validate the valid Global Policy Asset', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/globalpolicy.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(true);
});
it('Test to validate the valid scope Asset', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/scope.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(true);
});
it('Test to validate the valid Api Asset', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/api.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(true);
});
it('Test to validate the invalid Tuple Asset', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/invalid_tuple.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(false);
});
it('Test to validate the valid SetContextVariable Asset', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/setcontextvariable.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(true);
});
it('Test to validate the valid IAM Asset', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/iam.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(true);
});
it('Test to validate the valid DataMasking Asset', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/datamasking.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(true);
});
it('Test to validate the valid WebMethodsISService Asset', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/wmisservice.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(true);
});
it('Test to validate the valid OutboundAlias Asset', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/outboundalias.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(true);
});
it('Test to validate the valid OutboundAnonymous Asset', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/outboundanonymous.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(true);
});
it('Test to validate the valid OutboundBasicAuth Asset', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/outboundbasicauth.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(true);
});
it('Test to validate the valid OutboundIncomingJWT Asset', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/outboundincjwt.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(true);
});
it('Test to validate the valid OutboundKerberosAuth Asset', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/outboundkerberos.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(true);
});
it('Test to validate the valid OutboundKerberosAuth Asset - UseCustomCredentials', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/outboundkerberos3.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(true);
});
it('Test to validate the valid OutboundKerberosAuth Asset - UseDelegateIncomingCredentials', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/outboundkerberos2.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(true);
});
it('Test to validate the valid OutboundKerberosAuth Asset - UseHttpIncomingCredentials', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/outboundkerberos4.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(true);
});
it('Test to validate the valid OutboundNTLMAuth Asset', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/outboundntlm.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(true);
});
it('Test to validate the valid OutboundNTLMAuth Asset 2', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/outboundnltm2.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(true);
});
it('Test to validate the valid OutboundOAuth2 Asset', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/outboundoauth.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(true);
});
it('Test to validate the valid AuthorizeUser Asset', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/authorizeUser.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(true);
});
it('Test to validate the valid InboundBulkHead Asset', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/inboundBulkHead.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(true);
});
it('Test to validate the valid InboundMessaging Asset', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/inboundMessaging.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(true);
});
it('Test to validate the valid MessageConfig Asset', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/messageConfig.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(true);
});
it('Test to validate the valid Plan Asset', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/plan.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(true);
});
it('Test to validate the valid Package Asset', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/package.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(true);
})
it('Test to validate the valid RequestLimit Asset', async () => {
const assetPath = path.resolve(__dirname, '../assets/validate/requestLimit.yaml');
const buffer = fs.readFileSync(assetPath);
const genObj = yaml.load(buffer.toString()) as YamlContent;
const isValid = await assetValidator.validateAssets(genObj);
expect(isValid).toBe(true);
})
});