leap_salesforce 0.1.17 → 0.1.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.idea/dictionaries/iqa.xml +1 -0
- data/.idea/leap-salesforce.iml +9 -8
- data/ChangeLog +5 -0
- data/lib/leap_salesforce/parameters.rb +9 -1
- data/lib/leap_salesforce/soql_data/soql_data.rb +10 -0
- data/lib/leap_salesforce/soql_data/soql_global_object_data.rb +12 -0
- data/lib/leap_salesforce/soql_data/soql_handler.rb +7 -1
- data/lib/leap_salesforce/users/users.rb +1 -1
- data/lib/leap_salesforce/version.rb +1 -1
- data/lib/leap_salesforce.rb +15 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 467199374ed9914ed99da0b95b4c9fbe7105eed96b1456ea469d55c1cfadc0f9
|
4
|
+
data.tar.gz: 1aca36e08dca7f60197fc8809d2fa69a1468087c0114c0fc70964cb0b46c80c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18f11ad55eee275cad36b44ba80eef5a34ba1de1cdba00d2c40541bf2449dedf29234f3854a1629e174d6353916ee40e834ea2ec0f4bc351a1142e0e60613a1e
|
7
|
+
data.tar.gz: ed67318c6a72655e8053d02f945ed133e6bf8461a89fc00ea7dd7684402d30291375c046b418f3465a2edcf33f45ddac1345027557cfc9a75623be041ea3d2a2
|
data/.idea/dictionaries/iqa.xml
CHANGED
data/.idea/leap-salesforce.iml
CHANGED
@@ -7,12 +7,11 @@
|
|
7
7
|
<content url="file://$MODULE_DIR$" />
|
8
8
|
<orderEntry type="jdk" jdkName="RVM: ruby-2.6.0" jdkType="RUBY_SDK" />
|
9
9
|
<orderEntry type="sourceFolder" forTests="false" />
|
10
|
-
<orderEntry type="library" scope="PROVIDED" name="activemodel (
|
11
|
-
<orderEntry type="library" scope="PROVIDED" name="activerecord (
|
12
|
-
<orderEntry type="library" scope="PROVIDED" name="activesupport (
|
10
|
+
<orderEntry type="library" scope="PROVIDED" name="activemodel (v6.0.0, RVM: ruby-2.6.0) [gem]" level="application" />
|
11
|
+
<orderEntry type="library" scope="PROVIDED" name="activerecord (v6.0.0, RVM: ruby-2.6.0) [gem]" level="application" />
|
12
|
+
<orderEntry type="library" scope="PROVIDED" name="activesupport (v6.0.0, RVM: ruby-2.6.0) [gem]" level="application" />
|
13
13
|
<orderEntry type="library" scope="PROVIDED" name="addressable (v2.6.0, RVM: ruby-2.6.0) [gem]" level="application" />
|
14
14
|
<orderEntry type="library" scope="PROVIDED" name="akami (v1.3.1, RVM: ruby-2.6.0) [gem]" level="application" />
|
15
|
-
<orderEntry type="library" scope="PROVIDED" name="arel (v9.0.0, RVM: ruby-2.6.0) [gem]" level="application" />
|
16
15
|
<orderEntry type="library" scope="PROVIDED" name="ast (v2.4.0, RVM: ruby-2.6.0) [gem]" level="application" />
|
17
16
|
<orderEntry type="library" scope="PROVIDED" name="builder (v3.2.3, RVM: ruby-2.6.0) [gem]" level="application" />
|
18
17
|
<orderEntry type="library" scope="PROVIDED" name="bundler (v2.0.2, RVM: ruby-2.6.0) [gem]" level="application" />
|
@@ -25,6 +24,7 @@
|
|
25
24
|
<orderEntry type="library" scope="PROVIDED" name="faker (v2.1.2, RVM: ruby-2.6.0) [gem]" level="application" />
|
26
25
|
<orderEntry type="library" scope="PROVIDED" name="gyoku (v1.3.1, RVM: ruby-2.6.0) [gem]" level="application" />
|
27
26
|
<orderEntry type="library" scope="PROVIDED" name="hashie (v3.6.0, RVM: ruby-2.6.0) [gem]" level="application" />
|
27
|
+
<orderEntry type="library" scope="PROVIDED" name="http-accept (v1.7.0, RVM: ruby-2.6.0) [gem]" level="application" />
|
28
28
|
<orderEntry type="library" scope="PROVIDED" name="http-cookie (v1.0.3, RVM: ruby-2.6.0) [gem]" level="application" />
|
29
29
|
<orderEntry type="library" scope="PROVIDED" name="httpi (v2.4.4, RVM: ruby-2.6.0) [gem]" level="application" />
|
30
30
|
<orderEntry type="library" scope="PROVIDED" name="humanize (v2.1.1, RVM: ruby-2.6.0) [gem]" level="application" />
|
@@ -51,9 +51,9 @@
|
|
51
51
|
<orderEntry type="library" scope="PROVIDED" name="rack-protection (v2.0.4, RVM: ruby-2.6.0) [gem]" level="application" />
|
52
52
|
<orderEntry type="library" scope="PROVIDED" name="rainbow (v3.0.0, RVM: ruby-2.6.0) [gem]" level="application" />
|
53
53
|
<orderEntry type="library" scope="PROVIDED" name="rake (v12.3.3, RVM: ruby-2.6.0) [gem]" level="application" />
|
54
|
-
<orderEntry type="library" scope="PROVIDED" name="random-port (v0.
|
54
|
+
<orderEntry type="library" scope="PROVIDED" name="random-port (v0.4.1, RVM: ruby-2.6.0) [gem]" level="application" />
|
55
55
|
<orderEntry type="library" scope="PROVIDED" name="require_all (v2.0.0, RVM: ruby-2.6.0) [gem]" level="application" />
|
56
|
-
<orderEntry type="library" scope="PROVIDED" name="rest-client (v2.0
|
56
|
+
<orderEntry type="library" scope="PROVIDED" name="rest-client (v2.1.0, RVM: ruby-2.6.0) [gem]" level="application" />
|
57
57
|
<orderEntry type="library" scope="PROVIDED" name="rspec (v3.8.0, RVM: ruby-2.6.0) [gem]" level="application" />
|
58
58
|
<orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.8.0, RVM: ruby-2.6.0) [gem]" level="application" />
|
59
59
|
<orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.8.3, RVM: ruby-2.6.0) [gem]" level="application" />
|
@@ -67,13 +67,13 @@
|
|
67
67
|
<orderEntry type="library" scope="PROVIDED" name="sinatra (v2.0.4, RVM: ruby-2.6.0) [gem]" level="application" />
|
68
68
|
<orderEntry type="library" scope="PROVIDED" name="sinatra-basic-auth (v0.1.0, RVM: ruby-2.6.0) [gem]" level="application" />
|
69
69
|
<orderEntry type="library" scope="PROVIDED" name="sinatra-docdsl (v0.8.6, RVM: ruby-2.6.0) [gem]" level="application" />
|
70
|
-
<orderEntry type="library" scope="PROVIDED" name="soaspec (v0.2.
|
70
|
+
<orderEntry type="library" scope="PROVIDED" name="soaspec (v0.2.31, RVM: ruby-2.6.0) [gem]" level="application" />
|
71
71
|
<orderEntry type="library" scope="PROVIDED" name="socksify (v1.7.1, RVM: ruby-2.6.0) [gem]" level="application" />
|
72
72
|
<orderEntry type="library" scope="PROVIDED" name="thor (v0.20.3, RVM: ruby-2.6.0) [gem]" level="application" />
|
73
73
|
<orderEntry type="library" scope="PROVIDED" name="thread_safe (v0.3.6, RVM: ruby-2.6.0) [gem]" level="application" />
|
74
74
|
<orderEntry type="library" scope="PROVIDED" name="tilt (v2.0.9, RVM: ruby-2.6.0) [gem]" level="application" />
|
75
75
|
<orderEntry type="library" scope="PROVIDED" name="to_regexp (v0.2.1, RVM: ruby-2.6.0) [gem]" level="application" />
|
76
|
-
<orderEntry type="library" scope="PROVIDED" name="topoisomerase (v0.1.
|
76
|
+
<orderEntry type="library" scope="PROVIDED" name="topoisomerase (v0.1.5, RVM: ruby-2.6.0) [gem]" level="application" />
|
77
77
|
<orderEntry type="library" scope="PROVIDED" name="tzinfo (v1.2.5, RVM: ruby-2.6.0) [gem]" level="application" />
|
78
78
|
<orderEntry type="library" scope="PROVIDED" name="unf (v0.1.4, RVM: ruby-2.6.0) [gem]" level="application" />
|
79
79
|
<orderEntry type="library" scope="PROVIDED" name="unf_ext (v0.0.7.6, RVM: ruby-2.6.0) [gem]" level="application" />
|
@@ -82,5 +82,6 @@
|
|
82
82
|
<orderEntry type="library" scope="PROVIDED" name="xml-simple (v1.1.5, RVM: ruby-2.6.0) [gem]" level="application" />
|
83
83
|
<orderEntry type="library" scope="PROVIDED" name="yard (v0.9.19, RVM: ruby-2.6.0) [gem]" level="application" />
|
84
84
|
<orderEntry type="library" scope="PROVIDED" name="yard-doctest (v0.1.16, RVM: ruby-2.6.0) [gem]" level="application" />
|
85
|
+
<orderEntry type="library" scope="PROVIDED" name="zeitwerk (v2.1.9, RVM: ruby-2.6.0) [gem]" level="application" />
|
85
86
|
</component>
|
86
87
|
</module>
|
data/ChangeLog
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require_relative 'users/users'
|
4
4
|
require_relative 'soql_object'
|
5
|
+
require 'logger'
|
5
6
|
|
6
7
|
# Adding parameters to set for authentication, environment and other common settings
|
7
8
|
module LeapSalesforce
|
@@ -13,6 +14,8 @@ module LeapSalesforce
|
|
13
14
|
@client_secret = ENV['client_secret']
|
14
15
|
@password = ENV['password']
|
15
16
|
@environment = nil
|
17
|
+
@logger = Logger.new STDOUT
|
18
|
+
@sfdx = false
|
16
19
|
class << self
|
17
20
|
# @return [String] Environment to use for tests. This can be accessed to change the username used to login
|
18
21
|
# to test.salesforce with. This can be set on the command line with 'LEAP_ENV'
|
@@ -86,12 +89,17 @@ module LeapSalesforce
|
|
86
89
|
attr_accessor :objects_to_verify
|
87
90
|
# @return [Array] List of Soql Objects identified for Leap Salesforce to maintain
|
88
91
|
attr_reader :soql_objects
|
89
|
-
|
92
|
+
# @return [Logger] Logger used by LeapSalesforce
|
93
|
+
attr_accessor :logger
|
90
94
|
# @return [Array] list_of_soql_objects Array describing Soql objects taken from .leap_salesforce.yml
|
91
95
|
def soql_objects=(list_of_soql_objects)
|
92
96
|
@soql_objects = list_of_soql_objects.collect do |soql_object_desc|
|
93
97
|
SoqlObject.new(soql_object_desc)
|
94
98
|
end
|
95
99
|
end
|
100
|
+
# Setting this variable uses sfdx for authentication and other actions such
|
101
|
+
# as opening an organisation link
|
102
|
+
# @return [Boolean] Whether Salesforce sfdx is being used
|
103
|
+
attr_accessor :sfdx
|
96
104
|
end
|
97
105
|
end
|
@@ -100,6 +100,16 @@ class SoqlData < Exchange
|
|
100
100
|
self
|
101
101
|
end
|
102
102
|
|
103
|
+
# @deprecated
|
104
|
+
# Get details of itself by searching for it's id
|
105
|
+
# Store response within itself
|
106
|
+
# @return [Exchange] Exchange with details of data
|
107
|
+
def get
|
108
|
+
LeapSalesforce.logger.warn "Method 'get' called when it is deprecated" \
|
109
|
+
" from #{caller_locations[0]}"
|
110
|
+
find
|
111
|
+
end
|
112
|
+
|
103
113
|
# Update current record with data provided
|
104
114
|
# @param [Hash] data Data to update exchange with
|
105
115
|
def update(data)
|
@@ -89,6 +89,16 @@ module SoqlGlobalObjectData
|
|
89
89
|
instance_to_get
|
90
90
|
end
|
91
91
|
|
92
|
+
# @deprecated
|
93
|
+
# Get details of itself by searching for it's id
|
94
|
+
# Store response within itself
|
95
|
+
# @return [Exchange] Exchange with details of data
|
96
|
+
def get(lookup)
|
97
|
+
LeapSalesforce.logger.warn "Method 'get' called when it is deprecated" \
|
98
|
+
" from #{caller_locations[0]}"
|
99
|
+
find(lookup)
|
100
|
+
end
|
101
|
+
|
92
102
|
# @return [self] SoqlData object that is the result of looking up id based on lookup criteria
|
93
103
|
def lookup_id(lookup)
|
94
104
|
teardown = lookup.delete(:teardown)
|
@@ -183,6 +193,7 @@ module SoqlGlobalObjectData
|
|
183
193
|
# rubocop:disable Metrics/AbcSize
|
184
194
|
def soql_element(name, backend_name)
|
185
195
|
# Either set the element (if creating a new record) or update the object
|
196
|
+
# @todo: ensure next time an element is retrieved it's not from a cached value
|
186
197
|
# @param [String] new_value Value to update record to
|
187
198
|
define_method("#{name}=") do |new_value|
|
188
199
|
if @response
|
@@ -199,6 +210,7 @@ module SoqlGlobalObjectData
|
|
199
210
|
rescue NoElementAtPath
|
200
211
|
raise diagnose_error if error_message?
|
201
212
|
|
213
|
+
# TODO: Response here should not be necessary. Only find is
|
202
214
|
@response = find.response
|
203
215
|
self[backend_name]
|
204
216
|
end
|
@@ -7,7 +7,13 @@ require 'soaspec'
|
|
7
7
|
# Credentials are stored either in 'config/credentials' folder or via environment variables
|
8
8
|
# To check out SOQL SCHEMA go to workbench.developerforce.com. Use Sandbox and login
|
9
9
|
class SoqlHandler < Soaspec::RestHandler
|
10
|
-
oauth2 LeapSalesforce.oauth_settings
|
10
|
+
oauth2 LeapSalesforce.oauth_settings unless LeapSalesforce.sfdx
|
11
|
+
if LeapSalesforce.sfdx
|
12
|
+
# @return [String]
|
13
|
+
def instance_url
|
14
|
+
# TODO: Get this
|
15
|
+
end
|
16
|
+
end
|
11
17
|
base_url '<%= instance_url %>/services/data/v<%= api_version %>/'
|
12
18
|
|
13
19
|
pascal_keys true
|
@@ -10,7 +10,7 @@ module LeapSalesforce
|
|
10
10
|
# @return [Array] List of test users
|
11
11
|
attr_accessor :list
|
12
12
|
|
13
|
-
# @param [LeapSalesforce::User] user Test user to add to leap salesforce
|
13
|
+
# @param [LeapSalesforce::User, Array] user Test user to add to leap salesforce
|
14
14
|
def add(user)
|
15
15
|
return @list << user if user.is_a? LeapSalesforce::User
|
16
16
|
|
data/lib/leap_salesforce.rb
CHANGED
@@ -3,13 +3,13 @@
|
|
3
3
|
require 'leap_salesforce/version'
|
4
4
|
|
5
5
|
require 'soaspec'
|
6
|
-
Soaspec::OAuth2.refresh_token = :once
|
7
|
-
Soaspec.log_warnings = false
|
8
|
-
Soaspec::SpecLogger.progname = 'Leaps'
|
9
|
-
Soaspec::OAuth2.request_message = false
|
6
|
+
Soaspec::OAuth2.refresh_token = :once # Save access token and reuse it
|
7
|
+
Soaspec.log_warnings = false # Log any API warnings
|
8
|
+
Soaspec::SpecLogger.progname = 'Leaps' # Program name shown in logs
|
9
|
+
Soaspec::OAuth2.request_message = false # Don't display message explaining OAuth request
|
10
10
|
Soaspec::OAuth2.retry_limit = 1 # Retrying for OAuth token too many times results in user locked out
|
11
11
|
require 'active_support/core_ext/integer/time' # Creating time objects
|
12
|
-
require 'leap_salesforce/parameters'
|
12
|
+
require 'leap_salesforce/parameters' # Important to load this first
|
13
13
|
require 'leap_salesforce/ext/string'
|
14
14
|
require 'leap_salesforce/ext/time'
|
15
15
|
require 'require_all'
|
@@ -21,7 +21,7 @@ require 'leap_salesforce/error'
|
|
21
21
|
LEAP_CONFIG_FILE = '.leap_salesforce.yml'
|
22
22
|
CREDENTIAL_FILE = File.join('config', 'credentials', 'salesforce_oauth2.yml')
|
23
23
|
|
24
|
-
leap_logger =
|
24
|
+
leap_logger = LeapSalesforce.logger
|
25
25
|
leap_logger.level = Logger::DEBUG
|
26
26
|
leap_logger.datetime_format = '%Y-%m-%d %H:%M:%S'
|
27
27
|
|
@@ -41,7 +41,15 @@ end
|
|
41
41
|
|
42
42
|
raise LeapSalesforce::SetupError, 'LeapSalesforce.environment not set' if LeapSalesforce.environment.nil?
|
43
43
|
|
44
|
-
if
|
44
|
+
if LeapSalesforce.sfdx
|
45
|
+
# Assume authentication already made through 'sfdx force:auth:jwt:grant'
|
46
|
+
unless ENV['SF_USERNAME'] && ENV['SF_CONSUMER_KEY']
|
47
|
+
raise LeapSalesforce::SetupError,
|
48
|
+
'Please set SF_USERNAME and SF_CONSUMER_KEY environment variables'
|
49
|
+
end
|
50
|
+
`sfdx force:user:display -u #{ENV['SF_USERNAME']}`
|
51
|
+
elsif File.exist? CREDENTIAL_FILE
|
52
|
+
# Set credentials from credentials file for ConnectedApp
|
45
53
|
YAML.load_file(CREDENTIAL_FILE).each do |key, value|
|
46
54
|
LeapSalesforce.send("#{key}=", value)
|
47
55
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: leap_salesforce
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- IQA
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-08-
|
12
|
+
date: 2019-08-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|