autodiscover 0.1.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/.travis.yml +6 -0
- data/Gemfile +4 -0
- data/README.md +32 -31
- data/Rakefile +19 -0
- data/autodiscover.gemspec +30 -0
- data/lib/autodiscover.rb +12 -25
- data/lib/autodiscover/client.rb +22 -215
- data/lib/autodiscover/errors.rb +5 -0
- data/lib/autodiscover/pox_request.rb +72 -0
- data/lib/autodiscover/pox_response.rb +32 -0
- data/lib/autodiscover/server_version_parser.rb +45 -0
- data/lib/autodiscover/version.rb +3 -0
- data/test/fixtures/pox_response.xml +93 -0
- data/test/test_helper.rb +12 -0
- data/test/units/client_test.rb +35 -0
- data/test/units/pox_request_test.rb +46 -0
- data/test/units/pox_response_test.rb +54 -0
- data/test/units/server_version_parser_test.rb +18 -0
- metadata +154 -81
- data/lib/autodiscover/credentials.rb +0 -51
- data/lib/autodiscover/services.rb +0 -40
- data/test/unit_test.rb +0 -195
@@ -0,0 +1,72 @@
|
|
1
|
+
module Autodiscover
|
2
|
+
class PoxRequest
|
3
|
+
|
4
|
+
attr_reader :client, :options
|
5
|
+
|
6
|
+
# @param client [Autodiscover::Client]
|
7
|
+
# @param [Hash] **options
|
8
|
+
# @option **options [Boolean] :ignore_ssl_errors Whether to keep trying if
|
9
|
+
# there are SSL errors
|
10
|
+
def initialize(client, **options)
|
11
|
+
@client = client
|
12
|
+
@options = options
|
13
|
+
end
|
14
|
+
|
15
|
+
# @return [Autodiscover::PoxResponse, nil]
|
16
|
+
def autodiscover
|
17
|
+
available_urls.each do |url|
|
18
|
+
begin
|
19
|
+
response = client.http.post(url, request_body, {'Content-Type' => 'text/xml; charset=utf-8'})
|
20
|
+
return PoxResponse.new(response.body) if good_response?(response)
|
21
|
+
rescue Errno::ENETUNREACH
|
22
|
+
next
|
23
|
+
rescue OpenSSL::SSL::SSLError
|
24
|
+
options[:ignore_ssl_errors] ? next : raise
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
|
33
|
+
def good_response?(response)
|
34
|
+
response.status == 200
|
35
|
+
end
|
36
|
+
|
37
|
+
def available_urls(&block)
|
38
|
+
return to_enum(__method__) unless block_given?
|
39
|
+
formatted_https_urls.each {|url|
|
40
|
+
yield url
|
41
|
+
}
|
42
|
+
yield redirected_http_url
|
43
|
+
end
|
44
|
+
|
45
|
+
def formatted_https_urls
|
46
|
+
@formatted_urls ||= %W{
|
47
|
+
https://#{client.domain}/autodiscover/autodiscover.xml
|
48
|
+
https://autodiscover.#{client.domain}/autodiscover/autodiscover.xml
|
49
|
+
}
|
50
|
+
end
|
51
|
+
|
52
|
+
def redirected_http_url
|
53
|
+
@redirected_http_url ||=
|
54
|
+
begin
|
55
|
+
response = client.http.get("http://autodiscover.#{client.domain}/autodiscover/autodiscover.xml")
|
56
|
+
(response.status == 302) ? response.headers["Location"] : nil
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def request_body
|
61
|
+
Nokogiri::XML::Builder.new do |xml|
|
62
|
+
xml.Autodiscover('xmlns' => 'http://schemas.microsoft.com/exchange/autodiscover/outlook/requestschema/2006') {
|
63
|
+
xml.Request {
|
64
|
+
xml.EMailAddress client.email
|
65
|
+
xml.AcceptableResponseSchema 'http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a'
|
66
|
+
}
|
67
|
+
}
|
68
|
+
end.to_xml
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Autodiscover
|
2
|
+
class PoxResponse
|
3
|
+
|
4
|
+
attr_reader :response
|
5
|
+
|
6
|
+
def initialize(response)
|
7
|
+
raise ArgumentError, "Response must be an XML string" if(response.nil? || response.empty?)
|
8
|
+
@response = Nori.new(parser: :nokogiri).parse(response)["Autodiscover"]["Response"]
|
9
|
+
end
|
10
|
+
|
11
|
+
def exchange_version
|
12
|
+
ServerVersionParser.new(exch_proto["ServerVersion"]).exchange_version
|
13
|
+
end
|
14
|
+
|
15
|
+
def ews_url
|
16
|
+
expr_proto["EwsUrl"]
|
17
|
+
end
|
18
|
+
|
19
|
+
def exch_proto
|
20
|
+
@exch_proto ||= (response["Account"]["Protocol"].select{|p| p["Type"] == "EXCH"}.first || {})
|
21
|
+
end
|
22
|
+
|
23
|
+
def expr_proto
|
24
|
+
@expr_proto ||= (response["Account"]["Protocol"].select{|p| p["Type"] == "EXPR"}.first || {})
|
25
|
+
end
|
26
|
+
|
27
|
+
def web_proto
|
28
|
+
@web_proto ||= (response["Account"]["Protocol"].select{|p| p["Type"] == "WEB"}.first || {})
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Autodiscover
|
2
|
+
class ServerVersionParser
|
3
|
+
|
4
|
+
VERSIONS = {
|
5
|
+
8 => {
|
6
|
+
0 => "Exchange2007",
|
7
|
+
1 => "Exchange2007_SP1",
|
8
|
+
2 => "Exchange2007_SP1",
|
9
|
+
3 => "Exchange2007_SP1",
|
10
|
+
},
|
11
|
+
14 => {
|
12
|
+
0 => "Exchange2010",
|
13
|
+
1 => "Exchange2010_SP1",
|
14
|
+
2 => "Exchange2010_SP2",
|
15
|
+
3 => "Exchange2010_SP2",
|
16
|
+
},
|
17
|
+
15 => {
|
18
|
+
0 => "Exchange2013",
|
19
|
+
1 => "Exchange2013_SP1",
|
20
|
+
}
|
21
|
+
}
|
22
|
+
|
23
|
+
def initialize(hexversion)
|
24
|
+
@version = hexversion.hex.to_s(2).rjust(hexversion.size*4, '0')
|
25
|
+
end
|
26
|
+
|
27
|
+
def major
|
28
|
+
@version[4..9].to_i(2)
|
29
|
+
end
|
30
|
+
|
31
|
+
def minor
|
32
|
+
@version[10..15].to_i(2)
|
33
|
+
end
|
34
|
+
|
35
|
+
def build
|
36
|
+
@version[17..31].to_i(2)
|
37
|
+
end
|
38
|
+
|
39
|
+
def exchange_version
|
40
|
+
v = VERSIONS[major][minor]
|
41
|
+
v.nil? ? VERIONS[8][0] : v
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<Autodiscover xmlns="http://schemas.microsoft.com/exchange/autodiscover/responseschema/2006">
|
3
|
+
<Response xmlns="http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a">
|
4
|
+
<User>
|
5
|
+
<DisplayName>Bill Lumbergh</DisplayName>
|
6
|
+
<LegacyDN>/o=ExchangeLabs/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Recipients/cn=asdfasdfasdfasdfasdfadf-Bill Lumb</LegacyDN>
|
7
|
+
<AutoDiscoverSMTPAddress>blumbergh@initech.local</AutoDiscoverSMTPAddress>
|
8
|
+
<DeploymentId>33333333-3333-3333-3333-3333333333333</DeploymentId>
|
9
|
+
</User>
|
10
|
+
<Account>
|
11
|
+
<AccountType>email</AccountType>
|
12
|
+
<Action>settings</Action>
|
13
|
+
<MicrosoftOnline>True</MicrosoftOnline>
|
14
|
+
<Protocol>
|
15
|
+
<Type>EXCH</Type>
|
16
|
+
<Server>22222222-2222-2222-2222-222222222222@initech.local</Server>
|
17
|
+
<ServerDN>/o=ExchangeLabs/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Configuration/cn=Servers/cn=22222222-2222-2222-2222-222222222222@initech.local</ServerDN>
|
18
|
+
<ServerVersion>73C1809A</ServerVersion>
|
19
|
+
<MdbDN>/o=ExchangeLabs/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Configuration/cn=Servers/cn=22222222-2222-2222-2222-222222222222@initech.local/cn=Microsoft Private MDB</MdbDN>
|
20
|
+
<PublicFolderServer>outlook.office365.com</PublicFolderServer>
|
21
|
+
<AuthPackage>Anonymous</AuthPackage>
|
22
|
+
<ASUrl>https://outlook.office365.com/EWS/Exchange.asmx</ASUrl>
|
23
|
+
<EwsUrl>https://outlook.office365.com/EWS/Exchange.asmx</EwsUrl>
|
24
|
+
<EmwsUrl>https://outlook.office365.com/EWS/Exchange.asmx</EmwsUrl>
|
25
|
+
<SharingUrl>https://outlook.office365.com/EWS/Exchange.asmx</SharingUrl>
|
26
|
+
<EcpUrl>https://outlook.office365.com/ecp/</EcpUrl>
|
27
|
+
<EcpUrl-um>?rfr=olk&p=customize/voicemail.aspx&exsvurl=1&realm=initech.local</EcpUrl-um>
|
28
|
+
<EcpUrl-aggr>?rfr=olk&p=personalsettings/EmailSubscriptions.slab&exsvurl=1&realm=initech.local</EcpUrl-aggr>
|
29
|
+
<EcpUrl-mt>PersonalSettings/DeliveryReport.aspx?rfr=olk&exsvurl=1&IsOWA=<IsOWA>&MsgID=<MsgID>&Mbx=<Mbx>&realm=initech.local</EcpUrl-mt>
|
30
|
+
<EcpUrl-ret>?rfr=olk&p=organize/retentionpolicytags.slab&exsvurl=1&realm=initech.local</EcpUrl-ret>
|
31
|
+
<EcpUrl-sms>?rfr=olk&p=sms/textmessaging.slab&exsvurl=1&realm=initech.local</EcpUrl-sms>
|
32
|
+
<EcpUrl-publish>customize/calendarpublishing.slab?rfr=olk&exsvurl=1&FldID=<FldID>&realm=initech.local</EcpUrl-publish>
|
33
|
+
<EcpUrl-photo>PersonalSettings/EditAccount.aspx?rfr=olk&chgPhoto=1&exsvurl=1&realm=initech.local</EcpUrl-photo>
|
34
|
+
<EcpUrl-connect>Connect/Main.aspx?rfr=olk&exsvurl=1&Provider=<Provider>&Action=<Action>&realm=initech.local</EcpUrl-connect>
|
35
|
+
<EcpUrl-tm>?rfr=olk&ftr=TeamMailbox&exsvurl=1&realm=initech.local</EcpUrl-tm>
|
36
|
+
<EcpUrl-tmCreating>?rfr=olk&ftr=TeamMailboxCreating&SPUrl=<SPUrl>&Title=<Title>&SPTMAppUrl=<SPTMAppUrl>&exsvurl=1&realm=initech.local</EcpUrl-tmCreating>
|
37
|
+
<EcpUrl-tmEditing>?rfr=olk&ftr=TeamMailboxEditing&Id=<Id>&exsvurl=1&realm=initech.local</EcpUrl-tmEditing>
|
38
|
+
<EcpUrl-extinstall>Extension/InstalledExtensions.slab?rfr=olk&exsvurl=1&realm=initech.local</EcpUrl-extinstall>
|
39
|
+
<OOFUrl>https://outlook.office365.com/EWS/Exchange.asmx</OOFUrl>
|
40
|
+
<UMUrl>https://outlook.office365.com/EWS/UM2007Legacy.asmx</UMUrl>
|
41
|
+
<OABUrl>https://outlook.office365.com/OAB/99999999-9999-9999-9999-999999999999/</OABUrl>
|
42
|
+
<ServerExclusiveConnect>off</ServerExclusiveConnect>
|
43
|
+
</Protocol>
|
44
|
+
<Protocol>
|
45
|
+
<Type>EXPR</Type>
|
46
|
+
<Server>outlook.office365.com</Server>
|
47
|
+
<SSL>On</SSL>
|
48
|
+
<AuthPackage>Basic</AuthPackage>
|
49
|
+
<ASUrl>https://outlook.office365.com/EWS/Exchange.asmx</ASUrl>
|
50
|
+
<EwsUrl>https://outlook.office365.com/EWS/Exchange.asmx</EwsUrl>
|
51
|
+
<EmwsUrl>https://outlook.office365.com/EWS/Exchange.asmx</EmwsUrl>
|
52
|
+
<SharingUrl>https://outlook.office365.com/EWS/Exchange.asmx</SharingUrl>
|
53
|
+
<EcpUrl>https://outlook.office365.com/ecp/</EcpUrl>
|
54
|
+
<EcpUrl-um>?rfr=olk&p=customize/voicemail.aspx&exsvurl=1&realm=initech.local</EcpUrl-um>
|
55
|
+
<EcpUrl-aggr>?rfr=olk&p=personalsettings/EmailSubscriptions.slab&exsvurl=1&realm=initech.local</EcpUrl-aggr>
|
56
|
+
<EcpUrl-mt>PersonalSettings/DeliveryReport.aspx?rfr=olk&exsvurl=1&IsOWA=<IsOWA>&MsgID=<MsgID>&Mbx=<Mbx>&realm=initech.local</EcpUrl-mt>
|
57
|
+
<EcpUrl-ret>?rfr=olk&p=organize/retentionpolicytags.slab&exsvurl=1&realm=initech.local</EcpUrl-ret>
|
58
|
+
<EcpUrl-sms>?rfr=olk&p=sms/textmessaging.slab&exsvurl=1&realm=initech.local</EcpUrl-sms>
|
59
|
+
<EcpUrl-publish>customize/calendarpublishing.slab?rfr=olk&exsvurl=1&FldID=<FldID>&realm=initech.local</EcpUrl-publish>
|
60
|
+
<EcpUrl-photo>PersonalSettings/EditAccount.aspx?rfr=olk&chgPhoto=1&exsvurl=1&realm=initech.local</EcpUrl-photo>
|
61
|
+
<EcpUrl-connect>Connect/Main.aspx?rfr=olk&exsvurl=1&Provider=<Provider>&Action=<Action>&realm=initech.local</EcpUrl-connect>
|
62
|
+
<EcpUrl-tm>?rfr=olk&ftr=TeamMailbox&exsvurl=1&realm=initech.local</EcpUrl-tm>
|
63
|
+
<EcpUrl-tmCreating>?rfr=olk&ftr=TeamMailboxCreating&SPUrl=<SPUrl>&Title=<Title>&SPTMAppUrl=<SPTMAppUrl>&exsvurl=1&realm=initech.local</EcpUrl-tmCreating>
|
64
|
+
<EcpUrl-tmEditing>?rfr=olk&ftr=TeamMailboxEditing&Id=<Id>&exsvurl=1&realm=initech.local</EcpUrl-tmEditing>
|
65
|
+
<EcpUrl-extinstall>Extension/InstalledExtensions.slab?rfr=olk&exsvurl=1&realm=initech.local</EcpUrl-extinstall>
|
66
|
+
<OOFUrl>https://outlook.office365.com/EWS/Exchange.asmx</OOFUrl>
|
67
|
+
<UMUrl>https://outlook.office365.com/EWS/UM2007Legacy.asmx</UMUrl>
|
68
|
+
<OABUrl>https://outlook.office365.com/OAB/99999999-9999-9999-9999-999999999999/</OABUrl>
|
69
|
+
<ServerExclusiveConnect>on</ServerExclusiveConnect>
|
70
|
+
<CertPrincipalName>msstd:outlook.com</CertPrincipalName>
|
71
|
+
<EwsPartnerUrl>https://outlook.office365.com/EWS/Exchange.asmx</EwsPartnerUrl>
|
72
|
+
<GroupingInformation>ZC4PR14</GroupingInformation>
|
73
|
+
</Protocol>
|
74
|
+
<Protocol>
|
75
|
+
<Type>WEB</Type>
|
76
|
+
<Internal>
|
77
|
+
<OWAUrl AuthenticationMethod="LiveIdFba, OAuth">https://outlook.office365.com/owa/</OWAUrl>
|
78
|
+
<Protocol>
|
79
|
+
<Type>EXCH</Type>
|
80
|
+
<ASUrl>https://outlook.office365.com/EWS/Exchange.asmx</ASUrl>
|
81
|
+
</Protocol>
|
82
|
+
</Internal>
|
83
|
+
<External>
|
84
|
+
<OWAUrl AuthenticationMethod="Fba">https://outlook.office365.com/owa/initech.local/</OWAUrl>
|
85
|
+
<Protocol>
|
86
|
+
<Type>EXPR</Type>
|
87
|
+
<ASUrl>https://outlook.office365.com/EWS/Exchange.asmx</ASUrl>
|
88
|
+
</Protocol>
|
89
|
+
</External>
|
90
|
+
</Protocol>
|
91
|
+
</Account>
|
92
|
+
</Response>
|
93
|
+
</Autodiscover>
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require File.expand_path('../../lib/autodiscover.rb', __FILE__)
|
2
|
+
require 'minitest/autorun'
|
3
|
+
require "minitest/autorun"
|
4
|
+
require "mocha/mini_test"
|
5
|
+
|
6
|
+
TEST_DIR = File.dirname(__FILE__)
|
7
|
+
|
8
|
+
class MiniTest::Spec
|
9
|
+
def load_sample(name)
|
10
|
+
File.read("#{TEST_DIR}/fixtures/#{name}")
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
describe Autodiscover::Client do
|
4
|
+
let(:_class) { Autodiscover::Client }
|
5
|
+
|
6
|
+
describe "#initialize" do
|
7
|
+
it "sets a username and domain from the email" do
|
8
|
+
inst = _class.new(email: "test@example.local", password: "test")
|
9
|
+
_(inst.domain).must_equal "example.local"
|
10
|
+
_(inst.instance_variable_get(:@username)).must_equal "test@example.local"
|
11
|
+
end
|
12
|
+
|
13
|
+
it "allows you to override the username and domain" do
|
14
|
+
inst = _class.new(email: "test@example.local", password: "test", username: 'DOMAIN\test', domain: "otherexample.local")
|
15
|
+
_(inst.domain).must_equal "otherexample.local"
|
16
|
+
_(inst.instance_variable_get(:@username)).must_equal 'DOMAIN\test'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "#autodiscover" do
|
21
|
+
it "dispatches autodiscover to a PoxRequest instance" do
|
22
|
+
inst = _class.new(email: "test@example.local", password: "test")
|
23
|
+
pox_request = mock("pox")
|
24
|
+
pox_request.expects(:autodiscover)
|
25
|
+
Autodiscover::PoxRequest.expects(:new).with(inst,{}).returns(pox_request)
|
26
|
+
inst.autodiscover
|
27
|
+
end
|
28
|
+
|
29
|
+
it "raises an exception if an invalid autodiscover type is passed" do
|
30
|
+
inst = _class.new(email: "test@example.local", password: "test")
|
31
|
+
->{ inst.autodiscover(type: :invalid) }.must_raise(Autodiscover::ArgumentError)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
require "ostruct"
|
3
|
+
|
4
|
+
describe Autodiscover::PoxRequest do
|
5
|
+
let(:_class) {Autodiscover::PoxRequest }
|
6
|
+
let(:http) { mock("http") }
|
7
|
+
let(:client) { OpenStruct.new({http: http, domain: "example.local", email: "test@example.local"}) }
|
8
|
+
|
9
|
+
describe "#autodiscover" do
|
10
|
+
it "returns a PoxResponse if the autodiscover is successful" do
|
11
|
+
request_body = <<-EOF.gsub(/^ /,"")
|
12
|
+
<?xml version="1.0"?>
|
13
|
+
<Autodiscover xmlns="http://schemas.microsoft.com/exchange/autodiscover/outlook/requestschema/2006">
|
14
|
+
<Request>
|
15
|
+
<EMailAddress>test@example.local</EMailAddress>
|
16
|
+
<AcceptableResponseSchema>http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a</AcceptableResponseSchema>
|
17
|
+
</Request>
|
18
|
+
</Autodiscover>
|
19
|
+
EOF
|
20
|
+
http.expects(:post).with(
|
21
|
+
"https://example.local/autodiscover/autodiscover.xml", request_body,
|
22
|
+
{'Content-Type' => 'text/xml; charset=utf-8'}
|
23
|
+
).returns(OpenStruct.new({status: 200, body: "<Autodiscover><Response><test></test></Response></Autodiscover>"}))
|
24
|
+
|
25
|
+
inst = _class.new(client)
|
26
|
+
_(inst.autodiscover).must_be_instance_of(Autodiscover::PoxResponse)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "will fail if :ignore_ssl_errors is not true" do
|
30
|
+
http.expects(:post).raises(OpenSSL::SSL::SSLError, "Test Error")
|
31
|
+
inst = _class.new(client)
|
32
|
+
-> {inst.autodiscover}.must_raise(OpenSSL::SSL::SSLError)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "keeps trying if :ignore_ssl_errors is set" do
|
36
|
+
http.expects(:get).once.returns(OpenStruct.new({headers: {"Location" => "http://example.local"}, status: 302}))
|
37
|
+
http.expects(:post).times(3).
|
38
|
+
raises(OpenSSL::SSL::SSLError, "Test Error").then.
|
39
|
+
raises(OpenSSL::SSL::SSLError, "Test Error").then.
|
40
|
+
raises(Errno::ENETUNREACH, "Test Error")
|
41
|
+
inst = _class.new(client, ignore_ssl_errors: true)
|
42
|
+
_(inst.autodiscover).must_be_nil
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
describe Autodiscover::PoxResponse do
|
4
|
+
let(:_class) {Autodiscover::PoxResponse }
|
5
|
+
let(:response) { load_sample("pox_response.xml") }
|
6
|
+
|
7
|
+
describe "#initialize" do
|
8
|
+
it "parses an XML string into a Hash when initialized" do
|
9
|
+
inst = _class.new response
|
10
|
+
_(inst.response).must_be_instance_of Hash
|
11
|
+
end
|
12
|
+
|
13
|
+
it "it raises an exception if the response is empty or nil" do
|
14
|
+
->{_class.new ""}.must_raise(Autodiscover::ArgumentError)
|
15
|
+
->{_class.new nil}.must_raise(Autodiscover::ArgumentError)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "#exchange_version" do
|
20
|
+
it "returns an Exchange version usable for EWS" do
|
21
|
+
_(_class.new(response).exchange_version).must_equal "Exchange2013_SP1"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "#ews_url" do
|
26
|
+
it "returns the EWS url" do
|
27
|
+
_(_class.new(response).ews_url).must_equal "https://outlook.office365.com/EWS/Exchange.asmx"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "Protocol Hashes" do
|
32
|
+
let(:_inst) { _class.new(response) }
|
33
|
+
|
34
|
+
it "returns the EXCH protocol Hash" do
|
35
|
+
_(_inst.exch_proto["Type"]).must_equal "EXCH"
|
36
|
+
end
|
37
|
+
|
38
|
+
it "returns the EXPR protocol Hash" do
|
39
|
+
_(_inst.expr_proto["Type"]).must_equal "EXPR"
|
40
|
+
end
|
41
|
+
|
42
|
+
it "returns the WEB protocol Hash" do
|
43
|
+
_(_inst.web_proto["Type"]).must_equal "WEB"
|
44
|
+
end
|
45
|
+
|
46
|
+
it "returns empty Hashes when the protocols are missing" do
|
47
|
+
_inst.response["Account"]["Protocol"] = []
|
48
|
+
_(_inst.exch_proto).must_equal({})
|
49
|
+
_(_inst.expr_proto).must_equal({})
|
50
|
+
_(_inst.web_proto).must_equal({})
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
describe Autodiscover::ServerVersionParser do
|
4
|
+
let(:_class) { Autodiscover::ServerVersionParser }
|
5
|
+
|
6
|
+
it "parses a hex ServerVersion response" do
|
7
|
+
inst = _class.new("738180DA")
|
8
|
+
_(inst.major).must_equal 14
|
9
|
+
_(inst.minor).must_equal 1
|
10
|
+
_(inst.build).must_equal 218
|
11
|
+
end
|
12
|
+
|
13
|
+
it "returns an Exchange Server Version" do
|
14
|
+
inst = _class.new("738180DA")
|
15
|
+
inst.exchange_version.must_equal "Exchange2010_SP1"
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
metadata
CHANGED
@@ -1,112 +1,185 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: autodiscover
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
segments:
|
6
|
-
- 0
|
7
|
-
- 1
|
8
|
-
- 0
|
9
|
-
version: 0.1.0
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
10
5
|
platform: ruby
|
11
|
-
authors:
|
6
|
+
authors:
|
12
7
|
- David King
|
8
|
+
- Dan Wanek
|
13
9
|
autorequire:
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
dependencies:
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2015-05-12 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: nokogiri
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0'
|
21
|
+
type: :runtime
|
22
22
|
prerelease: false
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: nori
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
26
32
|
- - ">="
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
- 0
|
30
|
-
version: "0"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
31
35
|
type: :runtime
|
32
|
-
version_requirements: *id001
|
33
|
-
- !ruby/object:Gem::Dependency
|
34
|
-
name: httpclient
|
35
36
|
prerelease: false
|
36
|
-
|
37
|
-
|
38
|
-
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: httpclient
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
39
46
|
- - ">="
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
|
42
|
-
- 0
|
43
|
-
version: "0"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
44
49
|
type: :runtime
|
45
|
-
version_requirements: *id002
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
name: webmock
|
48
50
|
prerelease: false
|
49
|
-
|
50
|
-
|
51
|
-
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: minitest
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 5.6.0
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 5.6.0
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: mocha
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 1.1.0
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: 1.1.0
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: bundler
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: rake
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
52
102
|
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
|
55
|
-
- 0
|
56
|
-
version: "0"
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
57
105
|
type: :development
|
58
|
-
|
59
|
-
|
60
|
-
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
- !ruby/object:Gem::Dependency
|
113
|
+
name: pry
|
114
|
+
requirement: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
type: :development
|
120
|
+
prerelease: false
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
description: The Autodiscover Service provides information about a Microsoft Exchange
|
127
|
+
environment such as service URLs, versions and many other attributes.
|
128
|
+
email:
|
129
|
+
- dking@bestinclass.com
|
130
|
+
- dan.wanek@gmail.com
|
61
131
|
executables: []
|
62
|
-
|
63
132
|
extensions: []
|
64
|
-
|
65
|
-
|
66
|
-
-
|
67
|
-
-
|
68
|
-
files:
|
133
|
+
extra_rdoc_files: []
|
134
|
+
files:
|
135
|
+
- ".gitignore"
|
136
|
+
- ".travis.yml"
|
69
137
|
- CHANGELOG
|
70
|
-
-
|
138
|
+
- Gemfile
|
71
139
|
- MIT-LICENSE
|
72
|
-
-
|
73
|
-
-
|
74
|
-
-
|
140
|
+
- README.md
|
141
|
+
- Rakefile
|
142
|
+
- autodiscover.gemspec
|
75
143
|
- lib/autodiscover.rb
|
76
|
-
-
|
77
|
-
|
78
|
-
|
144
|
+
- lib/autodiscover/client.rb
|
145
|
+
- lib/autodiscover/errors.rb
|
146
|
+
- lib/autodiscover/pox_request.rb
|
147
|
+
- lib/autodiscover/pox_response.rb
|
148
|
+
- lib/autodiscover/server_version_parser.rb
|
149
|
+
- lib/autodiscover/version.rb
|
150
|
+
- test/fixtures/pox_response.xml
|
151
|
+
- test/test_helper.rb
|
152
|
+
- test/units/client_test.rb
|
153
|
+
- test/units/pox_request_test.rb
|
154
|
+
- test/units/pox_response_test.rb
|
155
|
+
- test/units/server_version_parser_test.rb
|
156
|
+
homepage: http://github.com/WinRb/autodiscover
|
79
157
|
licenses: []
|
80
|
-
|
158
|
+
metadata: {}
|
81
159
|
post_install_message:
|
82
160
|
rdoc_options: []
|
83
|
-
|
84
|
-
require_paths:
|
161
|
+
require_paths:
|
85
162
|
- lib
|
86
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
87
|
-
|
88
|
-
requirements:
|
163
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
164
|
+
requirements:
|
89
165
|
- - ">="
|
90
|
-
- !ruby/object:Gem::Version
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
- 7
|
95
|
-
version: 1.8.7
|
96
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
|
-
requirements:
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: 2.1.0
|
168
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
169
|
+
requirements:
|
99
170
|
- - ">="
|
100
|
-
- !ruby/object:Gem::Version
|
101
|
-
|
102
|
-
- 0
|
103
|
-
version: "0"
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: '0'
|
104
173
|
requirements: []
|
105
|
-
|
106
174
|
rubyforge_project:
|
107
|
-
rubygems_version:
|
175
|
+
rubygems_version: 2.4.3
|
108
176
|
signing_key:
|
109
|
-
specification_version:
|
177
|
+
specification_version: 4
|
110
178
|
summary: Ruby client for Microsoft's Autodiscover Service
|
111
|
-
test_files:
|
112
|
-
- test/
|
179
|
+
test_files:
|
180
|
+
- test/fixtures/pox_response.xml
|
181
|
+
- test/test_helper.rb
|
182
|
+
- test/units/client_test.rb
|
183
|
+
- test/units/pox_request_test.rb
|
184
|
+
- test/units/pox_response_test.rb
|
185
|
+
- test/units/server_version_parser_test.rb
|