Skip to content

Commit

Permalink
Merge pull request #90 from boneskull/auth-method
Browse files Browse the repository at this point in the history
remove unused auth-method option
  • Loading branch information
durera committed Aug 3, 2018
2 parents 4489093 + bd24ec4 commit 10eceaf
Show file tree
Hide file tree
Showing 7 changed files with 3 additions and 87 deletions.
8 changes: 3 additions & 5 deletions README.md
Expand Up @@ -82,11 +82,9 @@ configuration JSON containing the following:
- org - Your organization ID
- type - The type of your device
- id - The ID of your device
- auth-method - Method of authentication (the only value currently
supported is “token”)
- auth-token - API key token (required if auth-method is “token”)
- domain - (Optional)The messaging endpoint URL. By default, the value is "internetofthings.ibmcloud.com"(Watson IoT Production server).
- enforce-ws - (Optional)Enforce Websocket when using the library in Node.js
- auth-token - API key token
- domain - (Optional) The messaging endpoint URL. By default, the value is "internetofthings.ibmcloud.com"(Watson IoT Production server).
- enforce-ws - (Optional) Enforce Websocket when using the library in Node.js
- use-client-certs - (Optional) Enforces use of client side certificates when specified as true
- server-ca - (Optional) Specifies the custom server certificate signed using device key
- client-ca - (Mandatory when use-client-certs:true) Specifies the path to device-client CA certificate
Expand Down
10 changes: 0 additions & 10 deletions src/clients/DeviceClient.js
Expand Up @@ -38,16 +38,6 @@ export default class DeviceClient extends BaseClient {
}

if(config.org !== QUICKSTART_ORG_ID){
if(!isDefined(config['auth-method'])){
throw new Error('[DeviceClient:constructor] config must contain auth-method');
}
else if(!isString(config['auth-method'])){
throw new Error('[DeviceClient:constructor] auth-method must be a string');
}
else if(config['auth-method'] !== 'token'){
throw new Error('[DeviceClient:constructor] unsupported authentication method' + config['auth-method']);
}

this.mqttConfig.username = 'use-token-auth';
}

Expand Down
10 changes: 0 additions & 10 deletions src/clients/GatewayClient.js
Expand Up @@ -40,16 +40,6 @@ export default class GatewayClient extends BaseClient {
throw new Error('[GatewayClient:constructor] Quickstart not supported in Gateways');
}

if(!isDefined(config['auth-method'])){
throw new Error('[GatewayClient:constructor] config must contain auth-method');
}
else if(!isString(config['auth-method'])){
throw new Error('[GatewayClient:constructor] auth-method must be a string');
}
else if(config['auth-method'] !== 'token'){
throw new Error('[GatewayClient:constructor] unsupported authentication method' + config['auth-method']);
}

this.mqttConfig.username = 'use-token-auth';

this.org = config.org;
Expand Down
20 changes: 0 additions & 20 deletions test/DeviceClient.spec.js
Expand Up @@ -87,26 +87,6 @@ describe('IotfDevice', () => {
}).to.throw(/config must contain type/);
});

it('should throw an error if auth-method is not present', () => {
expect(() => {
let client = new IBMIoTF.IotfDevice({org:'regorg', id:'123', 'auth-token': '123', 'type': '123'});
}).to.throw(/config must contain auth-method/);
});

it('should throw an error if auth-method is not "token"', () => {
expect(() => {
let client = new IBMIoTF.IotfDevice({org:'regorg', id:'123', 'auth-token': '123', 'type': '123', 'auth-method': 'abc'});
}).to.throw(/unsupported authentication method/);
});

it('should throw an error if auth-method is not "token"', () => {
let client;
expect(() => {
client = new IBMIoTF.IotfDevice({org:'regorg', id:'123', 'auth-token': '123', 'type': '123', 'auth-method': 'token'});
}).not.to.throw();
expect(client).to.be.instanceof(IBMIoTF.IotfDevice);
});

it('should run in registered mode if org is not set to "quickstart"', () => {
let client = new IBMIoTF.IotfDevice({org: 'qs', type: 'mytype', id: '3215', 'auth-method': 'token', 'auth-token': 'abc'});
expect(client.isQuickstart).to.equal(false);
Expand Down
18 changes: 0 additions & 18 deletions test/GatewayClient.spec.js
Expand Up @@ -64,24 +64,6 @@ describe('IotfGateway', () => {
}).to.throw(/type must be a string/);
});

it('should throw an error if auth-method is not present', () => {
expect(() => {
let client = new IBMIoTF.IotfGateway({org:'regorg', id:'123', 'auth-token': '123', 'type': '123'});
}).to.throw(/config must contain auth-method/);
});

it('should throw an error if auth-method is not string', () => {
expect(() => {
let client = new IBMIoTF.IotfGateway({org:'regorg', id:'123', 'auth-token': '123', 'type': '123', 'auth-method': 123});
}).to.throw(/auth-method must be a string/);
});

it('should throw an error if auth-method is not "token"', () => {
expect(() => {
let client = new IBMIoTF.IotfGateway({org:'regorg', id:'123', 'auth-token': '123', 'type': '123', 'auth-method': 'abc'});
}).to.throw(/unsupported authentication method/);
});

it('should throw an error if org is set to quickstart', () => {
expect(() => {
let client = new IBMIoTF.IotfGateway({org:'quickstart', id:'123', 'auth-token': '123', 'type': '123', 'auth-method': 'abc'});
Expand Down
12 changes: 0 additions & 12 deletions test/ManagedDeviceClient.spec.js
Expand Up @@ -54,18 +54,6 @@ describe('IotfManagedDevice', () => {
}).to.throw(/config must contain type/);
});

it('should throw an error if auth-method is not present', () => {
expect(() => {
let client = new IBMIoTF.IotfManagedDevice({org:'regorg', id:'123', 'auth-token': '123', 'type': '123'});
}).to.throw(/config must contain auth-method/);
});

it('should throw an error if auth-method is not "token"', () => {
expect(() => {
let client = new IBMIoTF.IotfManagedDevice({org:'regorg', id:'123', 'auth-token': '123', 'type': '123', 'auth-method': 'abc'});
}).to.throw(/unsupported authentication method/);
});

it('should return an instance if org, id and type are specified', () => {
let client;
expect(() => {
Expand Down
12 changes: 0 additions & 12 deletions test/ManagedGatewayClient.spec.js
Expand Up @@ -54,18 +54,6 @@ describe('IotfManagedGateway', () => {
}).to.throw(/config must contain type/);
});

it('should throw an error if auth-method is not present', () => {
expect(() => {
let client = new IBMIoTF.IotfManagedGateway({org:'regorg', id:'123', 'auth-token': '123', 'type': '123'});
}).to.throw(/config must contain auth-method/);
});

it('should throw an error if auth-method is not "token"', () => {
expect(() => {
let client = new IBMIoTF.IotfManagedGateway({org:'regorg', id:'123', 'auth-token': '123', 'type': '123', 'auth-method': 'abc'});
}).to.throw(/unsupported authentication method/);
});

it('should return an instance if org, id and type are specified', () => {
let client;
expect(() => {
Expand Down

0 comments on commit 10eceaf

Please sign in to comment.