Birst_Command 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +0,0 @@
1
- {
2
- "wsdl": "https://app2102.bws.birst.com/CommandWebService.asmx?WSDL",
3
- "endpoint": "https://app2102.bws.birst.com/CommandWebService.asmx",
4
- "username": "name@myplace.com",
5
- "password": "obfuscated pwd"
6
- }
@@ -1,28 +0,0 @@
1
- module Birst_Command
2
- require 'erb'
3
- module Config
4
- extend self
5
-
6
- attr_accessor :config_full_path
7
- @config_full_path = File.join(File.dirname(__FILE__),"../../config.json")
8
-
9
- attr_accessor :options
10
- @options = {
11
- :soap_log_level => :error,
12
- :soap_log => false
13
- }
14
-
15
- def read_config(config_full_path = @config_full_path)
16
- parse_erb = ERB.new(IO.read(config_full_path)).result(binding)
17
- parse_json = JSON.parse(parse_erb, :symbolize_names => true)
18
- @options = @options.merge!(parse_json)
19
- end
20
-
21
- def set_debug
22
- @options = @options.merge!({
23
- :soap_log_level => :debug,
24
- :soap_log => true
25
- })
26
- end
27
- end
28
- end
@@ -1 +0,0 @@
1
- /config_test.json
@@ -1,8 +0,0 @@
1
- {
2
- "test": {
3
- "test_add_user_to_space": {
4
- "username": "mytestuser@company.com",
5
- "space_id": "MYTESTSPACEID"
6
- }
7
- }
8
- }
@@ -1,4 +0,0 @@
1
- {
2
- "username": "name@myplace.com",
3
- "password": "obfuscated pwd"
4
- }
@@ -1,49 +0,0 @@
1
- require "test_birst_command"
2
-
3
- class Test_add_user_to_space < Test::Unit::TestCase
4
-
5
- def setup
6
- Birst_Command::Config.read_config
7
- Birst_Command::Config.read_config(File.join(File.dirname(__FILE__),"../config_test.json"))
8
- @test_options = Birst_Command::Config.options[:test][:test_add_user_to_space]
9
- end
10
-
11
-
12
- def teardown
13
- end
14
-
15
-
16
- def user_exists?
17
- result = nil
18
- Session.start do |bc|
19
- users = bc.list_users_in_space :spaceID => @test_options[:space_id]
20
- result = [users[:string]].flatten.include? @test_options[:username]
21
- end
22
- result
23
- end
24
-
25
-
26
- def test_add_user_to_space
27
- Session.start do |bc|
28
- bc.add_user_to_space :userName => @test_options[:username],
29
- :spaceID => @test_options[:space_id],
30
- :hasAdmin => "false"
31
- end
32
-
33
- assert user_exists?, "User #{@test_options[:username]} not added!"
34
- end
35
-
36
-
37
- def test_remove_user_from_space
38
- test_add_user_to_space if !user_exists?
39
-
40
- Session.start do |bc|
41
- bc.remove_user_from_space :userName => @test_options[:username],
42
- :spaceID => @test_options[:space_id]
43
- end
44
-
45
- assert !user_exists?, "User #{@test_options[:username]} should no longer exist!"
46
- end
47
- end
48
-
49
-
@@ -1,44 +0,0 @@
1
- require "test_birst_command"
2
-
3
- class Test_command_helper < Test::Unit::TestCase
4
-
5
- # Decided that commands should return whatever the Birst API returns.
6
- # However, for user code, it would be helpful to customize returns for
7
- # specific use cases
8
-
9
- class Session < Birst_Command::Session
10
- def list_spaces(*args)
11
- result = command __method__, *args
12
- [result[:user_space]].flatten
13
- end
14
- def list_users_in_space(*args)
15
- result = command __method__, *args
16
- [result[:string]].flatten
17
- end
18
- end
19
-
20
-
21
- def setup
22
- Birst_Command::Config.read_config
23
- Birst_Command::Config.read_config(File.join(File.dirname(__FILE__),"../config_test.json"))
24
- end
25
-
26
- def teardown
27
- end
28
-
29
- def test_add_user_to_space
30
- test_options = Birst_Command::Config.options[:test][:test_add_user_to_space]
31
-
32
- spaces = nil
33
- users = nil
34
- Session.start do |bc|
35
- spaces = bc.list_spaces
36
- users = bc.list_users_in_space :spaceID => test_options[:space_id]
37
- end
38
-
39
- assert spaces.is_a?(Array), "list_spaces helper did not return an array"
40
- assert !spaces[0].has_key?(:user_space), "list_spaces helper should not give :user_space"
41
- end
42
- end
43
-
44
-
@@ -1,61 +0,0 @@
1
- require "test_birst_command"
2
-
3
- class Test_cookie < Test::Unit::TestCase
4
-
5
- def setup
6
- Birst_Command::Config.read_config
7
- Birst_Command::Config.read_config(File.join(File.dirname(__FILE__),"../config_test.json"))
8
- @new_space_id = nil
9
- end
10
-
11
- def teardown
12
- Session.start do |bc|
13
- bc.delete_space :spaceId => @new_space_id
14
- end
15
- end
16
-
17
- def test_cookie_using_a_copy_command
18
- test_options = Birst_Command::Config.options[:test][:test_copy_space]
19
-
20
- session_cookie = nil
21
- job_token = nil
22
- Session.start do |bc|
23
- @new_space_id = bc.create_new_space :spaceName => "test_copy_space",
24
- :comments => "",
25
- :automatic => "false"
26
-
27
- puts "#{JSON.pretty_generate bc.list_spaces}"
28
- job_token = bc.copy_space :spFromID => test_options[:from_space_id],
29
- :spToID => @new_space_id,
30
- :mode => "copy",
31
- :options => "data;settings-permissions;settings-membership;repository;birst-connect;custom-subject-areas;dashboardstyles;salesforce;catalog;CustomGeoMaps.xml;spacesettings.xml;SavedExpressions.xml;DrillMaps.xml;connectors;datastore-aggregates;settings-basic"
32
-
33
- session_cookie = bc.auth_cookies
34
- end
35
-
36
- puts "COOKIE COOKIE: #{session_cookie}"
37
-
38
- i = 0
39
- loop do
40
- i += 1
41
- if i < 60
42
- is_job_complete = false
43
- Session.start use_cookie: session_cookie do |bc|
44
- is_job_complete = bc.is_job_complete :jobToken => job_token
45
- end
46
- puts "COMPLETE? #{is_job_complete}"
47
-
48
- sleep 1
49
- break if is_job_complete
50
- else
51
- raise "Copy job timed out"
52
- end
53
-
54
- end
55
-
56
-
57
- # This test sucks, but it will fail if the cookies don't work
58
- assert_equal 36, @new_space_id.length, "Got an invalid space id #{@new_space_id}"
59
- end
60
- end
61
-
@@ -1,55 +0,0 @@
1
- require "test_birst_command"
2
-
3
- class Test_copy_space < Test::Unit::TestCase
4
-
5
- def setup
6
- Birst_Command::Config.read_config
7
- Birst_Command::Config.read_config(File.join(File.dirname(__FILE__),"../config_test.json"))
8
- @new_space_id = nil
9
- end
10
-
11
- def teardown
12
- Session.start do |bc|
13
- bc.delete_space :spaceId => @new_space_id
14
- end
15
- end
16
-
17
- def test_copy_space
18
- test_options = Birst_Command::Config.options[:test][:test_copy_space]
19
-
20
- Session.start do |bc|
21
- @new_space_id = bc.create_new_space :spaceName => "test_copy_space",
22
- :comments => "",
23
- :automatic => "false"
24
-
25
- puts "#{JSON.pretty_generate bc.list_spaces}"
26
- job_token = bc.copy_space :spFromID => test_options[:from_space_id],
27
- :spToID => @new_space_id,
28
- :mode => "copy",
29
- :options => "data;settings-permissions;settings-membership;repository;birst-connect;custom-subject-areas;dashboardstyles;salesforce;catalog;CustomGeoMaps.xml;spacesettings.xml;SavedExpressions.xml;DrillMaps.xml;connectors;datastore-aggregates;settings-basic"
30
-
31
-
32
- i = 0
33
- loop do
34
- i += 1
35
- if i < 60
36
- status = bc.get_job_status :jobToken => job_token
37
- puts "#{JSON.pretty_generate status}"
38
-
39
- is_job_complete = bc.is_job_complete :jobToken => job_token
40
- puts "COMPLETE? #{is_job_complete}"
41
- sleep 1
42
-
43
- break if is_job_complete
44
- else
45
- raise "Copy job timed out"
46
- end
47
- end
48
-
49
-
50
- end
51
-
52
- assert_equal 36, @new_space_id.length, "Got an invalid space id #{@new_space_id}"
53
- end
54
- end
55
-
@@ -1,24 +0,0 @@
1
- require "test_birst_command"
2
-
3
- class Test_list_spaces < Test::Unit::TestCase
4
-
5
- def setup
6
- Birst_Command::Config.read_config
7
- end
8
-
9
- def teardown
10
- end
11
-
12
- def test_list_spaces
13
- spaces = nil
14
- Session.start do |bc|
15
- unclean_spaces = bc.list_spaces
16
- spaces = [unclean_spaces[:user_space]].flatten
17
- end
18
-
19
- assert spaces.is_a?(Array), "Expecting spaces to be an array"
20
- assert spaces[0].is_a?(Hash), "Expecting spaces to be an array of hashes"
21
- end
22
- end
23
-
24
-
@@ -1,23 +0,0 @@
1
- require "test_birst_command"
2
-
3
- class Test_login < Test::Unit::TestCase
4
-
5
- def setup
6
- Birst_Command::Config.read_config
7
- end
8
-
9
- def teardown
10
- end
11
-
12
- def test_login
13
- token = ""
14
- Session.start do |bc|
15
- token = bc.token
16
- end
17
-
18
- assert_equal 32, token.length, "Got an invalid token #{token}"
19
- end
20
-
21
- end
22
-
23
-
@@ -1,21 +0,0 @@
1
- require "test_birst_command"
2
-
3
- class Test_password < Test::Unit::TestCase
4
-
5
- def setup
6
- ENV['ENVCRYPT_KEY'] = '9Aqck/FZ0pCRkiw95VpxLw==$kxnYLOCo9qHDHHaTZM+fN73WVclDkRqO+uxSgzFzrpQ=$qoEtCm1BQWgc+WAxpotsrw=='
7
-
8
- @password = "mysecretpass"
9
- @encrypted = "MBTkxkMT8AbQupkOwtG9uQ=="
10
- end
11
-
12
- def teardown
13
- end
14
-
15
- def test_decrypt
16
- crypt = Envcrypt::Envcrypter.new
17
- assert_equal @password, crypt.decrypt(@encrypted), "Wrong decrypted password"
18
- end
19
- end
20
-
21
-
@@ -1,18 +0,0 @@
1
- require "test_birst_command"
2
-
3
- class Test_read_config < Test::Unit::TestCase
4
-
5
- def setup
6
- end
7
-
8
- def teardown
9
- end
10
-
11
- def test_read_config
12
- Birst_Command::Config.read_config(File.join(File.dirname(__FILE__),"resources/config_test.json"))
13
- assert_equal "name@myplace.com", Birst_Command::Config.options[:username], "Error with config file"
14
- end
15
-
16
- end
17
-
18
-
@@ -1,10 +0,0 @@
1
- require 'rubygems'
2
- require 'bundler/setup'
3
-
4
- require 'birst_command'
5
- require 'test/unit'
6
- require 'benchmark'
7
-
8
- Birst_Command::Config.set_debug
9
-
10
- include Birst_Command