8000 fix: adjustments in the domain and firewall processing transform config by jcbsfilho · Pull Request #101 · aziontech/lib · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: adjustments in the domain and firewall processing transform config #101

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

Merged
merged 2 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8000
Diff view
8000
Original file line number Diff line number Diff line change
Expand Up @@ -475,11 +475,9 @@ const schemaFirewallManifest = {
errorMessage: "The 'rules' field must be an array of firewall rules.",
},
},
required: ['main_settings'],
additionalProperties: false,
errorMessage: {
additionalProperties: 'No additional properties are allowed in firewall items.',
required: "The 'main_settings' field is required in each firewall item.",
additionalProperties: 'No additional properties are allowed in firewall object.',
},
};

Expand Down Expand Up @@ -797,9 +795,7 @@ const schemaManifest = {
errorMessage: "The 'domains' field must be an array of domain items.",
},
firewall: {
type: 'array',
items: schemaFirewallManifest,
errorMessage: "The 'firewall' field must be an array of firewall items.",
...schemaFirewallManifest,
},
application: {
type: 'array',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,13 @@ class DomainProcessConfigStrategy extends ProcessConfigStrategy {
digitalCertificateId: domain.digital_certificate_id,
edgeApplicationId: domain.edge_application_id,
edgeFirewallId: domain.edge_firewall_id,
mtls: {
verification: domain.mtls_verification,
trustedCaCertificateId: domain.mtls_trusted_ca_certificate_id,
crlList: domain.crl_list,
},
mtls: domain.mtls_verification
? {
verification: domain.mtls_verification,
trustedCaCertificateId: domain.mtls_trusted_ca_certificate_id,
crlList: domain.crl_list,
}
: undefined,
};
return transformedPayload.domain;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ describe('FirewallProcessConfigStrategy', () => {
const manifest = {};
const config = {};
const result = strategy.transformToConfig(manifest, config);
expect(result).toBeUndefined();
expect(result).toStrictEqual(expect.objectContaining({}));
});

it('should transform all behavior types from manifest to config', () => {
Expand Down Expand Up @@ -299,7 +299,8 @@ describe('FirewallProcessConfigStrategy', () => {
};

const config = {};
const result = strategy.transformToConfig(manifest, config);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const result: any = strategy.transformToConfig(manifest, config);
expect(result?.rules?.[0].behavior).toEqual({
runFunction: {
path: '/edge/function.js',
Expand Down Expand Up @@ -336,7 +337,8 @@ describe('FirewallProcessConfigStrategy', () => {
};

const config = {};
const result = strategy.transformToConfig(manifest, config);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const result: any = strategy.transformToConfig(manifest, config);
expect(result?.rules?.[0].behavior).toEqual({});
});

Expand All @@ -360,7 +362,8 @@ describe('FirewallProcessConfigStrategy', () => {
};

const config = {};
const result = strategy.transformToConfig(manifest, config);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const result: any = strategy.transformToConfig(manifest, config);
expect(result?.rules?.[0].behavior).toEqual({});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ class FirewallProcessConfigStrategy extends ProcessConfigStrategy {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
transformToConfig(payload: any, transformedPayload: AzionConfig) {
const firewall = payload.firewall;
if (!firewall) {
return;
if (!firewall || Object.keys(firewall).length === 0) {
return {};
}

const firewallConfig: AzionFirewall = {
Expand Down
0