baruwa 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +15 -0
- data/.codeclimate.yml +4 -0
- data/.gitignore +5 -0
- data/.rspec +1 -0
- data/.travis.yml +11 -0
- data/Gemfile +6 -0
- data/LICENSE +373 -0
- data/README.md +37 -0
- data/Rakefile +7 -0
- data/baruwa.gemspec +33 -0
- data/lib/baruwa/version.rb +11 -0
- data/lib/baruwa.rb +401 -0
- data/spec/baruwa_alias_spec.rb +63 -0
- data/spec/baruwa_authservers_spec.rb +79 -0
- data/spec/baruwa_deliveryservers_spec.rb +79 -0
- data/spec/baruwa_domainalias_spec.rb +79 -0
- data/spec/baruwa_domains_spec.rb +95 -0
- data/spec/baruwa_ldapsettings_spec.rb +70 -0
- data/spec/baruwa_organizations_spec.rb +75 -0
- data/spec/baruwa_radiusettings_spec.rb +70 -0
- data/spec/baruwa_relays_spec.rb +63 -0
- data/spec/baruwa_status_spec.rb +23 -0
- data/spec/baruwa_users_spec.rb +104 -0
- data/spec/spec_helper.rb +13 -0
- metadata +135 -0
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Test Domain Aliases' do
|
4
|
+
before(:each) do
|
5
|
+
WebMock.reset!
|
6
|
+
end
|
7
|
+
|
8
|
+
before do
|
9
|
+
@baruwapi = BaruwaAPI.new('https://testbaruwa.com', '6e2347bc-278e-42f6-a84b-fa1766140cbd')
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should get domain aliases' do
|
13
|
+
domainid = 10
|
14
|
+
stub_request(:get, "https://testbaruwa.com/api/v1/domainaliases/#{domainid}").
|
15
|
+
with(:body => false,
|
16
|
+
:headers => {'Accept'=>'*/*',
|
17
|
+
'Content-Type'=>'application/json',
|
18
|
+
'User-Agent'=>'BaruwaAPI/Ruby',
|
19
|
+
'Authorization'=>'Bearer 6e2347bc-278e-42f6-a84b-fa1766140cbd'}).
|
20
|
+
to_return(:status => 200, :body => "", :headers => {})
|
21
|
+
@baruwapi.get_domainaliases(domainid)
|
22
|
+
expect(WebMock).to have_requested(:get, "#{@baruwapi.instance_variable_get(:@baruwa_url)}/domainaliases/#{domainid}")
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should get a domain alias' do
|
26
|
+
domainid = 10
|
27
|
+
aliasid = 1
|
28
|
+
stub_request(:get, "https://testbaruwa.com/api/v1/domainaliases/#{domainid}/#{aliasid}").
|
29
|
+
with(:body => false,
|
30
|
+
:headers => {'Accept'=>'*/*',
|
31
|
+
'Content-Type'=>'application/json',
|
32
|
+
'User-Agent'=>'BaruwaAPI/Ruby',
|
33
|
+
'Authorization'=>'Bearer 6e2347bc-278e-42f6-a84b-fa1766140cbd'}).
|
34
|
+
to_return(:status => 200, :body => "", :headers => {})
|
35
|
+
@baruwapi.get_domainalias(domainid, aliasid)
|
36
|
+
expect(WebMock).to have_requested(:get, "#{@baruwapi.instance_variable_get(:@baruwa_url)}/domainaliases/#{domainid}/#{aliasid}")
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should create a domain alias' do
|
40
|
+
domainid = 10
|
41
|
+
stub_request(:post, "https://testbaruwa.com/api/v1/domainaliases/#{domainid}").
|
42
|
+
with(:body => {},
|
43
|
+
:headers => {'Accept'=>'*/*',
|
44
|
+
'Content-Type'=>'application/json',
|
45
|
+
'User-Agent'=>'BaruwaAPI/Ruby',
|
46
|
+
'Authorization'=>'Bearer 6e2347bc-278e-42f6-a84b-fa1766140cbd'}).
|
47
|
+
to_return(:status => 200, :body => "", :headers => {})
|
48
|
+
@baruwapi.create_domainalias(domainid, {})
|
49
|
+
expect(WebMock).to have_requested(:post, "#{@baruwapi.instance_variable_get(:@baruwa_url)}/domainaliases/#{domainid}")
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'should update a domain alias' do
|
53
|
+
domainid = 10
|
54
|
+
aliasid = 1
|
55
|
+
stub_request(:put, "https://testbaruwa.com/api/v1/domainaliases/#{domainid}/#{aliasid}").
|
56
|
+
with(:body => {},
|
57
|
+
:headers => {'Accept'=>'*/*',
|
58
|
+
'Content-Type'=>'application/json',
|
59
|
+
'User-Agent'=>'BaruwaAPI/Ruby',
|
60
|
+
'Authorization'=>'Bearer 6e2347bc-278e-42f6-a84b-fa1766140cbd'}).
|
61
|
+
to_return(:status => 200, :body => "", :headers => {})
|
62
|
+
@baruwapi.update_domainalias(domainid, aliasid, {})
|
63
|
+
expect(WebMock).to have_requested(:put, "#{@baruwapi.instance_variable_get(:@baruwa_url)}/domainaliases/#{domainid}/#{aliasid}")
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'should delete a domain alias' do
|
67
|
+
domainid = 10
|
68
|
+
aliasid = 1
|
69
|
+
stub_request(:delete, "https://testbaruwa.com/api/v1/domainaliases/#{domainid}/#{aliasid}").
|
70
|
+
with(:body => {},
|
71
|
+
:headers => {'Accept'=>'*/*',
|
72
|
+
'Content-Type'=>'application/json',
|
73
|
+
'User-Agent'=>'BaruwaAPI/Ruby',
|
74
|
+
'Authorization'=>'Bearer 6e2347bc-278e-42f6-a84b-fa1766140cbd'}).
|
75
|
+
to_return(:status => 200, :body => "", :headers => {})
|
76
|
+
@baruwapi.delete_domainalias(domainid, aliasid, {})
|
77
|
+
expect(WebMock).to have_requested(:delete, "#{@baruwapi.instance_variable_get(:@baruwa_url)}/domainaliases/#{domainid}/#{aliasid}")
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Test Domains' do
|
4
|
+
before(:each) do
|
5
|
+
WebMock.reset!
|
6
|
+
end
|
7
|
+
|
8
|
+
before do
|
9
|
+
@baruwapi = BaruwaAPI.new('https://testbaruwa.com', '6e2347bc-278e-42f6-a84b-fa1766140cbd')
|
10
|
+
end
|
11
|
+
|
12
|
+
dom = {:name=>"example.net",
|
13
|
+
:site_url=>"http://baruwa.example.net",
|
14
|
+
:status=>"y",
|
15
|
+
:smtp_callout=>"",
|
16
|
+
:ldap_callout=>"",
|
17
|
+
:virus_checks=>"y",
|
18
|
+
:virus_checks_at_smtp=>"y",
|
19
|
+
:spam_checks=>"y",
|
20
|
+
:spam_actions=>"3",
|
21
|
+
:highspam_actions=>"3",
|
22
|
+
:virus_actions=>"3",
|
23
|
+
:low_score=>"0.0",
|
24
|
+
:high_score=>"0.0",
|
25
|
+
:message_size=>"0",
|
26
|
+
:delivery_mode=>"1",
|
27
|
+
:language=>"en",
|
28
|
+
:timezone=>"Africa/Johannesburg",
|
29
|
+
:report_every=>"3",
|
30
|
+
:organizations=>"1"}
|
31
|
+
|
32
|
+
it 'should get domains' do
|
33
|
+
stub_request(:get, "https://testbaruwa.com/api/v1/domains").
|
34
|
+
with(:body => false,
|
35
|
+
:headers => {'Accept'=>'*/*',
|
36
|
+
'Content-Type'=>'application/json',
|
37
|
+
'User-Agent'=>'BaruwaAPI/Ruby',
|
38
|
+
'Authorization'=>'Bearer 6e2347bc-278e-42f6-a84b-fa1766140cbd'}).
|
39
|
+
to_return(:status => 200, :body => "", :headers => {})
|
40
|
+
@baruwapi.get_domains()
|
41
|
+
expect(WebMock).to have_requested(:get, "#{@baruwapi.instance_variable_get(:@baruwa_url)}/domains")
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should get a domain' do
|
45
|
+
domainid = 10
|
46
|
+
stub_request(:get, "https://testbaruwa.com/api/v1/domains/#{domainid}").
|
47
|
+
with(:body => false,
|
48
|
+
:headers => {'Accept'=>'*/*',
|
49
|
+
'Content-Type'=>'application/json',
|
50
|
+
'User-Agent'=>'BaruwaAPI/Ruby',
|
51
|
+
'Authorization'=>'Bearer 6e2347bc-278e-42f6-a84b-fa1766140cbd'}).
|
52
|
+
to_return(:status => 200, :body => "", :headers => {})
|
53
|
+
@baruwapi.get_domain(domainid)
|
54
|
+
expect(WebMock).to have_requested(:get, "#{@baruwapi.instance_variable_get(:@baruwa_url)}/domains/#{domainid}")
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'should create a domain' do
|
58
|
+
stub_request(:post, "https://testbaruwa.com/api/v1/domains").
|
59
|
+
with(:body => @baruwapi.get_params(dom),
|
60
|
+
:headers => {'Accept'=>'*/*',
|
61
|
+
'Content-Type'=>'application/json',
|
62
|
+
'User-Agent'=>'BaruwaAPI/Ruby',
|
63
|
+
'Authorization'=>'Bearer 6e2347bc-278e-42f6-a84b-fa1766140cbd'}).
|
64
|
+
to_return(:status => 200, :body => "", :headers => {})
|
65
|
+
@baruwapi.create_domain(dom)
|
66
|
+
expect(WebMock).to have_requested(:post, "#{@baruwapi.instance_variable_get(:@baruwa_url)}/domains")
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'should update a domain' do
|
70
|
+
domainid = 10
|
71
|
+
stub_request(:put, "https://testbaruwa.com/api/v1/domains/#{domainid}").
|
72
|
+
with(:body => @baruwapi.get_params(dom),
|
73
|
+
:headers => {'Accept'=>'*/*',
|
74
|
+
'Content-Type'=>'application/json',
|
75
|
+
'User-Agent'=>'BaruwaAPI/Ruby',
|
76
|
+
'Authorization'=>'Bearer 6e2347bc-278e-42f6-a84b-fa1766140cbd'}).
|
77
|
+
to_return(:status => 200, :body => "", :headers => {})
|
78
|
+
@baruwapi.update_domain(domainid, dom)
|
79
|
+
expect(WebMock).to have_requested(:put, "#{@baruwapi.instance_variable_get(:@baruwa_url)}/domains/#{domainid}")
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'should delete a domain' do
|
83
|
+
domainid = 10
|
84
|
+
stub_request(:delete, "https://testbaruwa.com/api/v1/domains/#{domainid}").
|
85
|
+
with(:body => false,
|
86
|
+
:headers => {'Accept'=>'*/*',
|
87
|
+
'Content-Type'=>'application/json',
|
88
|
+
'User-Agent'=>'BaruwaAPI/Ruby',
|
89
|
+
'Authorization'=>'Bearer 6e2347bc-278e-42f6-a84b-fa1766140cbd'}).
|
90
|
+
to_return(:status => 200, :body => "", :headers => {})
|
91
|
+
@baruwapi.delete_domain(domainid)
|
92
|
+
expect(WebMock).to have_requested(:delete, "#{@baruwapi.instance_variable_get(:@baruwa_url)}/domains/#{domainid}")
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Test AD/LDAP Settings' do
|
4
|
+
before(:each) do
|
5
|
+
WebMock.reset!
|
6
|
+
end
|
7
|
+
|
8
|
+
before do
|
9
|
+
@baruwapi = BaruwaAPI.new('https://testbaruwa.com', '6e2347bc-278e-42f6-a84b-fa1766140cbd')
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should get ldap settings' do
|
13
|
+
domainid = 10
|
14
|
+
serverid = 10
|
15
|
+
settingsid = 10
|
16
|
+
stub_request(:get, "https://testbaruwa.com/api/v1/ldapsettings/#{domainid}/#{serverid}/#{settingsid}").
|
17
|
+
with(:body => false,
|
18
|
+
:headers => {'Accept'=>'*/*',
|
19
|
+
'Content-Type'=>'application/json',
|
20
|
+
'User-Agent'=>'BaruwaAPI/Ruby',
|
21
|
+
'Authorization'=>'Bearer 6e2347bc-278e-42f6-a84b-fa1766140cbd'}).
|
22
|
+
to_return(:status => 200, :body => "", :headers => {})
|
23
|
+
@baruwapi.get_ldapsettings(domainid, serverid, settingsid)
|
24
|
+
expect(WebMock).to have_requested(:get, "#{@baruwapi.instance_variable_get(:@baruwa_url)}/ldapsettings/#{domainid}/#{serverid}/#{settingsid}")
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should create ldap settings' do
|
28
|
+
domainid = 10
|
29
|
+
serverid = 10
|
30
|
+
stub_request(:post, "https://testbaruwa.com/api/v1/ldapsettings/#{domainid}/#{serverid}").
|
31
|
+
with(:body => {},
|
32
|
+
:headers => {'Accept'=>'*/*',
|
33
|
+
'Content-Type'=>'application/json',
|
34
|
+
'User-Agent'=>'BaruwaAPI/Ruby',
|
35
|
+
'Authorization'=>'Bearer 6e2347bc-278e-42f6-a84b-fa1766140cbd'}).
|
36
|
+
to_return(:status => 200, :body => "", :headers => {})
|
37
|
+
@baruwapi.create_ldapsettings(domainid, serverid, {})
|
38
|
+
expect(WebMock).to have_requested(:post, "#{@baruwapi.instance_variable_get(:@baruwa_url)}/ldapsettings/#{domainid}/#{serverid}")
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should update ldap settings' do
|
42
|
+
domainid = 10
|
43
|
+
serverid = 10
|
44
|
+
settingsid = 10
|
45
|
+
stub_request(:put, "https://testbaruwa.com/api/v1/ldapsettings/#{domainid}/#{serverid}/#{settingsid}").
|
46
|
+
with(:body => {},
|
47
|
+
:headers => {'Accept'=>'*/*',
|
48
|
+
'Content-Type'=>'application/json',
|
49
|
+
'User-Agent'=>'BaruwaAPI/Ruby',
|
50
|
+
'Authorization'=>'Bearer 6e2347bc-278e-42f6-a84b-fa1766140cbd'}).
|
51
|
+
to_return(:status => 200, :body => "", :headers => {})
|
52
|
+
@baruwapi.update_ldapsettings(domainid, serverid, settingsid, {})
|
53
|
+
expect(WebMock).to have_requested(:put, "#{@baruwapi.instance_variable_get(:@baruwa_url)}/ldapsettings/#{domainid}/#{serverid}/#{settingsid}")
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'should delete ldap settings' do
|
57
|
+
domainid = 10
|
58
|
+
serverid = 10
|
59
|
+
settingsid = 10
|
60
|
+
stub_request(:delete, "https://testbaruwa.com/api/v1/ldapsettings/#{domainid}/#{serverid}/#{settingsid}").
|
61
|
+
with(:body => {},
|
62
|
+
:headers => {'Accept'=>'*/*',
|
63
|
+
'Content-Type'=>'application/json',
|
64
|
+
'User-Agent'=>'BaruwaAPI/Ruby',
|
65
|
+
'Authorization'=>'Bearer 6e2347bc-278e-42f6-a84b-fa1766140cbd'}).
|
66
|
+
to_return(:status => 200, :body => "", :headers => {})
|
67
|
+
@baruwapi.delete_ldapsettings(domainid, serverid, settingsid, {})
|
68
|
+
expect(WebMock).to have_requested(:delete, "#{@baruwapi.instance_variable_get(:@baruwa_url)}/ldapsettings/#{domainid}/#{serverid}/#{settingsid}")
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Test Organizations' do
|
4
|
+
before(:each) do
|
5
|
+
WebMock.reset!
|
6
|
+
end
|
7
|
+
|
8
|
+
before do
|
9
|
+
@baruwapi = BaruwaAPI.new('https://testbaruwa.com', '6e2347bc-278e-42f6-a84b-fa1766140cbd')
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should get organizations' do
|
13
|
+
stub_request(:get, "https://testbaruwa.com/api/v1/organizations").
|
14
|
+
with(:body => false,
|
15
|
+
:headers => {'Accept'=>'*/*',
|
16
|
+
'Content-Type'=>'application/json',
|
17
|
+
'User-Agent'=>'BaruwaAPI/Ruby',
|
18
|
+
'Authorization'=>'Bearer 6e2347bc-278e-42f6-a84b-fa1766140cbd'}).
|
19
|
+
to_return(:status => 200, :body => "", :headers => {})
|
20
|
+
@baruwapi.get_organizations()
|
21
|
+
expect(WebMock).to have_requested(:get, "#{@baruwapi.instance_variable_get(:@baruwa_url)}/organizations")
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should get an organization' do
|
25
|
+
orgid = 10
|
26
|
+
stub_request(:get, "https://testbaruwa.com/api/v1/organizations/#{orgid}").
|
27
|
+
with(:body => false,
|
28
|
+
:headers => {'Accept'=>'*/*',
|
29
|
+
'Content-Type'=>'application/json',
|
30
|
+
'User-Agent'=>'BaruwaAPI/Ruby',
|
31
|
+
'Authorization'=>'Bearer 6e2347bc-278e-42f6-a84b-fa1766140cbd'}).
|
32
|
+
to_return(:status => 200, :body => "", :headers => {})
|
33
|
+
@baruwapi.get_organization(orgid)
|
34
|
+
expect(WebMock).to have_requested(:get, "#{@baruwapi.instance_variable_get(:@baruwa_url)}/organizations/#{orgid}")
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should create an organization' do
|
38
|
+
stub_request(:post, "https://testbaruwa.com/api/v1/organizations").
|
39
|
+
with(:body => {},
|
40
|
+
:headers => {'Accept'=>'*/*',
|
41
|
+
'Content-Type'=>'application/json',
|
42
|
+
'User-Agent'=>'BaruwaAPI/Ruby',
|
43
|
+
'Authorization'=>'Bearer 6e2347bc-278e-42f6-a84b-fa1766140cbd'}).
|
44
|
+
to_return(:status => 200, :body => "", :headers => {})
|
45
|
+
@baruwapi.create_organization({})
|
46
|
+
expect(WebMock).to have_requested(:post, "#{@baruwapi.instance_variable_get(:@baruwa_url)}/organizations")
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'should update an organization' do
|
50
|
+
orgid = 10
|
51
|
+
stub_request(:put, "https://testbaruwa.com/api/v1/organizations/#{orgid}").
|
52
|
+
with(:body => {},
|
53
|
+
:headers => {'Accept'=>'*/*',
|
54
|
+
'Content-Type'=>'application/json',
|
55
|
+
'User-Agent'=>'BaruwaAPI/Ruby',
|
56
|
+
'Authorization'=>'Bearer 6e2347bc-278e-42f6-a84b-fa1766140cbd'}).
|
57
|
+
to_return(:status => 200, :body => "", :headers => {})
|
58
|
+
@baruwapi.update_organization(orgid, {})
|
59
|
+
expect(WebMock).to have_requested(:put, "#{@baruwapi.instance_variable_get(:@baruwa_url)}/organizations/#{orgid}")
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'should delete an organization' do
|
63
|
+
orgid = 10
|
64
|
+
stub_request(:delete, "https://testbaruwa.com/api/v1/organizations/#{orgid}").
|
65
|
+
with(:body => false,
|
66
|
+
:headers => {'Accept'=>'*/*',
|
67
|
+
'Content-Type'=>'application/json',
|
68
|
+
'User-Agent'=>'BaruwaAPI/Ruby',
|
69
|
+
'Authorization'=>'Bearer 6e2347bc-278e-42f6-a84b-fa1766140cbd'}).
|
70
|
+
to_return(:status => 200, :body => "", :headers => {})
|
71
|
+
@baruwapi.delete_organization(orgid)
|
72
|
+
expect(WebMock).to have_requested(:delete, "#{@baruwapi.instance_variable_get(:@baruwa_url)}/organizations/#{orgid}")
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Test RADIUS Settings' do
|
4
|
+
before(:each) do
|
5
|
+
WebMock.reset!
|
6
|
+
end
|
7
|
+
|
8
|
+
before do
|
9
|
+
@baruwapi = BaruwaAPI.new('https://testbaruwa.com', '6e2347bc-278e-42f6-a84b-fa1766140cbd')
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should get radius settings' do
|
13
|
+
domainid = 10
|
14
|
+
serverid = 10
|
15
|
+
settingsid = 10
|
16
|
+
stub_request(:get, "https://testbaruwa.com/api/v1/radiussettings/#{domainid}/#{serverid}/#{settingsid}").
|
17
|
+
with(:body => false,
|
18
|
+
:headers => {'Accept'=>'*/*',
|
19
|
+
'Content-Type'=>'application/json',
|
20
|
+
'User-Agent'=>'BaruwaAPI/Ruby',
|
21
|
+
'Authorization'=>'Bearer 6e2347bc-278e-42f6-a84b-fa1766140cbd'}).
|
22
|
+
to_return(:status => 200, :body => "", :headers => {})
|
23
|
+
@baruwapi.get_radiussettings(domainid, serverid, settingsid)
|
24
|
+
expect(WebMock).to have_requested(:get, "#{@baruwapi.instance_variable_get(:@baruwa_url)}/radiussettings/#{domainid}/#{serverid}/#{settingsid}")
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should create radius settings' do
|
28
|
+
domainid = 10
|
29
|
+
serverid = 10
|
30
|
+
stub_request(:post, "https://testbaruwa.com/api/v1/radiussettings/#{domainid}/#{serverid}").
|
31
|
+
with(:body => {},
|
32
|
+
:headers => {'Accept'=>'*/*',
|
33
|
+
'Content-Type'=>'application/json',
|
34
|
+
'User-Agent'=>'BaruwaAPI/Ruby',
|
35
|
+
'Authorization'=>'Bearer 6e2347bc-278e-42f6-a84b-fa1766140cbd'}).
|
36
|
+
to_return(:status => 200, :body => "", :headers => {})
|
37
|
+
@baruwapi.create_radiussettings(domainid, serverid, {})
|
38
|
+
expect(WebMock).to have_requested(:post, "#{@baruwapi.instance_variable_get(:@baruwa_url)}/radiussettings/#{domainid}/#{serverid}")
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should update radius settings' do
|
42
|
+
domainid = 10
|
43
|
+
serverid = 10
|
44
|
+
settingsid = 10
|
45
|
+
stub_request(:put, "https://testbaruwa.com/api/v1/radiussettings/#{domainid}/#{serverid}/#{settingsid}").
|
46
|
+
with(:body => {},
|
47
|
+
:headers => {'Accept'=>'*/*',
|
48
|
+
'Content-Type'=>'application/json',
|
49
|
+
'User-Agent'=>'BaruwaAPI/Ruby',
|
50
|
+
'Authorization'=>'Bearer 6e2347bc-278e-42f6-a84b-fa1766140cbd'}).
|
51
|
+
to_return(:status => 200, :body => "", :headers => {})
|
52
|
+
@baruwapi.update_radiussettings(domainid, serverid, settingsid, {})
|
53
|
+
expect(WebMock).to have_requested(:put, "#{@baruwapi.instance_variable_get(:@baruwa_url)}/radiussettings/#{domainid}/#{serverid}/#{settingsid}")
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'should delete radius settings' do
|
57
|
+
domainid = 10
|
58
|
+
serverid = 10
|
59
|
+
settingsid = 10
|
60
|
+
stub_request(:delete, "https://testbaruwa.com/api/v1/radiussettings/#{domainid}/#{serverid}/#{settingsid}").
|
61
|
+
with(:body => {},
|
62
|
+
:headers => {'Accept'=>'*/*',
|
63
|
+
'Content-Type'=>'application/json',
|
64
|
+
'User-Agent'=>'BaruwaAPI/Ruby',
|
65
|
+
'Authorization'=>'Bearer 6e2347bc-278e-42f6-a84b-fa1766140cbd'}).
|
66
|
+
to_return(:status => 200, :body => "", :headers => {})
|
67
|
+
@baruwapi.delete_radiussettings(domainid, serverid, settingsid, {})
|
68
|
+
expect(WebMock).to have_requested(:delete, "#{@baruwapi.instance_variable_get(:@baruwa_url)}/radiussettings/#{domainid}/#{serverid}/#{settingsid}")
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Test Relays' do
|
4
|
+
before(:each) do
|
5
|
+
WebMock.reset!
|
6
|
+
end
|
7
|
+
|
8
|
+
before do
|
9
|
+
@baruwapi = BaruwaAPI.new('https://testbaruwa.com', '6e2347bc-278e-42f6-a84b-fa1766140cbd')
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should get a relay' do
|
13
|
+
relayid = 2
|
14
|
+
stub_request(:get, "https://testbaruwa.com/api/v1/relays/#{relayid}").
|
15
|
+
with(:body => false,
|
16
|
+
:headers => {'Accept'=>'*/*',
|
17
|
+
'Content-Type'=>'application/json',
|
18
|
+
'User-Agent'=>'BaruwaAPI/Ruby',
|
19
|
+
'Authorization'=>'Bearer 6e2347bc-278e-42f6-a84b-fa1766140cbd'}).
|
20
|
+
to_return(:status => 200, :body => "", :headers => {})
|
21
|
+
@baruwapi.get_relay(relayid)
|
22
|
+
expect(WebMock).to have_requested(:get, "#{@baruwapi.instance_variable_get(:@baruwa_url)}/relays/#{relayid}")
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should create a relay' do
|
26
|
+
orgid = 2
|
27
|
+
stub_request(:post, "https://testbaruwa.com/api/v1/relays/#{orgid}").
|
28
|
+
with(:body => {},
|
29
|
+
:headers => {'Accept'=>'*/*',
|
30
|
+
'Content-Type'=>'application/json',
|
31
|
+
'User-Agent'=>'BaruwaAPI/Ruby',
|
32
|
+
'Authorization'=>'Bearer 6e2347bc-278e-42f6-a84b-fa1766140cbd'}).
|
33
|
+
to_return(:status => 200, :body => "", :headers => {})
|
34
|
+
@baruwapi.create_relay(orgid, {})
|
35
|
+
expect(WebMock).to have_requested(:post, "#{@baruwapi.instance_variable_get(:@baruwa_url)}/relays/#{orgid}")
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should update a relay' do
|
39
|
+
relayid = 2
|
40
|
+
stub_request(:put, "https://testbaruwa.com/api/v1/relays/#{relayid}").
|
41
|
+
with(:body => {},
|
42
|
+
:headers => {'Accept'=>'*/*',
|
43
|
+
'Content-Type'=>'application/json',
|
44
|
+
'User-Agent'=>'BaruwaAPI/Ruby',
|
45
|
+
'Authorization'=>'Bearer 6e2347bc-278e-42f6-a84b-fa1766140cbd'}).
|
46
|
+
to_return(:status => 200, :body => "", :headers => {})
|
47
|
+
@baruwapi.update_relay(relayid, {})
|
48
|
+
expect(WebMock).to have_requested(:put, "#{@baruwapi.instance_variable_get(:@baruwa_url)}/relays/#{relayid}")
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'should delete a relay' do
|
52
|
+
relayid = 2
|
53
|
+
stub_request(:delete, "https://testbaruwa.com/api/v1/relays/#{relayid}").
|
54
|
+
with(:body => {},
|
55
|
+
:headers => {'Accept'=>'*/*',
|
56
|
+
'Content-Type'=>'application/json',
|
57
|
+
'User-Agent'=>'BaruwaAPI/Ruby',
|
58
|
+
'Authorization'=>'Bearer 6e2347bc-278e-42f6-a84b-fa1766140cbd'}).
|
59
|
+
to_return(:status => 200, :body => "", :headers => {})
|
60
|
+
@baruwapi.delete_relay(relayid, {})
|
61
|
+
expect(WebMock).to have_requested(:delete, "#{@baruwapi.instance_variable_get(:@baruwa_url)}/relays/#{relayid}")
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Test System Status' do
|
4
|
+
before(:each) do
|
5
|
+
WebMock.reset!
|
6
|
+
end
|
7
|
+
|
8
|
+
before do
|
9
|
+
@baruwapi = BaruwaAPI.new('https://testbaruwa.com', '6e2347bc-278e-42f6-a84b-fa1766140cbd')
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should get system status' do
|
13
|
+
stub_request(:get, "https://testbaruwa.com/api/v1/status").
|
14
|
+
with(:body => false,
|
15
|
+
:headers => {'Accept'=>'*/*',
|
16
|
+
'Content-Type'=>'application/json',
|
17
|
+
'User-Agent'=>'BaruwaAPI/Ruby',
|
18
|
+
'Authorization'=>'Bearer 6e2347bc-278e-42f6-a84b-fa1766140cbd'}).
|
19
|
+
to_return(:status => 200, :body => "", :headers => {})
|
20
|
+
@baruwapi.get_status()
|
21
|
+
expect(WebMock).to have_requested(:get, "#{@baruwapi.instance_variable_get(:@baruwa_url)}/status")
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'cgi'
|
3
|
+
|
4
|
+
describe 'Test Users' do
|
5
|
+
before(:each) do
|
6
|
+
WebMock.reset!
|
7
|
+
end
|
8
|
+
|
9
|
+
before do
|
10
|
+
@baruwapi = BaruwaAPI.new('https://testbaruwa.com', '6e2347bc-278e-42f6-a84b-fa1766140cbd')
|
11
|
+
end
|
12
|
+
|
13
|
+
user = {:username=>"blossom",
|
14
|
+
:firstname=>"Blossom",
|
15
|
+
:lastname=>"Utonium",
|
16
|
+
:password1=>"ng5qhhbiwozcANc3",
|
17
|
+
:password2=>"ng5qhhbiwozcANc3",
|
18
|
+
:email=>"blossom@example.com",
|
19
|
+
:timezone=>"Africa/Johannesburg",
|
20
|
+
:account_type=>"3",
|
21
|
+
:domains=>"9",
|
22
|
+
:active=>"y",
|
23
|
+
:send_report=>"y",
|
24
|
+
:spam_checks=>"y",
|
25
|
+
:low_score=>"0.0",
|
26
|
+
:high_score=>"0.0"}
|
27
|
+
|
28
|
+
it 'should get users' do
|
29
|
+
stub_request(:get, "https://testbaruwa.com/api/v1/users").
|
30
|
+
with(:body => false,
|
31
|
+
:headers => {'Accept'=>'*/*',
|
32
|
+
'Content-Type'=>'application/json',
|
33
|
+
'User-Agent'=>'BaruwaAPI/Ruby',
|
34
|
+
'Authorization'=>'Bearer 6e2347bc-278e-42f6-a84b-fa1766140cbd'}).
|
35
|
+
to_return(:status => 200, :body => "", :headers => {})
|
36
|
+
@baruwapi.get_users()
|
37
|
+
expect(WebMock).to have_requested(:get, "#{@baruwapi.instance_variable_get(:@baruwa_url)}/users")
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should get a user' do
|
41
|
+
userid = 20
|
42
|
+
stub_request(:get, "https://testbaruwa.com/api/v1/users/#{userid}").
|
43
|
+
with(:body => false,
|
44
|
+
:headers => {'Accept'=>'*/*',
|
45
|
+
'Content-Type'=>'application/json',
|
46
|
+
'User-Agent'=>'BaruwaAPI/Ruby',
|
47
|
+
'Authorization'=>'Bearer 6e2347bc-278e-42f6-a84b-fa1766140cbd'}).
|
48
|
+
to_return(:status => 200, :body => "", :headers => {})
|
49
|
+
@baruwapi.get_user(userid)
|
50
|
+
expect(WebMock).to have_requested(:get, "#{@baruwapi.instance_variable_get(:@baruwa_url)}/users/#{userid}")
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'should create a user' do
|
54
|
+
stub_request(:post, "https://testbaruwa.com/api/v1/users").
|
55
|
+
with(:body => @baruwapi.get_params(user),
|
56
|
+
:headers => {'Accept'=>'*/*',
|
57
|
+
'Content-Type'=>'application/json',
|
58
|
+
'User-Agent'=>'BaruwaAPI/Ruby',
|
59
|
+
'Authorization'=>'Bearer 6e2347bc-278e-42f6-a84b-fa1766140cbd'}).
|
60
|
+
to_return(:status => 200, :body => "", :headers => {})
|
61
|
+
@baruwapi.create_user(user)
|
62
|
+
expect(WebMock).to have_requested(:post, "#{@baruwapi.instance_variable_get(:@baruwa_url)}/users")
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'should update a user' do
|
66
|
+
stub_request(:put, "https://testbaruwa.com/api/v1/users").
|
67
|
+
with(:body => @baruwapi.get_params(user),
|
68
|
+
:headers => {'Accept'=>'*/*',
|
69
|
+
'Content-Type'=>'application/json',
|
70
|
+
'User-Agent'=>'BaruwaAPI/Ruby',
|
71
|
+
'Authorization'=>'Bearer 6e2347bc-278e-42f6-a84b-fa1766140cbd'}).
|
72
|
+
to_return(:status => 200, :body => "", :headers => {})
|
73
|
+
@baruwapi.update_user(user)
|
74
|
+
expect(WebMock).to have_requested(:put, "#{@baruwapi.instance_variable_get(:@baruwa_url)}/users")
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'should delete a user' do
|
78
|
+
userid = 20
|
79
|
+
stub_request(:delete, "https://testbaruwa.com/api/v1/users/#{userid}").
|
80
|
+
with(:body => false,
|
81
|
+
:headers => {'Accept'=>'*/*',
|
82
|
+
'Content-Type'=>'application/json',
|
83
|
+
'User-Agent'=>'BaruwaAPI/Ruby',
|
84
|
+
'Authorization'=>'Bearer 6e2347bc-278e-42f6-a84b-fa1766140cbd'}).
|
85
|
+
to_return(:status => 200, :body => "", :headers => {})
|
86
|
+
@baruwapi.delete_user(userid)
|
87
|
+
expect(WebMock).to have_requested(:delete, "#{@baruwapi.instance_variable_get(:@baruwa_url)}/users/#{userid}")
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'should set a user password' do
|
91
|
+
userid = 20
|
92
|
+
data = {:password1=>"Hp9hzcd1grdSqtrn",
|
93
|
+
:password2=>"Hp9hzcd1grdSqtrn"}
|
94
|
+
stub_request(:post, "https://testbaruwa.com/api/v1/users/chpw/#{userid}").
|
95
|
+
with(:body => @baruwapi.get_params(data),
|
96
|
+
:headers => {'Accept'=>'*/*',
|
97
|
+
'Content-Type'=>'application/json',
|
98
|
+
'User-Agent'=>'BaruwaAPI/Ruby',
|
99
|
+
'Authorization'=>'Bearer 6e2347bc-278e-42f6-a84b-fa1766140cbd'}).
|
100
|
+
to_return(:status => 200, :body => "", :headers => {})
|
101
|
+
@baruwapi.set_user_passwd(userid, data)
|
102
|
+
expect(WebMock).to have_requested(:post, "#{@baruwapi.instance_variable_get(:@baruwa_url)}/users/chpw/#{userid}")
|
103
|
+
end
|
104
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require "codeclimate-test-reporter"
|
2
|
+
CodeClimate::TestReporter.start
|
3
|
+
require 'simplecov'
|
4
|
+
SimpleCov.start
|
5
|
+
require 'rubygems'
|
6
|
+
require 'json'
|
7
|
+
require 'rspec'
|
8
|
+
require 'webmock/rspec'
|
9
|
+
require 'baruwa'
|
10
|
+
|
11
|
+
ENV['CODECLIMATE_REPO_TOKEN'] = "69a832cbd11706e0578a20c2aae40d42cf520f3a9a776932bc32833dd1b58f2b"
|
12
|
+
|
13
|
+
WebMock.disable_net_connect!(:allow_localhost => true, :allow => "codeclimate.com")
|