qubitro-mqtt 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 65a25771b798460c0e6bb0139e663b03b25b70e3523571c99d3dfc321c9946d9
4
- data.tar.gz: aa84a5c562e2982ed348c0495ade1740a365defdbad831dde547b2e1a28086c2
3
+ metadata.gz: 7e45bcfabd6e2367a012443f034589db3f5b2c77c3c094194b9c5f40fbde2ffd
4
+ data.tar.gz: 033462023ec38750bef3e354254ac9695a6fa4498aca320792e8669a8ece2dd3
5
5
  SHA512:
6
- metadata.gz: ab8f325bcbf975c8bc14c42437dced1b3527434148d7e62c99715a5c3dd69b83c226ba5bd694b22c983e18a63ad927340e28192288ecec5de090c3dba5ed6564
7
- data.tar.gz: bf49a922afd337facc796c78fdf6a1aec8f7aebd02a0289e6728d23449684372634abba2e7604af22d31f062708dcc8e1bd0f3c897c6d51220ab6d6741cac722
6
+ metadata.gz: b214109e69f71238e59479e284b09bf49cffaca0ec9b47555f5d37c0d69455395782a758518783119ca7063f53c79afa38d134db8da12507a46b5088d46db5f8
7
+ data.tar.gz: 66fade5d90ac5c4fc5575da1957778a0589364aa3d57af3ed051cc7f60b903d702c6d5c88cd2fa39ab0c48c85c3660dd01c3f846f0e6d2254da828118b3b0e98
@@ -35,11 +35,11 @@ module MQTT
35
35
  # Number of seconds to wait for acknowledgement packets (default is 5 seconds)
36
36
  attr_accessor :ack_timeout
37
37
 
38
- # Username to authenticate to the server with
39
- attr_accessor :username
38
+ # Device ID to authenticate to the server with
39
+ attr_accessor :deviceId
40
40
 
41
- # Password to authenticate to the server with
42
- attr_accessor :password
41
+ # Device Token to authenticate to the server with
42
+ attr_accessor :deviceToken
43
43
 
44
44
  # The topic that the Will message is published to
45
45
  attr_accessor :will_topic
@@ -68,8 +68,8 @@ module MQTT
68
68
  :clean_session => true,
69
69
  :client_id => nil,
70
70
  :ack_timeout => 5,
71
- :username => nil,
72
- :password => nil,
71
+ :deviceId => nil,
72
+ :deviceToken => nil,
73
73
  :will_topic => nil,
74
74
  :will_payload => nil,
75
75
  :will_qos => 0,
@@ -252,8 +252,8 @@ module MQTT
252
252
  :clean_session => @clean_session,
253
253
  :keep_alive => @keep_alive,
254
254
  :client_id => @client_id,
255
- :username => @username,
256
- :password => @password,
255
+ :deviceId => @deviceId,
256
+ :deviceToken => @deviceToken,
257
257
  :will_topic => @will_topic,
258
258
  :will_payload => @will_payload,
259
259
  :will_qos => @will_qos,
@@ -579,8 +579,8 @@ module MQTT
579
579
  {
580
580
  :host => uri.host,
581
581
  :port => uri.port || nil,
582
- :username => uri.user ? URI.unescape(uri.user) : nil,
583
- :password => uri.password ? URI.unescape(uri.password) : nil,
582
+ :deviceId => uri.user ? URI.unescape(uri.user) : nil,
583
+ :deviceToken => uri.password ? URI.unescape(uri.password) : nil,
584
584
  :ssl => ssl
585
585
  }
586
586
  end
@@ -422,11 +422,11 @@ module MQTT
422
422
  # The payload of the Will message
423
423
  attr_accessor :will_payload
424
424
 
425
- # The username for authenticating with the server
426
- attr_accessor :username
425
+ # The deviceId for authenticating with the server
426
+ attr_accessor :deviceId
427
427
 
428
- # The password for authenticating with the server
429
- attr_accessor :password
428
+ # The deviceToken for authenticating with the server
429
+ attr_accessor :deviceToken
430
430
 
431
431
  # Default attribute values
432
432
  ATTR_DEFAULTS = {
@@ -438,8 +438,8 @@ module MQTT
438
438
  :ack_timeout => 15,
439
439
  :will_retain => false,
440
440
  :will_payload => '',
441
- :username => nil,
442
- :password => nil
441
+ :deviceId => nil,
442
+ :deviceToken => nil
443
443
  }
444
444
 
445
445
  # Create a new Client Connect packet
@@ -479,8 +479,8 @@ module MQTT
479
479
  @connect_flags |= 0x04 unless @will_topic.nil?
480
480
  @connect_flags |= ((@will_qos & 0x03) << 3)
481
481
  @connect_flags |= 0x20 if @will_retain
482
- @connect_flags |= 0x40 unless @password.nil?
483
- @connect_flags |= 0x80 unless @username.nil?
482
+ @connect_flags |= 0x40 unless @deviceToken.nil?
483
+ @connect_flags |= 0x80 unless @deviceId.nil?
484
484
  body += encode_bytes(@connect_flags)
485
485
 
486
486
  body += encode_short(@keep_alive)
@@ -490,8 +490,8 @@ module MQTT
490
490
  # The MQTT v3.1 specification says that the payload is a UTF-8 string
491
491
  body += encode_string(@will_payload)
492
492
  end
493
- body += encode_string(@username) unless @username.nil?
494
- body += encode_string(@password) unless @password.nil?
493
+ body += encode_string(@deviceId) unless @deviceId.nil?
494
+ body += encode_string(@deviceToken) unless @deviceToken.nil?
495
495
  body
496
496
  end
497
497
 
@@ -521,10 +521,10 @@ module MQTT
521
521
  @will_payload = shift_string(buffer)
522
522
  end
523
523
  if ((@connect_flags & 0x80) >> 7) == 0x01 && buffer.bytesize > 0
524
- @username = shift_string(buffer)
524
+ @deviceId = shift_string(buffer)
525
525
  end
526
526
  if ((@connect_flags & 0x40) >> 6) == 0x01 && buffer.bytesize > 0 # rubocop: disable Style/GuardClause
527
- @password = shift_string(buffer)
527
+ @deviceToken = shift_string(buffer)
528
528
  end
529
529
  end
530
530
 
@@ -534,8 +534,8 @@ module MQTT
534
534
  "keep_alive=#{keep_alive}"
535
535
  str += ', clean' if clean_session
536
536
  str += ", client_id='#{client_id}'"
537
- str += ", username='#{username}'" unless username.nil?
538
- str += ', password=...' unless password.nil?
537
+ str += ", deviceId='#{deviceId}'" unless deviceId.nil?
538
+ str += ', deviceToken=...' unless deviceToken.nil?
539
539
  str + '>'
540
540
  end
541
541
 
@@ -1,5 +1,5 @@
1
1
  module MQTT
2
2
  # The version number of the MQTT gem
3
- VERSION = '0.0.6'
3
+ VERSION = '0.0.7'
4
4
  end
5
5
 
@@ -109,28 +109,28 @@ describe MQTT::Client do
109
109
  expect(client.ssl).to be_truthy
110
110
  end
111
111
 
112
- it "with a URI containing a username and password" do
112
+ it "with a URI containing a deviceId and deviceToken" do
113
113
  client = MQTT::Client.new(URI.parse('mqtt://auser:bpass@mqtt.example.com'))
114
114
  expect(client.host).to eq('mqtt.example.com')
115
115
  expect(client.port).to eq(1883)
116
- expect(client.username).to eq('auser')
117
- expect(client.password).to eq('bpass')
116
+ expect(client.deviceId).to eq('auser')
117
+ expect(client.deviceToken).to eq('bpass')
118
118
  end
119
119
 
120
- it "with a URI containing an escaped username and password" do
120
+ it "with a URI containing an escaped deviceId and deviceToken" do
121
121
  client = MQTT::Client.new(URI.parse('mqtt://foo%20bar:%40123%2B%25@mqtt.example.com'))
122
122
  expect(client.host).to eq('mqtt.example.com')
123
123
  expect(client.port).to eq(1883)
124
- expect(client.username).to eq('foo bar')
125
- expect(client.password).to eq('@123+%')
124
+ expect(client.deviceId).to eq('foo bar')
125
+ expect(client.deviceToken).to eq('@123+%')
126
126
  end
127
127
 
128
- it "with a URI containing a double escaped username and password" do
128
+ it "with a URI containing a double escaped deviceId and deviceToken" do
129
129
  client = MQTT::Client.new(URI.parse('mqtt://foo%2520bar:123%2525@mqtt.example.com'))
130
130
  expect(client.host).to eq('mqtt.example.com')
131
131
  expect(client.port).to eq(1883)
132
- expect(client.username).to eq('foo%20bar')
133
- expect(client.password).to eq('123%25')
132
+ expect(client.deviceId).to eq('foo%20bar')
133
+ expect(client.deviceToken).to eq('123%25')
134
134
  end
135
135
 
136
136
  it "with a URI as a string" do
@@ -334,17 +334,17 @@ describe MQTT::Client do
334
334
  client.connect('myclient')
335
335
  end
336
336
 
337
- it "should include the username and password for an authenticated connection" do
338
- client.username = 'username'
339
- client.password = 'password'
337
+ it "should include the deviceId and deviceToken for an authenticated connection" do
338
+ client.deviceId = 'deviceId'
339
+ client.deviceToken = 'deviceToken'
340
340
  client.connect('myclient')
341
341
  expect(socket.string).to eq(
342
342
  "\x10\x28"+
343
343
  "\x00\x04MQTT"+
344
344
  "\x04\xC2\x00\x0f"+
345
345
  "\x00\x08myclient"+
346
- "\x00\x08username"+
347
- "\x00\x08password"
346
+ "\x00\x08deviceId"+
347
+ "\x00\x08deviceToken"
348
348
  )
349
349
  end
350
350
 
@@ -541,19 +541,19 @@ describe MQTT::Packet::Connect do
541
541
  )
542
542
  end
543
543
 
544
- it "should output the correct bytes for a packet with a username and password" do
544
+ it "should output the correct bytes for a packet with a deviceId and deviceToken" do
545
545
  packet = MQTT::Packet::Connect.new(
546
546
  :client_id => 'myclient',
547
- :username => 'username',
548
- :password => 'password'
547
+ :deviceId => 'deviceId',
548
+ :deviceToken => 'deviceToken'
549
549
  )
550
550
  expect(packet.to_s).to eq(
551
551
  "\x10\x2A"+
552
552
  "\x00\x06MQIsdp"+
553
553
  "\x03\xC2\x00\x0f"+
554
554
  "\x00\x08myclient"+
555
- "\x00\x08username"+
556
- "\x00\x08password"
555
+ "\x00\x08deviceId"+
556
+ "\x00\x08deviceToken"
557
557
  )
558
558
  end
559
559
 
@@ -566,8 +566,8 @@ describe MQTT::Packet::Connect do
566
566
  :will_retain => true,
567
567
  :will_topic => 'will_topic',
568
568
  :will_payload => 'will_message',
569
- :username => 'user0123456789',
570
- :password => 'pass0123456789'
569
+ :deviceId => 'user0123456789',
570
+ :deviceToken => 'pass0123456789'
571
571
  )
572
572
  expect(packet.to_s).to eq(
573
573
  "\x10\x5F"+ # fixed header (2)
@@ -577,9 +577,9 @@ describe MQTT::Packet::Connect do
577
577
  "\x00\x1712345678901234567890123"+ # client identifier (25)
578
578
  "\x00\x0Awill_topic"+ # will topic (12)
579
579
  "\x00\x0Cwill_message"+ # will message (14)
580
- "\x00\x0Euser0123456789"+ # username (16)
580
+ "\x00\x0Euser0123456789"+ # deviceId (16)
581
581
  "\x00\x0Epass0123456789"
582
- ) # password (16)
582
+ ) # deviceToken (16)
583
583
  end
584
584
 
585
585
  context 'protocol version 3.1.1' do
@@ -643,12 +643,12 @@ describe MQTT::Packet::Connect do
643
643
  expect(packet.clean_session).to be_falsey
644
644
  end
645
645
 
646
- it "should set the the username field of the packet to nil" do
647
- expect(packet.username).to be_nil
646
+ it "should set the the deviceId field of the packet to nil" do
647
+ expect(packet.deviceId).to be_nil
648
648
  end
649
649
 
650
- it "should set the the password field of the packet to nil" do
651
- expect(packet.password).to be_nil
650
+ it "should set the the deviceToken field of the packet to nil" do
651
+ expect(packet.deviceToken).to be_nil
652
652
  end
653
653
  end
654
654
 
@@ -693,12 +693,12 @@ describe MQTT::Packet::Connect do
693
693
  expect(packet.clean_session).to be_falsey
694
694
  end
695
695
 
696
- it "should set the the username field of the packet to nil" do
697
- expect(packet.username).to be_nil
696
+ it "should set the the deviceId field of the packet to nil" do
697
+ expect(packet.deviceId).to be_nil
698
698
  end
699
699
 
700
- it "should set the the password field of the packet to nil" do
701
- expect(packet.password).to be_nil
700
+ it "should set the the deviceToken field of the packet to nil" do
701
+ expect(packet.deviceToken).to be_nil
702
702
  end
703
703
  end
704
704
 
@@ -770,15 +770,15 @@ describe MQTT::Packet::Connect do
770
770
  end
771
771
  end
772
772
 
773
- describe "when parsing a Connect packet with a username and password" do
773
+ describe "when parsing a Connect packet with a deviceId and deviceToken" do
774
774
  let(:packet) do
775
775
  MQTT::Packet.parse(
776
776
  "\x10\x2A"+
777
777
  "\x00\x06MQIsdp"+
778
778
  "\x03\xC0\x00\x0a"+
779
779
  "\x00\x08myclient"+
780
- "\x00\x08username"+
781
- "\x00\x08password"
780
+ "\x00\x08deviceId"+
781
+ "\x00\x08deviceToken"
782
782
  )
783
783
  end
784
784
 
@@ -812,64 +812,64 @@ describe MQTT::Packet::Connect do
812
812
  expect(packet.keep_alive).to eq(10)
813
813
  end
814
814
 
815
- it "should set the Username of the packet correctly" do
816
- expect(packet.username).to eq('username')
817
- expect(packet.username.encoding.to_s).to eq('UTF-8')
815
+ it "should set the Device ID of the packet correctly" do
816
+ expect(packet.deviceId).to eq('deviceId')
817
+ expect(packet.deviceId.encoding.to_s).to eq('UTF-8')
818
818
  end
819
819
 
820
- it "should set the Username of the packet correctly" do
821
- expect(packet.password).to eq('password')
822
- expect(packet.password.encoding.to_s).to eq('UTF-8')
820
+ it "should set the Device ID of the packet correctly" do
821
+ expect(packet.deviceToken).to eq('deviceToken')
822
+ expect(packet.deviceToken.encoding.to_s).to eq('UTF-8')
823
823
  end
824
824
  end
825
825
 
826
- describe "when parsing a Connect that has a username but no password" do
826
+ describe "when parsing a Connect that has a deviceId but no deviceToken" do
827
827
  let(:packet) do
828
828
  MQTT::Packet.parse(
829
- "\x10\x20\x00\x06MQIsdp\x03\x80\x00\x0a\x00\x08myclient\x00\x08username"
829
+ "\x10\x20\x00\x06MQIsdp\x03\x80\x00\x0a\x00\x08myclient\x00\x08deviceId"
830
830
  )
831
831
  end
832
832
 
833
- it "should set the Username of the packet correctly" do
834
- expect(packet.username).to eq('username')
835
- expect(packet.username.encoding.to_s).to eq('UTF-8')
833
+ it "should set the Device ID of the packet correctly" do
834
+ expect(packet.deviceId).to eq('deviceId')
835
+ expect(packet.deviceId.encoding.to_s).to eq('UTF-8')
836
836
  end
837
837
 
838
- it "should set the Username of the packet correctly" do
839
- expect(packet.password).to be_nil
838
+ it "should set the Device ID of the packet correctly" do
839
+ expect(packet.deviceToken).to be_nil
840
840
  end
841
841
  end
842
842
 
843
- describe "when parsing a Connect that has a password but no username" do
843
+ describe "when parsing a Connect that has a deviceToken but no deviceId" do
844
844
  let(:packet) do
845
845
  MQTT::Packet.parse(
846
- "\x10\x20\x00\x06MQIsdp\x03\x40\x00\x0a\x00\x08myclient\x00\x08password"
846
+ "\x10\x20\x00\x06MQIsdp\x03\x40\x00\x0a\x00\x08myclient\x00\x08deviceToken"
847
847
  )
848
848
  end
849
849
 
850
- it "should set the Username of the packet correctly" do
851
- expect(packet.username).to be_nil
850
+ it "should set the Device ID of the packet correctly" do
851
+ expect(packet.deviceId).to be_nil
852
852
  end
853
853
 
854
- it "should set the Username of the packet correctly" do
855
- expect(packet.password).to eq('password')
856
- expect(packet.password.encoding.to_s).to eq('UTF-8')
854
+ it "should set the Device ID of the packet correctly" do
855
+ expect(packet.deviceToken).to eq('deviceToken')
856
+ expect(packet.deviceToken.encoding.to_s).to eq('UTF-8')
857
857
  end
858
858
  end
859
859
 
860
- describe "when parsing a Connect packet has the username and password flags set but doesn't have the fields" do
860
+ describe "when parsing a Connect packet has the deviceId and deviceToken flags set but doesn't have the fields" do
861
861
  let(:packet) do
862
862
  MQTT::Packet.parse(
863
863
  "\x10\x16\x00\x06MQIsdp\x03\xC0\x00\x0a\x00\x08myclient"
864
864
  )
865
865
  end
866
866
 
867
- it "should set the Username of the packet correctly" do
868
- expect(packet.username).to be_nil
867
+ it "should set the Device ID of the packet correctly" do
868
+ expect(packet.deviceId).to be_nil
869
869
  end
870
870
 
871
- it "should set the Username of the packet correctly" do
872
- expect(packet.password).to be_nil
871
+ it "should set the Device ID of the packet correctly" do
872
+ expect(packet.deviceToken).to be_nil
873
873
  end
874
874
  end
875
875
 
@@ -883,8 +883,8 @@ describe MQTT::Packet::Connect do
883
883
  "\x00\x1712345678901234567890123"+ # client identifier (25)
884
884
  "\x00\x0Awill_topic"+ # will topic (12)
885
885
  "\x00\x0Cwill_message"+ # will message (14)
886
- "\x00\x0Euser0123456789"+ # username (16)
887
- "\x00\x0Epass0123456789" # password (16)
886
+ "\x00\x0Euser0123456789"+ # deviceId (16)
887
+ "\x00\x0Epass0123456789" # deviceToken (16)
888
888
  )
889
889
  end
890
890
 
@@ -936,14 +936,14 @@ describe MQTT::Packet::Connect do
936
936
  expect(packet.will_payload.encoding.to_s).to eq('UTF-8')
937
937
  end
938
938
 
939
- it "should set the Username of the packet correctly" do
940
- expect(packet.username).to eq('user0123456789')
941
- expect(packet.username.encoding.to_s).to eq('UTF-8')
939
+ it "should set the Device ID of the packet correctly" do
940
+ expect(packet.deviceId).to eq('user0123456789')
941
+ expect(packet.deviceId.encoding.to_s).to eq('UTF-8')
942
942
  end
943
943
 
944
- it "should set the Username of the packet correctly" do
945
- expect(packet.password).to eq('pass0123456789')
946
- expect(packet.password.encoding.to_s).to eq('UTF-8')
944
+ it "should set the Device ID of the packet correctly" do
945
+ expect(packet.deviceToken).to eq('pass0123456789')
946
+ expect(packet.deviceToken.encoding.to_s).to eq('UTF-8')
947
947
  end
948
948
  end
949
949
 
@@ -997,9 +997,9 @@ describe MQTT::Packet::Connect do
997
997
  :keep_alive => 10,
998
998
  :client_id => 'c123',
999
999
  :clean_session => false,
1000
- :username => 'foo'
1000
+ :deviceId => 'foo'
1001
1001
  )
1002
- expect(packet.inspect).to eq("#<MQTT::Packet::Connect: keep_alive=10, client_id='c123', username='foo'>")
1002
+ expect(packet.inspect).to eq("#<MQTT::Packet::Connect: keep_alive=10, client_id='c123', deviceId='foo'>")
1003
1003
  end
1004
1004
  end
1005
1005
 
@@ -1167,7 +1167,7 @@ describe MQTT::Packet::Connack do
1167
1167
  end
1168
1168
 
1169
1169
  it "should set the return message of the packet correctly" do
1170
- expect(packet.return_msg).to match(/bad user name or password/i)
1170
+ expect(packet.return_msg).to match(/bad user name or deviceToken/i)
1171
1171
  end
1172
1172
  end
1173
1173
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qubitro-mqtt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Qubitro