Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
coutoPL committed Sep 28, 2024
1 parent 35d421b commit 16e652e
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 68 deletions.
40 changes: 20 additions & 20 deletions e2e-tests/cypress/e2e/Direct-kibana-request.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ describe('Direct kibana request', () => {
rorApiClient.configureRorIndexMainSettings("defaultSettings.yaml")
});

afterEach(() => {
const clearDirectKibanaRequestState = () => {
kbnApiAdvancedClient.deleteSavedObjects(user1);
kbnApiAdvancedClient.deleteSavedObjects(admin);
if (semver.gte(getKibanaVersion(), '8.0.0')) {
kbnApiAdvancedClient.deleteDataViews(user1);
kbnApiAdvancedClient.deleteDataViews(admin);
}
};
// afterEach(() => {
// const clearDirectKibanaRequestState = () => {
// kbnApiAdvancedClient.deleteSavedObjects(user1);
// kbnApiAdvancedClient.deleteSavedObjects(admin);
// if (semver.gte(getKibanaVersion(), '8.0.0')) {
// kbnApiAdvancedClient.deleteDataViews(user1);
// kbnApiAdvancedClient.deleteDataViews(admin);
// }
// };

clearDirectKibanaRequestState();
rorApiClient.configureRorIndexMainSettings("defaultSettings.yaml")
});
// clearDirectKibanaRequestState();
// rorApiClient.configureRorIndexMainSettings("defaultSettings.yaml")
// });

it('should check direct kibana request', () => {
const verifySavedObjects = () => {
Expand All @@ -48,23 +48,23 @@ describe('Direct kibana request', () => {

cy.log('Get imported saved objects for user1 Administrators group');
kbnApiAdvancedClient.getSavedObjects(user1).then(result => {
expect(result.saved_objects[0].id).equal('my-pattern');
expect(result.saved_objects[1].id).equal('my-dashboard');
expect(result.saved_objects).to.have.length(2);
expect(result.saved_objects[1].id).equal('my-pattern');
expect(result.saved_objects[2].id).equal('my-dashboard');
expect(result.saved_objects).to.have.length(3);
})

cy.log('Get imported saved objects for admin Administrators group');
kbnApiAdvancedClient
.getSavedObjects(admin)
kbnApiAdvancedClient.getSavedObjects(admin)
.then(result => {
expect(result.saved_objects[0].id).equal('my-pattern');
expect(result.saved_objects[1].id).equal('my-dashboard');
expect(result.saved_objects).to.have.length(2);
expect(result.saved_objects[1].id).equal('my-pattern');
expect(result.saved_objects[2].id).equal('my-dashboard');
expect(result.saved_objects).to.have.length(3);
});

cy.log('Get imported saved objects for user1 infosec group');
kbnApiAdvancedClient.getSavedObjects(user1, "infosec_group")
.then(result => {
debugger;
const actual = result.saved_objects.some(
saved_object => saved_object.id === 'my-pattern' || saved_object.id === 'my-dashboard'
);
Expand Down
9 changes: 4 additions & 5 deletions e2e-tests/cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ function call(method: string, url: string, credentials: string, payload?: Cypres
authorization: `Basic ${btoa(credentials)}`,
...headers
},
body: payload || null
body: payload || null,
}).then((response) => {
expect(response.status).to.be.within(200, 299);

console.log(`RR: ${method} ${url} ${credentials} ${JSON.stringify(headers)} = ${JSON.stringify(response)}`)
// expect(response.status).to.be.within(200, 299);
return isJsonString(response.body) ? JSON.parse(response.body) : response.body;
})
}
Expand All @@ -130,10 +130,9 @@ function uploadFile(url: string, credentials: string, fixtureFilename: string, h
const formData = new FormData();
formData.append('file', Cypress.Blob.base64StringToBlob(fileContent, 'application/octet-stream'), fixtureFilename);

// Prepare headers
const requestHeaders = {
authorization: `Basic ${btoa(credentials)}`,
...(headers || {}) // Spread additional headers directly into requestHeaders
...(headers || {})
};

cy.request({
Expand Down
2 changes: 1 addition & 1 deletion e2e-tests/cypress/support/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace Cypress {
export interface Chainable<Subject> {
kbnRequest({ method, endpoint, payload, currentGroupHeader }: { method: string, endpoint: string, credentials: string, payload?: RequestBody, currentGroupHeader?: string }): Chainable<Subject>;
kbnRequest({ method, endpoint, credentials, payload, currentGroupHeader }: { method: string, endpoint: string, credentials: string, payload?: RequestBody, currentGroupHeader?: string }): Chainable<Subject>;
kbnGet({ endpoint, credentials, currentGroupHeader }: { endpoint: string, credentials: string, currentGroupHeader?: string }): Chainable<Subject>;
kbnPost({ endpoint, credentials, payload, currentGroupHeader }: { endpoint: string, credentials: string, payload?: RequestBody, currentGroupHeader?: string }): Chainable<Subject>;
kbnPut({ endpoint, credentials, payload }: { endpoint: string, credentials: string, payload?: RequestBody }): Chainable<Subject>;
Expand Down
2 changes: 1 addition & 1 deletion e2e-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"license": "Beshu Limited, All rights reserved",
"dependencies": {
"@testing-library/cypress": "^10.0.1",
"cypress": "13.14.2",
"cypress": "13.15.0",
"js-yaml": "^4.1.0",
"semver": "7.5.2"
},
Expand Down
12 changes: 6 additions & 6 deletions e2e-tests/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
dependencies:
regenerator-runtime "^0.13.4"

"@cypress/request@^3.0.1":
"@cypress/request@^3.0.4":
version "3.0.5"
resolved "https://registry.yarnpkg.com/@cypress/request/-/request-3.0.5.tgz#d893a6e68ce2636c085fcd8d7283c3186499ba63"
integrity sha512-v+XHd9XmWbufxF1/bTaVm2yhbxY+TB4YtWRqF2zaXBlDNMkls34KiATz0AVDLavL3iB6bQk9/7n3oY1EoLSWGA==
Expand Down Expand Up @@ -736,12 +736,12 @@ cross-spawn@^7.0.0, cross-spawn@^7.0.2:
shebang-command "^2.0.0"
which "^2.0.1"

cypress@13.14.2:
version "13.14.2"
resolved "https://registry.yarnpkg.com/cypress/-/cypress-13.14.2.tgz#4237eb7b26de2baeaa1f01e585f965d88fca7f39"
integrity sha512-lsiQrN17vHMB2fnvxIrKLAjOr9bPwsNbPZNrWf99s4u+DVmCY6U+w7O3GGG9FvP4EUVYaDu+guWeNLiUzBrqvA==
cypress@13.15.0:
version "13.15.0"
resolved "https://registry.yarnpkg.com/cypress/-/cypress-13.15.0.tgz#5eca5387ef34b2e611cfa291967c69c2cd39381d"
integrity sha512-53aO7PwOfi604qzOkCSzNlWquCynLlKE/rmmpSPcziRH6LNfaDUAklQT6WJIsD8ywxlIy+uVZsnTMCCQVd2kTw==
dependencies:
"@cypress/request" "^3.0.1"
"@cypress/request" "^3.0.4"
"@cypress/xvfb" "^1.2.4"
"@types/sinonjs__fake-timers" "8.1.1"
"@types/sizzle" "^2.3.2"
Expand Down
51 changes: 19 additions & 32 deletions elk-ror/conf/kbn/kbn-proxy-nginx.conf
Original file line number Diff line number Diff line change
@@ -1,40 +1,27 @@
events { }

http {
# Upstream Kibana configuration
upstream kbn-ror {
server kbn-ror:5601;
}

# Server block for handling HTTPS
server {
listen 443 ssl;

# Path to your SSL certificate and key (these should be valid for your domain)
ssl_certificate /etc/nginx/kibana/kibana.crt;
ssl_certificate_key /etc/nginx/kibana/kibana.key;
upstream kbn-ror {
server kbn-ror:5601;
}

server {
listen 443 ssl;
server_name localhost;

# Optional: Use a stronger set of SSL parameters
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;

# Proxy settings to forward to Kibana over HTTPS
location / {
proxy_pass https://kbn-ror; # Note the 'https'
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_ssl_verify off; # Disable SSL verification for internal requests (only if Kibana uses self-signed certs)
}
}
ssl_certificate /etc/nginx/kibana/kibana.crt;
ssl_certificate_key /etc/nginx/kibana/kibana.key;

# Redirect HTTP requests to HTTPS (optional but recommended)
server {
listen 80;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;

location / {
return 301 https://$host$request_uri;
}
location / {
proxy_pass https://kbn-ror;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_ssl_verify off; # Disable SSL verification for internal requests (only if Kibana uses self-signed certs)
}
}
}
4 changes: 2 additions & 2 deletions elk-ror/conf/kbn/kibana.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
server.name: "kibana-ror-${HOSTNAME}"
server.host: 0.0.0.0
server.port: 5601
server.publicBaseUrl: "http://localhost:5601"

# csp needs to be disabled to let cypress e2e tests works
csp.strict: false
Expand All @@ -27,6 +28,5 @@ telemetry.enabled: false

readonlyrest_kbn:
cookiePass: '12312313123213123213123adadasdasdasd'
logLevel: info

logLevel: trace
store_sessions_in_index: true
4 changes: 3 additions & 1 deletion elk-ror/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,12 @@ services:
condition: service_healthy
deploy:
mode: replicated
replicas: 3
replicas: 1
resources:
limits:
memory: 756G
ports:
- "15601:5601"
environment:
ELASTIC_USER_PASSWORD: elastic
ES_API_URL: https://es-ror:9200
Expand Down

0 comments on commit 16e652e

Please sign in to comment.