spec/lib/metasploit/credential/migrator_spec.rb in metasploit-credential-0.14.8 vs spec/lib/metasploit/credential/migrator_spec.rb in metasploit-credential-1.0.0.pre.rails.pre.4.0b

- old
+ new

@@ -12,11 +12,13 @@ subject(:migrator){ Metasploit::Credential::Migrator.new(workspace) } describe "#convert_creds_in_workspace" do describe "when there are no Mdm::Cred objects in the workspace" do before(:each) do - workspace.creds = [] + workspace.services.each do |service| + service.creds = [] + end end it 'should not change the Core count' do expect{migrator.convert_creds_in_workspace(workspace)}.to_not change(Metasploit::Credential::Core, :count) end @@ -42,43 +44,35 @@ let(:service1){ FactoryGirl.create(:mdm_service, host: host1)} let(:service2){ FactoryGirl.create(:mdm_service, host: host2)} let(:service3){ FactoryGirl.create(:mdm_service, host: host3)} - let(:cred1){ FactoryGirl.create(:mdm_cred, service: service1)} - let(:cred2){ FactoryGirl.create(:mdm_cred, service: service2)} - let(:cred3){ FactoryGirl.create(:mdm_cred, service: service3)} + let!(:cred1){ FactoryGirl.create(:mdm_cred, service: service1)} + let!(:cred2){ FactoryGirl.create(:mdm_cred, service: service2)} + let!(:cred3){ FactoryGirl.create(:mdm_cred, service: service3)} - before(:each) do - cred1; cred2; cred3 - end - it 'should migrate them into Metasploit::Credential::Core objects' do expect{migrator.convert_creds_in_workspace(workspace)}.to change(Metasploit::Credential::Core, :count).from(0).to(3) end describe "new Publics" do before(:each) do migrator.convert_creds_in_workspace(workspace) end it "should be created for each Mdm::Cred" do - Metasploit::Credential::Public.where(username: cred1.user).should_not be_blank - Metasploit::Credential::Public.where(username: cred2.user).should_not be_blank - Metasploit::Credential::Public.where(username: cred3.user).should_not be_blank + expect(Metasploit::Credential::Public.pluck(:username)).to match_array([cred1.user, cred2.user, cred3.user]) end + end describe "new Privates" do before(:each) do migrator.convert_creds_in_workspace(workspace) end it "should be created for each Mdm::Cred" do - migrator.convert_creds_in_workspace(workspace) - Metasploit::Credential::Password.where(data: cred1.pass).should_not be_blank - Metasploit::Credential::Password.where(data: cred2.pass).should_not be_blank - Metasploit::Credential::Password.where(data: cred3.pass).should_not be_blank + expect(Metasploit::Credential::Password.pluck(:data)).to match_array([cred1.pass, cred2.pass, cred3.pass]) end end end describe "creating the proper kinds of Private objects" do