Read about Rspec Testing. Link 1. Link 2 gives a great introduction to RSpec, and good TDD example. let(). :colon_things
See how it's applied to Victor's ether_shell: git clone https://github.com/pwnall/ether_shell.git and navigate to its "spec" directory to run the rspec tests.
Install rspec: sudo gem install rspec.
Run an RSpec test to see it produces RSpec outputs! :)
ether_shell/spec/ether_shell$ rspec raw_socket_spec.rb
FFFFF
Failures:
1) RawSocket mac should have 6 bytes
Failure/Error: let(:mac) { EtherShell::RawSocket.mac eth_device }
Errno::EPERM:
Operation not permitted - socket(2)
# /home/haoqili/Desktop/rails/secureSt/ether_shell/spec/../lib/ether_shell/raw_socket.rb:15:in `initialize'
# /home/haoqili/Desktop/rails/secureSt/ether_shell/spec/../lib/ether_shell/raw_socket.rb:15:in `new'
# /home/haoqili/Desktop/rails/secureSt/ether_shell/spec/../lib/ether_shell/raw_socket.rb:15:in `socket'
# /home/haoqili/Desktop/rails/secureSt/ether_shell/spec/../lib/ether_shell/raw_socket.rb:31:in `mac'
# ./raw_socket_spec.rb:5
# ./raw_socket_spec.rb:14
2) RawSocket mac should match ifconfig output
Failure/Error: let(:mac) { EtherShell::RawSocket.mac eth_device }
Errno::EPERM:
Operation not permitted - socket(2)
# /home/haoqili/Desktop/rails/secureSt/ether_shell/spec/../lib/ether_shell/raw_socket.rb:15:in `initialize'
# /home/haoqili/Desktop/rails/secureSt/ether_shell/spec/../lib/ether_shell/raw_socket.rb:15:in `new'
# /home/haoqili/Desktop/rails/secureSt/ether_shell/spec/../lib/ether_shell/raw_socket.rb:15:in `socket'
# /home/haoqili/Desktop/rails/secureSt/ether_shell/spec/../lib/ether_shell/raw_socket.rb:31:in `mac'
# ./raw_socket_spec.rb:5
# ./raw_socket_spec.rb:18
3) RawSocket socket should be able to receive data
Failure/Error: before { @socket = EtherShell::RawSocket.socket eth_device }
Errno::EPERM:
Operation not permitted - socket(2)
# /home/haoqili/Desktop/rails/secureSt/ether_shell/spec/../lib/ether_shell/raw_socket.rb:15:in `initialize'
# /home/haoqili/Desktop/rails/secureSt/ether_shell/spec/../lib/ether_shell/raw_socket.rb:15:in `new'
# /home/haoqili/Desktop/rails/secureSt/ether_shell/spec/../lib/ether_shell/raw_socket.rb:15:in `socket'
# ./raw_socket_spec.rb:25
4) RawSocket socket should output a packet
Failure/Error: before { @socket = EtherShell::RawSocket.socket eth_device }
Errno::EPERM:
Operation not permitted - socket(2)
# /home/haoqili/Desktop/rails/secureSt/ether_shell/spec/../lib/ether_shell/raw_socket.rb:15:in `initialize'
# /home/haoqili/Desktop/rails/secureSt/ether_shell/spec/../lib/ether_shell/raw_socket.rb:15:in `new'
# /home/haoqili/Desktop/rails/secureSt/ether_shell/spec/../lib/ether_shell/raw_socket.rb:15:in `socket'
# ./raw_socket_spec.rb:25
5) RawSocket socket should receive some network noise
Failure/Error: before { @socket = EtherShell::RawSocket.socket eth_device }
Errno::EPERM:
Operation not permitted - socket(2)
# /home/haoqili/Desktop/rails/secureSt/ether_shell/spec/../lib/ether_shell/raw_socket.rb:15:in `initialize'
# /home/haoqili/Desktop/rails/secureSt/ether_shell/spec/../lib/ether_shell/raw_socket.rb:15:in `new'
# /home/haoqili/Desktop/rails/secureSt/ether_shell/spec/../lib/ether_shell/raw_socket.rb:15:in `socket'
# ./raw_socket_spec.rb:25
Finished in 0.00203 seconds
5 examples, 5 failures
Failures:
1) RawSocket mac should have 6 bytes
Failure/Error: let(:mac) { EtherShell::RawSocket.mac eth_device }
Errno::EPERM:
Operation not permitted - socket(2)
# /home/haoqili/Desktop/rails/secureSt/ether_shell/spec/../lib/ether_shell/raw_socket.rb:15:in `initialize'
# /home/haoqili/Desktop/rails/secureSt/ether_shell/spec/../lib/ether_shell/raw_socket.rb:15:in `new'
# /home/haoqili/Desktop/rails/secureSt/ether_shell/spec/../lib/ether_shell/raw_socket.rb:15:in `socket'
# /home/haoqili/Desktop/rails/secureSt/ether_shell/spec/../lib/ether_shell/raw_socket.rb:31:in `mac'
# ./raw_socket_spec.rb:5
# ./raw_socket_spec.rb:14
2) RawSocket mac should match ifconfig output
Failure/Error: let(:mac) { EtherShell::RawSocket.mac eth_device }
Errno::EPERM:
Operation not permitted - socket(2)
# /home/haoqili/Desktop/rails/secureSt/ether_shell/spec/../lib/ether_shell/raw_socket.rb:15:in `initialize'
# /home/haoqili/Desktop/rails/secureSt/ether_shell/spec/../lib/ether_shell/raw_socket.rb:15:in `new'
# /home/haoqili/Desktop/rails/secureSt/ether_shell/spec/../lib/ether_shell/raw_socket.rb:15:in `socket'
# /home/haoqili/Desktop/rails/secureSt/ether_shell/spec/../lib/ether_shell/raw_socket.rb:31:in `mac'
# ./raw_socket_spec.rb:5
# ./raw_socket_spec.rb:18
3) RawSocket socket should be able to receive data
Failure/Error: before { @socket = EtherShell::RawSocket.socket eth_device }
Errno::EPERM:
Operation not permitted - socket(2)
# /home/haoqili/Desktop/rails/secureSt/ether_shell/spec/../lib/ether_shell/raw_socket.rb:15:in `initialize'
# /home/haoqili/Desktop/rails/secureSt/ether_shell/spec/../lib/ether_shell/raw_socket.rb:15:in `new'
# /home/haoqili/Desktop/rails/secureSt/ether_shell/spec/../lib/ether_shell/raw_socket.rb:15:in `socket'
# ./raw_socket_spec.rb:25
4) RawSocket socket should output a packet
Failure/Error: before { @socket = EtherShell::RawSocket.socket eth_device }
Errno::EPERM:
Operation not permitted - socket(2)
# /home/haoqili/Desktop/rails/secureSt/ether_shell/spec/../lib/ether_shell/raw_socket.rb:15:in `initialize'
# /home/haoqili/Desktop/rails/secureSt/ether_shell/spec/../lib/ether_shell/raw_socket.rb:15:in `new'
# /home/haoqili/Desktop/rails/secureSt/ether_shell/spec/../lib/ether_shell/raw_socket.rb:15:in `socket'
# ./raw_socket_spec.rb:25
5) RawSocket socket should receive some network noise
Failure/Error: before { @socket = EtherShell::RawSocket.socket eth_device }
Errno::EPERM:
Operation not permitted - socket(2)
# /home/haoqili/Desktop/rails/secureSt/ether_shell/spec/../lib/ether_shell/raw_socket.rb:15:in `initialize'
# /home/haoqili/Desktop/rails/secureSt/ether_shell/spec/../lib/ether_shell/raw_socket.rb:15:in `new'
# /home/haoqili/Desktop/rails/secureSt/ether_shell/spec/../lib/ether_shell/raw_socket.rb:15:in `socket'
# ./raw_socket_spec.rb:25
Finished in 0.00203 seconds
5 examples, 5 failures
No comments:
Post a Comment