Skip to content
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
Diff view
9 changes: 9 additions & 0 deletions src/connection/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default class Connection {
public readonly http: HttpClient;

constructor(params: ConnectionParams) {
params = this.sanitizeParams(params);
this.http = httpClient(params);
this.gql = gqlClient(params);
this.authEnabled = this.parseAuthParams(params);
Expand All @@ -35,6 +36,14 @@ export default class Connection {
return false;
}

private sanitizeParams(params: ConnectionParams) {
while (params.host.endsWith('/')) {
params.host = params.host.slice(0, -1);
}

return params;
}

post = (path: string, payload: any, expectReturnContent = true) => {
if (this.authEnabled) {
return this.login().then((token) =>
Expand Down
29 changes: 29 additions & 0 deletions src/connection/journey.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,35 @@ import Connection from './index';
import weaviate from '../index';

describe('connection', () => {
it('makes a logged-in request when client host param has trailing slashes', () => {
if (
process.env.WCS_DUMMY_CI_PW == undefined ||
process.env.WCS_DUMMY_CI_PW == ''
) {
console.warn('Skipping because `WCS_DUMMY_CI_PW` is not set');
return;
}

const client = weaviate.client({
scheme: 'http',
host: 'localhost:8085/////',
authClientSecret: new AuthUserPasswordCredentials({
username: 'ms_2d0e007e7136de11d5f29fce7a53dae219a51458@existiert.net',
password: process.env.WCS_DUMMY_CI_PW,
}),
});

return client.misc
.metaGetter()
.do()
.then((res: any) => {
expect(res.version).toBeDefined();
})
.catch((e: any) => {
throw new Error('it should not have errord: ' + e);
});
});

it('makes an Azure logged-in request with client credentials', () => {
if (
process.env.AZURE_CLIENT_SECRET == undefined ||
Expand Down