This repository has been archived by the owner on Oct 11, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed blockwise transfers and added some optional ETSI Plugtests.
- Loading branch information
Showing
16 changed files
with
172 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
#\ -o ::1 -p 5683 -O Block=false -O Multicast=false -O Observe=false -O Log=debug -E none | ||
|
||
module David; module Interop; end; end | ||
module David; module ETSI; end; end | ||
|
||
require 'bundler/setup' | ||
Bundler.setup | ||
|
||
require 'david' | ||
require 'david/interop/mandatory_etsi/rack' | ||
require 'david/etsi/mandatory/rack' | ||
|
||
run David::Interop::MandatoryETSI::Rack.new | ||
run David::ETSI::Mandatory::Rack.new |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module David::ETSI | ||
end | ||
|
||
require 'david/etsi/mandatory' | ||
require 'david/etsi/optional' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module David::ETSI::Mandatory | ||
path = File.expand_path('../mandatory', __FILE__) | ||
Dir["#{path}/*.rb"].each { |file| require file } | ||
end |
2 changes: 1 addition & 1 deletion
2
lib/david/interop/mandatory_etsi/grape.rb → lib/david/etsi/mandatory/grape.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
lib/david/interop/mandatory_etsi/hobbit.rb → lib/david/etsi/mandatory/hobbit.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
lib/david/interop/mandatory_etsi/nyny.rb → lib/david/etsi/mandatory/nyny.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
lib/david/interop/mandatory_etsi/rack.rb → lib/david/etsi/mandatory/rack.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
lib/david/interop/mandatory_etsi/sinatra.rb → lib/david/etsi/mandatory/sinatra.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module David::ETSI::Optional | ||
path = File.expand_path('../optional', __FILE__) | ||
Dir["#{path}/*.rb"].each { |file| require file } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
module David::ETSI::Optional | ||
class Rack | ||
def call(env) | ||
return case request(env) | ||
when 'GET /large' | ||
[2.05, {'Content-Type' => 'text/plain'}, ['*'*1025]] | ||
when 'GET /obs' | ||
[2.05, | ||
{ | ||
'Content-Type' => 'text/plain', | ||
'ETag' => rand(0xffff).to_s | ||
}, | ||
[Time.now.to_s] | ||
] | ||
else | ||
[4.04, {}, []] | ||
end | ||
end | ||
|
||
private | ||
|
||
def request(env) | ||
env['REQUEST_METHOD'] + ' ' + env['PATH_INFO'] | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
require 'spec_helper' | ||
|
||
[ | ||
ETSI::Optional::Rack, | ||
].each do |app| | ||
describe "ETSI Plugstests, Optional, #{app.to_s.split('::').last}" do | ||
let!(:server) { supervised_server(:MinimalMapping => true, app: app) } | ||
|
||
context 'TD_COAP_BLOCK_01' do | ||
it 'block 0' do | ||
mid, response = req(:get, '/large', block2: 0) # 0, false, 16 | ||
block = CoAP::Block.new(response.options[:block2]).decode | ||
|
||
expect(response).to be_a(CoAP::Message) | ||
expect(response.mcode).to eq([2, 5]) | ||
expect(response.mid).to eq(mid) | ||
expect(response.payload.size).to eq(16) | ||
expect(block.num).to eq(0) | ||
expect(block.more).to eq(true) | ||
expect(block.size).to eq(16) | ||
end | ||
|
||
it 'block 1' do | ||
mid, response = req(:get, '/large', block2: 16) # 1, false, 16 | ||
block = CoAP::Block.new(response.options[:block2]).decode | ||
|
||
expect(response).to be_a(CoAP::Message) | ||
expect(response.mcode).to eq([2, 5]) | ||
expect(response.mid).to eq(mid) | ||
expect(response.payload.size).to eq(16) | ||
expect(block.num).to eq(1) | ||
expect(block.more).to eq(true) | ||
expect(block.size).to eq(16) | ||
end | ||
|
||
it 'block 64' do | ||
mid, response = req(:get, '/large', block2: 1024) # 65, false, 16 | ||
block = CoAP::Block.new(response.options[:block2]).decode | ||
|
||
expect(response).to be_a(CoAP::Message) | ||
expect(response.mcode).to eq([2, 5]) | ||
expect(response.mid).to eq(mid) | ||
expect(response.payload.size).to eq(1) | ||
expect(block.num).to eq(64) | ||
expect(block.more).to eq(false) | ||
expect(block.size).to eq(16) | ||
end | ||
|
||
end | ||
|
||
context 'TD_COAP_BLOCK_02' do | ||
it 'block 0' do | ||
mid, response = req(:get, '/large') | ||
block = CoAP::Block.new(response.options[:block2]).decode | ||
|
||
expect(response).to be_a(CoAP::Message) | ||
expect(response.mcode).to eq([2, 5]) | ||
expect(response.mid).to eq(mid) | ||
expect(response.payload.size).to eq(1024) | ||
expect(block.num).to eq(0) | ||
expect(block.more).to eq(true) | ||
expect(block.size).to eq(1024) | ||
end | ||
|
||
it 'block 1' do | ||
mid, response = req(:get, '/large', block2: 22) # 1, false, 1024 | ||
block = CoAP::Block.new(response.options[:block2]).decode | ||
|
||
expect(response).to be_a(CoAP::Message) | ||
expect(response.mcode).to eq([2, 5]) | ||
expect(response.mid).to eq(mid) | ||
expect(response.payload.size).to eq(1) | ||
expect(block.num).to eq(1) | ||
expect(block.more).to eq(false) | ||
expect(block.size).to eq(1024) | ||
end | ||
end | ||
|
||
describe 'TD_COAP_OBS_01' do | ||
before do | ||
@answers = [] | ||
|
||
@t1 = Thread.start do | ||
CoAP::Client.new.observe \ | ||
'/obs', '::1', nil, | ||
->(s, m) { @answers << m } | ||
end | ||
|
||
Timeout.timeout(12) do | ||
sleep 0.25 while !(@answers.size > 2) | ||
end | ||
end | ||
|
||
it 'responses' do | ||
expect(@answers.size).to be > 2 | ||
@answers.each do |answer| | ||
obs = answer.options[:observe] | ||
expect(obs).not_to eq(nil) | ||
expect(obs).to be >= 0 | ||
expect(obs).to be <= 2 | ||
end | ||
end | ||
|
||
after do | ||
@t1.kill | ||
end | ||
end | ||
|
||
after do | ||
server.terminate | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters