require_relative 'base' require "vagrant-skytap/model/forwarded_port" describe VagrantPlugins::Skytap::Model::ForwardedPort do include_context "unit" let(:fp1) { VagrantPlugins::Skytap::Model::ForwardedPort.new("tcp9000", 9000, 80, protocol: 'tcp') } let(:fp2) { VagrantPlugins::Skytap::Model::ForwardedPort.new("tcp80", 80, 80, protocol: 'tcp') } let(:fp3) { VagrantPlugins::Skytap::Model::ForwardedPort.new("tcp2222", 2222, 22, protocol: 'tcp') } let(:fp4) { VagrantPlugins::Skytap::Model::ForwardedPort.new("ssh", 2201, 22, protocol: 'tcp') } let(:fp5) { VagrantPlugins::Skytap::Model::ForwardedPort.new("tcp1024", 1024, 80, protocol: 'tcp') } let(:fp6) { VagrantPlugins::Skytap::Model::ForwardedPort.new("tcp9000", 80, 1025, protocol: 'tcp') } describe "privileged_host_port?" do it "returns false for host port above 1024" do expect(fp1.privileged_host_port?).to be false end it "returns true for host port below 1024" do expect(fp2.privileged_host_port?).to be true end it "returns true for host port 1024" do expect(fp5.privileged_host_port?).to be true end it "returns true for host port 80 if guest port is over 1024" do expect(fp6.privileged_host_port?).to be true end end describe "internal_ssh_port?" do it "returns false for typical host port" do expect(fp1.internal_ssh_port?).to be false end it "returns true when guest port is 22 and host port is 2222" do expect(fp3.internal_ssh_port?).to be true end it "returns true when id has special value 'ssh'" do expect(fp4.internal_ssh_port?).to be true end end end #- [ ] Set up a “real" environment & machine #- [ ] Give it a Vagrantfile with a collision #- [ ] Provide matching machine folders. #- [ ] read_used_ports and read_forwarded_ports will have natural return values. #- [ ] Check that :port_collision_extra_in_use and :port_collision_remap are correct. #- [ ] Case where read_forwarded_ports returns []. :port_collision_remap should be {}. #- [ ] Case where read_forwarded_ports returns an object with the same id as something # in env[:machine].config.vm.networks: :port_collision_remap should be # { => FP hostport} # - [ ] observe what virtualbox does