Skip to content

Commit

Permalink
Adding basic login spec
Browse files Browse the repository at this point in the history
  • Loading branch information
iloveitaly committed Feb 22, 2015
1 parent ee7bb47 commit eb2e3ce
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
20 changes: 20 additions & 0 deletions spec/netsuite/actions/login_spec.rb
@@ -0,0 +1,20 @@
require 'spec_helper'

describe NetSuite::Actions::Login do
it 'properly executes a login call' do
savon.mock!

message = {"platformMsgs:passport"=>{"platformCore:email"=>"email", "platformCore:password"=>"password", "platformCore:account"=>"1234", "platformCore:role"=>234}}

savon.expects(:login).with(:message => message).returns(File.read('spec/support/fixtures/login.xml'))

result = NetSuite::Actions::Login.call({
email: 'email',
password: 'password',
role: 234
})

expect(result.success?).to eq(true)
expect(result.body[:user_id]).to_not be_nil
end
end
35 changes: 35 additions & 0 deletions spec/support/fixtures/login.xml
@@ -0,0 +1,35 @@
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
<platformMsgs:documentInfo xmlns:platformMsgs="urn:messages_2013_1.platform.webservices.netsuite.com">
<platformMsgs:nsId>WEBSERVICES_1050000_022120151347972620982848545_59961c863594</platformMsgs:nsId>
</platformMsgs:documentInfo>
</soapenv:Header>
<soapenv:Body>
<loginResponse xmlns="urn:messages_2013_1.platform.webservices.netsuite.com">
<sessionResponse>
<platformCore:status xmlns:platformCore="urn:core_2013_1.platform.webservices.netsuite.com" isSuccess="true"/>
<userId xmlns:platformCore="urn:core_2013_1.platform.webservices.netsuite.com" internalId="460362">
<platformCore:name>REDACTED NAME</platformCore:name>
</userId>
<platformCore:wsRoleList xmlns:platformCore="urn:core_2013_1.platform.webservices.netsuite.com">
<platformCore:wsRole>
<platformCore:role internalId="1047">
<platformCore:name>REDACTED ROLE</platformCore:name>
</platformCore:role>
<platformCore:isDefault>false</platformCore:isDefault>
<platformCore:isInactive>false</platformCore:isInactive>
<platformCore:isLoggedInRole>true</platformCore:isLoggedInRole>
</platformCore:wsRole>
<platformCore:wsRole>
<platformCore:role internalId="1047">
<platformCore:name>REDACTED ROLE</platformCore:name>
</platformCore:role>
<platformCore:isDefault>false</platformCore:isDefault>
<platformCore:isInactive>false</platformCore:isInactive>
<platformCore:isLoggedInRole>true</platformCore:isLoggedInRole>
</platformCore:wsRole>
</platformCore:wsRoleList>
</sessionResponse>
</loginResponse>
</soapenv:Body>
</soapenv:Envelope>

0 comments on commit eb2e3ce

Please sign in to comment.