Skip to content

Commit

Permalink
chore: extract finding ip in method
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterSchafer committed Dec 23, 2022
1 parent 3ea7546 commit 9d20442
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions test/jest/acceptance/https.spec.ts
Expand Up @@ -4,32 +4,34 @@ import { createProjectFromWorkspace } from '../util/createProject';
import { getFixturePath } from '../util/getFixturePath';
import { runSnykCLI } from '../util/runSnykCLI';
import { isCLIV2 } from '../util/isCLIV2';
import * as os from 'os';

jest.setTimeout(1000 * 30);

describe('https', () => {
let server: FakeServer;
let env: Record<string, string>;

beforeAll(async () => {
let ipaddress = '';
const os = require('os');
const interfaces = os.networkInterfaces();
function getFirstIPv4Address(): string {
let ipaddress = '';

for (const groupKey of Object.keys(interfaces)) {
const group = interfaces[groupKey];
const interfaces = os.networkInterfaces();
for (const [, group] of Object.entries(interfaces)) {
if (group) {
for (const inter of group) {
if (
(inter.address != '127.0.0.1' || inter.address != '::1') &&
inter.family == 'IPv4'
) {
if (inter && inter.family == 'IPv4' && inter.address != '127.0.0.1') {
ipaddress = inter.address;
break;
}
}
}
}
return ipaddress;
}

console.log(ipaddress);
describe('https', () => {
let server: FakeServer;
let env: Record<string, string>;

beforeAll(async () => {
const ipaddress = getFirstIPv4Address();
console.log('Using ip: ' + ipaddress);

const port = process.env.PORT || process.env.SNYK_PORT || '12345';
const baseApi = '/api/v1';
Expand Down

0 comments on commit 9d20442

Please sign in to comment.