leap_salesforce 1.1.2 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +5 -0
- data/README.md +4 -0
- data/bin/console +3 -2
- data/config/general.rb +3 -0
- data/exe/leap_salesforce +5 -0
- data/lib/leap_salesforce/parameters.rb +5 -4
- data/lib/leap_salesforce/session.rb +7 -4
- data/lib/leap_salesforce/soql_data/soql_settings.rb +0 -6
- data/lib/leap_salesforce/users/user.rb +7 -2
- data/lib/leap_salesforce/version.rb +1 -1
- data/lib/leap_salesforce.rb +2 -0
- 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: c7d7840f64baf2e945a29ab4f022f5ff2191b3443e9068f9cbd32afafb7520bb
|
4
|
+
data.tar.gz: fbe2a1d779b5605cd19c7eb79b2327fb673865170e2becc567bc587fa4d32798
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 861290a24fbb1575f0c3338690bd0aef6c65d3ee6a6d0e7a98c5b511e6bffc243891d927b08cd925fa819a09e9b9bcd523a6950729364c5597815f26b8f95bb9
|
7
|
+
data.tar.gz: c027b01dc9606cb88d388d25ba3b8895f05c9d5ae47b1377efc42022887b8fa160999c870e078f3434383a1249f24e66951c72b84dcbd5fcaf3398ca22bcd683
|
data/ChangeLog
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
Version 1.2.0
|
2
|
+
* Ability to set security token on leap_salesforce user by setting an environment variable with the format
|
3
|
+
`ENV["#{key}_token"]``
|
4
|
+
* Remove deprecated method of create_enum within soql_settings class
|
5
|
+
|
1
6
|
Version 1.1.2
|
2
7
|
* Fix user_id from session
|
3
8
|
|
data/README.md
CHANGED
@@ -104,6 +104,10 @@ Credentials are not stored in stored in source control. They can be setting thro
|
|
104
104
|
* 'client_secret'
|
105
105
|
* 'password'
|
106
106
|
|
107
|
+
> Security tokens can be set for each user (adding to password in OAuth like in [this article](https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_calls_login.htm))
|
108
|
+
> To do that set an environment variable as USER_KEY_token. E.g, so for a user with a key of :admin
|
109
|
+
> the token would be set with the `admin_token` environment variable
|
110
|
+
|
107
111
|
Tests can be run using the default `Rake` task.
|
108
112
|
|
109
113
|
E.g.,
|
data/bin/console
CHANGED
@@ -7,6 +7,7 @@ require 'leap_salesforce'
|
|
7
7
|
# You can add fixtures and/or initialization code here to make experimenting
|
8
8
|
# with your gem easier. You can also use a different console, if you like.
|
9
9
|
|
10
|
-
require '
|
10
|
+
require 'irb'
|
11
|
+
require 'irb/completion'
|
11
12
|
|
12
|
-
|
13
|
+
IRB.start(__FILE__)
|
data/config/general.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# Set environment variable to set a security token that will be sent for a user
|
4
|
+
# ENV['admin_token'] = 'test'
|
5
|
+
|
3
6
|
# Add users to LeapSalesforce context. First user is the default
|
4
7
|
module LeapSalesforce
|
5
8
|
Users.add User.new :admin, 'samuel.garratt@brave-otter-ttxype.com'
|
data/exe/leap_salesforce
CHANGED
@@ -36,6 +36,7 @@ module LeapSalesforce
|
|
36
36
|
exit if oauth_setup.downcase == 'n'
|
37
37
|
end
|
38
38
|
query_for_parameters # TODO: for sfdx
|
39
|
+
has_ignore_file = File.exist?('.gitignore')
|
39
40
|
generate_files binding, ['Gemfile', 'Rakefile', '.leap_salesforce.yml', '.rspec', '.gitignore',
|
40
41
|
{ config: ['general.rb', { credentials: 'salesforce_oauth2.yml' }] },
|
41
42
|
{ spec: %w[spec_helper.rb limit_spec.rb crud_eg_spec.rb picklists_spec.rb] }]
|
@@ -52,6 +53,10 @@ module LeapSalesforce
|
|
52
53
|
puts `rake leaps:create_soql_objects`
|
53
54
|
puts 'Creating enums'.colorize :yellow
|
54
55
|
puts `rake leaps:create_enums`
|
56
|
+
return unless has_ignore_file
|
57
|
+
|
58
|
+
puts 'Your .gitignore is already present so not updated.
|
59
|
+
Please ignore "config/credentials/" and "logs/"'.colorize :red
|
55
60
|
end
|
56
61
|
end
|
57
62
|
end
|
@@ -76,14 +76,13 @@ module LeapSalesforce
|
|
76
76
|
# using sfdx
|
77
77
|
# @return [Hash] OAuth2 parameters used in connecting to salesforce
|
78
78
|
def oauth_settings
|
79
|
-
|
80
|
-
username: '<%= LeapSalesforce.api_user %>',
|
79
|
+
{
|
80
|
+
username: '<%= LeapSalesforce.api_user %>',
|
81
|
+
password: '<%= LeapSalesforce.password + LeapSalesforce.security_token.to_s %>',
|
81
82
|
client_id: LeapSalesforce.client_id,
|
82
83
|
client_secret: LeapSalesforce.client_secret,
|
83
84
|
token_url: "#{LeapSalesforce.general_url}/services/oauth2/token"
|
84
85
|
}
|
85
|
-
settings[:security_token] = LeapSalesforce.security_token if LeapSalesforce.security_token
|
86
|
-
settings
|
87
86
|
end
|
88
87
|
|
89
88
|
# @return [String] General salesforce URL for logging in to
|
@@ -98,6 +97,8 @@ module LeapSalesforce
|
|
98
97
|
else
|
99
98
|
LeapSalesforce::Users.where(user)&.username
|
100
99
|
end
|
100
|
+
leaps_user = LeapSalesforce::Users.where username: @api_user
|
101
|
+
LeapSalesforce.security_token = leaps_user.security_token
|
101
102
|
Soaspec::SpecLogger.info "Using user '#{@api_user}' for API"
|
102
103
|
end
|
103
104
|
|
@@ -9,18 +9,21 @@ module LeapSalesforce
|
|
9
9
|
attr_accessor :session_id
|
10
10
|
# @return [String] User id returned from SOAP API
|
11
11
|
attr_accessor :user_id
|
12
|
+
# @return [Hash] Login response
|
13
|
+
attr_accessor :login_response
|
12
14
|
|
13
|
-
def initialize(username, password)
|
14
|
-
login_body = LeapSalesforce::Session.soap_login username, password
|
15
|
+
def initialize(username, password, security_token = '')
|
16
|
+
login_body = LeapSalesforce::Session.soap_login username, password, security_token
|
15
17
|
|
16
18
|
self.session_id = login_body[:login_response][:result][:session_id]
|
17
19
|
self.user_id = login_body[:login_response][:result][:user_id]
|
20
|
+
self.login_response = login_body[:login_response]
|
18
21
|
end
|
19
22
|
|
20
23
|
class << self
|
21
24
|
|
22
25
|
# Login via SOAP API
|
23
|
-
def soap_login(username, password)
|
26
|
+
def soap_login(username, password, security_token)
|
24
27
|
client = Savon.client do
|
25
28
|
endpoint "#{SoqlHandler.instance_url}/services/Soap/u/51.0"
|
26
29
|
namespace "urn:partner.soap.sforce.com"
|
@@ -29,7 +32,7 @@ module LeapSalesforce
|
|
29
32
|
response = client.call(:login, message:
|
30
33
|
{
|
31
34
|
username: username,
|
32
|
-
password: password
|
35
|
+
password: password + security_token
|
33
36
|
})
|
34
37
|
response.body
|
35
38
|
end
|
@@ -13,10 +13,4 @@ module SoqlSettings
|
|
13
13
|
def soql_object_name
|
14
14
|
@soql_object_name || to_s
|
15
15
|
end
|
16
|
-
|
17
|
-
# @deprecated Not used, setting in '.leap_salesforce.yml' controls this now
|
18
|
-
def create_enum(_set)
|
19
|
-
LeapSalesforce.logger.warn "Method 'create_enum' called when it is deprecated" \
|
20
|
-
" from #{caller_locations[0]}"
|
21
|
-
end
|
22
16
|
end
|
@@ -14,11 +14,16 @@ module LeapSalesforce
|
|
14
14
|
# readable format is required such as in a Cucumber test
|
15
15
|
attr_accessor :description
|
16
16
|
|
17
|
-
# @
|
18
|
-
|
17
|
+
# @return [String] Security token of user. Recommend this be set through ENV variable
|
18
|
+
attr_accessor :security_token
|
19
|
+
|
20
|
+
# @param [String, Symbol] user_params[0] key Key used to identify a test user
|
21
|
+
# @param [String] user_params[1] username Name used to login with user. In email address format.
|
22
|
+
# @param [String] user_params[1] security_token Security token of user
|
19
23
|
def initialize(*user_params, description: nil)
|
20
24
|
self.key = user_params[0]
|
21
25
|
self.username = user_params[1]
|
26
|
+
self.security_token = ENV["#{key}_token"] || nil
|
22
27
|
self.description = description
|
23
28
|
end
|
24
29
|
|
data/lib/leap_salesforce.rb
CHANGED
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: 1.
|
4
|
+
version: 1.2.0
|
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: 2022-02-
|
12
|
+
date: 2022-02-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|