Skip to content

Commit

Permalink
fix: Revert support for the rejectUnauthorized option until issues in #…
Browse files Browse the repository at this point in the history
…377 are sorted.
  • Loading branch information
jdalrymple committed Jul 1, 2019
1 parent 82e96fd commit f9a47c7
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 52 deletions.
16 changes: 6 additions & 10 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
# [7.0.0](https://github.com/jdalrymple/node-gitlab/compare/6.4.0...7.0.0) (2019-06-28)


### Features

* Adding missing endpoints for deploy keys [#373](https://github.com/jdalrymple/node-gitlab/issues/373) ([b23dd29](https://github.com/jdalrymple/node-gitlab/commit/b23dd29))

- Adding missing endpoints for deploy keys [#373](https://github.com/jdalrymple/node-gitlab/issues/373) ([b23dd29](https://github.com/jdalrymple/node-gitlab/commit/b23dd29))

### BREAKING CHANGES

* all method now takes an optional object since projectId is no longer required. If no projectId is passed, the all method returns all deploy keys across all projects of the GitLab instance
- all method now takes an optional object since projectId is no longer required. If no projectId is passed, the all method returns all deploy keys across all projects of the GitLab instance

# [6.4.0](https://github.com/jdalrymple/node-gitlab/compare/6.3.7...6.4.0) (2019-06-28)


### Bug Fixes

* Handle body types properly if not JSON ie formData ([a135841](https://github.com/jdalrymple/node-gitlab/commit/a135841)), closes [#355](https://github.com/jdalrymple/node-gitlab/issues/355)
* Missing headers when posting json data ([861f89e](https://github.com/jdalrymple/node-gitlab/commit/861f89e))
* Use the correct agent configuration for the rejectUnauthorized option ([775d755](https://github.com/jdalrymple/node-gitlab/commit/775d755)), closes [#357](https://github.com/jdalrymple/node-gitlab/issues/357)

- Handle body types properly if not JSON ie formData ([a135841](https://github.com/jdalrymple/node-gitlab/commit/a135841)), closes [#355](https://github.com/jdalrymple/node-gitlab/issues/355)
- Missing headers when posting json data ([861f89e](https://github.com/jdalrymple/node-gitlab/commit/861f89e))
- Use the correct agent configuration for the rejectUnauthorized option ([775d755](https://github.com/jdalrymple/node-gitlab/commit/775d755)), closes [#357](https://github.com/jdalrymple/node-gitlab/issues/357)

### Features

* Adding support for Group Issues ([00068c9](https://github.com/jdalrymple/node-gitlab/commit/00068c9)), closes [#306](https://github.com/jdalrymple/node-gitlab/issues/306)
- Adding support for Group Issues ([00068c9](https://github.com/jdalrymple/node-gitlab/commit/00068c9)), closes [#306](https://github.com/jdalrymple/node-gitlab/issues/306)

## [6.3.7](https://github.com/jdalrymple/node-gitlab/compare/6.3.6...6.3.7) (2019-06-12)

Expand Down
59 changes: 32 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,23 +158,29 @@ import { Projects } from 'gitlab'; // Just the Project Resource
const { Gitlab } = require('gitlab');
```

Instatiating options:
Basic Example

```javascript
const api = new Gitlab({
host: 'http://gl.com', //Optional, Default: https://gitlab.com
token: 'personaltoken', //Personal Token. Required (one of the three tokens are required)
oauthToken: 'oauthtoken', //OAuth Token. Required (one of the three tokens are required)
jobToken: 'myJobToken', //CI job token. Required (one of the three tokens are required)
rejectUnauthorized: false //Http Certificate setting. Optional, Default: false
sudo: false //Sudo query parameter. Optional, Default: false
version = 'v4', //API Version ID. Optional, Default: v4
camelize = false, //Response Key Camelize. Camelizes all response body keys. Optional, Default: false
requester = KyRequester, //Request Library Wrapper. Optional, Default: Currently wraps Ky.
requestTimeout = 300000 //Request Library Timeout. Optional, Default: 300,000 milliseconds.
token: 'personaltoken',
});
```

Available instatiating options:

| Name | Optional | Default | Description |
| -------------------- | -------- | ----------------------------------------------------- | --------------------------------------------------------------- |
| `host` | Yes | `https://gitlab.com` | Gitlab Instance Host URL |
| `token` | No\* | N/A | Personal Token. Required (one of the three tokens are required) |
| `oauthToken` | No\* | N/A | OAuth Token. Required (one of the three tokens are required) |
| `jobToken` | No\* | N/A | CI Job Token. Required (one of the three tokens are required) |
| `rejectUnauthorized` | Yes | `false` | Http Certificate setting |
| `sudo` | Yes | `false` | Sudo query parameter |
| `version` | Yes | `v4` | API Version ID |
| `camelize` | Yes | `false` | Response Key Camelize. Camelizes all response body keys |
| `requester` | Yes | [KyRequester.ts](./src/infrastructure/KyRequester.ts) | Request Library Wrapper. Currently wraps Ky. |
| `requestTimeout` | Yes | `300000` | Request Library Timeout in ms |

#### Bundle Imports

It can be annoying to have to import all the API's pertaining to a specific resource. For example, the Projects resource is composed of many API's, Projects, Issues, Labels, MergeRequests, etc. For convenience, there is a Bundle export for importing and instantiating all these related API's at once.
Expand All @@ -183,8 +189,8 @@ It can be annoying to have to import all the API's pertaining to a specific reso
import { ProjectsBundle } from 'gitlab';

const services = new ProjectsBundle({
host: 'http://example.com', // Defaults to https://gitlab.com
token: 'abcdefghij123456' // Can be created in your profile.
host: 'http://example.com',
token: 'abcdefghij123456'
})

services.Projects.all()
Expand Down Expand Up @@ -303,8 +309,8 @@ Using the await/async method
import { Gitlab } from 'gitlab';

const api = new Gitlab({
host: 'http://example.com', // Defaults to https://gitlab.com
token: 'abcdefghij123456', // Can be created in your profile.
host: 'http://example.com',
token: 'abcdefghij123456',
});

// Listing users
Expand All @@ -327,8 +333,8 @@ ie.
import { Gitlab } from 'gitlab';

const api = new Gitlab({
host: 'http://example.com', // Defaults to https://gitlab.com
token: 'abcdefghij123456', // Can be created in your profile.
host: 'http://example.com',
token: 'abcdefghij123456',
});

api.Projects.create(projectId, {
Expand All @@ -344,8 +350,8 @@ For any .all() function on a resource, it will return all the items from Gitlab.
import { Gitlab } from 'gitlab';

const api = new Gitlab({
host: 'http://example.com', // Defaults to https://gitlab.com
token: 'abcdefghij123456', // Can be created in your profile.
host: 'http://example.com',
token: 'abcdefghij123456',
});

let projects = await api.Projects.all({ maxPages: 2 });
Expand All @@ -357,8 +363,8 @@ You can also use this in conjunction to the perPage argument which would overrid
import { Gitlab } from 'gitlab';

const api = new Gitlab({
host: 'http://example.com', // Defaults to https://gitlab.com
token: 'abcdefghij123456', // Can be created in your profile.
host: 'http://example.com',
token: 'abcdefghij123456',
});

let projects = await api.Projects.all({ maxPages: 2, perPage: 40 });
Expand Down Expand Up @@ -405,8 +411,8 @@ For example, if you want to disable notifications for a specific user:
import { NotificationSettings } from 'gitlab';

const service = new NotificationSettings({
host: 'http://example.com', // Defaults to https://gitlab.com
token: 'abcdefghij123456' // Can be created in your profile.
host: 'http://example.com',
token: 'abcdefghij123456'
sudo: 8 // Can be the user ID or a username
});

Expand All @@ -428,11 +434,10 @@ import { Gitlab } from 'gitlab';
import YourCustomRequester from 'custom-requester';

const api = new Gitlab({
host: 'http://example.com', // Defaults to https://gitlab.com
token: 'abcdefghij123456' // Can be created in your profile.
requester: YourCustomRequester
host: 'http://example.com',
token: 'abcdefghij123456',
requester: YourCustomRequester,
});

```

## Docs
Expand Down
9 changes: 0 additions & 9 deletions src/infrastructure/KyRequester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { decamelizeKeys } from 'humps';
import { stringify } from 'query-string';
import { skipAllCaps } from './Utils';
import { Requester } from '.';
import { Agent } from 'https';

const methods = ['get', 'post', 'put', 'delete', 'stream'];
const KyRequester = {} as Requester;
Expand All @@ -23,7 +22,6 @@ function responseHeadersAsObject(response) {
function defaultRequest(service: any, { body, query, sudo, method }) {
const headers = new Headers(service.headers);
let bod = body;
let agent;

if (sudo) headers.append('sudo', `${sudo}`);

Expand All @@ -32,12 +30,6 @@ function defaultRequest(service: any, { body, query, sudo, method }) {
headers.append('content-type', 'application/json');
}

if (service.rejectUnauthorized) {
agent = new Agent({
rejectUnauthorized: service.rejectUnauthorized,
});
}

return {
timeout: service.requestTimeout,
headers,
Expand All @@ -46,7 +38,6 @@ function defaultRequest(service: any, { body, query, sudo, method }) {
searchParams: stringify(decamelizeKeys(query || {}) as any, { arrayFormat: 'bracket' }),
prefixUrl: service.url,
body: bod,
agent,
};
}

Expand Down
1 change: 0 additions & 1 deletion test/integration/bundles/ProjectsBundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { ProjectsBundle } from '../../../src';
const config = {
host: process.env.GITLAB_URL,
token: process.env.PERSONAL_ACCESS_TOKEN,
rejectUnauthorized: false, // Testing with localhost
};
let project;
let api;
Expand Down
1 change: 0 additions & 1 deletion test/integration/services/ApplicationSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ beforeAll(async () => {
service = new ApplicationSettings({
host: process.env.GITLAB_URL,
token: process.env.PERSONAL_ACCESS_TOKEN,
rejectUnauthorized: false, // Testing with localhost
});
});

Expand Down
1 change: 0 additions & 1 deletion test/integration/services/Issues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Issues, Projects } from '../../../src';
const config = {
host: process.env.GITLAB_URL,
token: process.env.PERSONAL_ACCESS_TOKEN,
rejectUnauthorized: false, // Testing with localhost
};
let project;
let service: Issues;
Expand Down
1 change: 0 additions & 1 deletion test/integration/services/Projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ beforeEach(() => {
service = new Projects({
host: process.env.GITLAB_URL,
token: process.env.PERSONAL_ACCESS_TOKEN,
rejectUnauthorized: false, // Testing with localhost
});
});

Expand Down
1 change: 0 additions & 1 deletion test/integration/services/PushRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ describe('PushRule.edit', () => {
const service = new PushRule({
host: process.env.GITLAB_URL,
token: process.env.PERSONAL_ACCESS_TOKEN,
rejectUnauthorized: false, // Testing with localhost
});

const result = await service.edit(1, {
Expand Down
1 change: 0 additions & 1 deletion test/integration/services/Snippets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ beforeEach(() => {
service = new Snippets({
host: process.env.GITLAB_URL,
token: process.env.PERSONAL_ACCESS_TOKEN,
rejectUnauthorized: false, // Testing with localhost
});
});

Expand Down

0 comments on commit f9a47c7

Please sign in to comment.