opensrs 0.3.4 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/rubocop-analysis.yml +43 -0
- data/.gitignore +17 -0
- data/.rspec +3 -0
- data/.rubocop.yml +131 -0
- data/Gemfile +2 -11
- data/Gemfile.lock +89 -43
- data/{LICENSE → LICENSE.txt} +4 -2
- data/README.md +126 -0
- data/Rakefile +1 -40
- data/SECURITY.md +12 -0
- data/bin/console +9 -0
- data/bin/setup +7 -0
- data/lib/opensrs.rb +7 -6
- data/lib/opensrs/response.rb +18 -12
- data/lib/opensrs/sanitizable_string.rb +21 -0
- data/lib/opensrs/server.rb +55 -27
- data/lib/opensrs/version.rb +1 -3
- data/lib/opensrs/xml_processor.rb +36 -37
- data/lib/opensrs/xml_processor/libxml.rb +66 -45
- data/lib/opensrs/xml_processor/nokogiri.rb +57 -38
- data/opensrs.gemspec +28 -72
- metadata +111 -54
- data/README.rdoc +0 -105
- data/spec/opensrs/server_spec.rb +0 -109
- data/spec/opensrs/version_spec.rb +0 -9
- data/spec/opensrs/xml_processor/libxml_spec.rb +0 -254
- data/spec/opensrs/xml_processor/nokogiri_spec.rb +0 -228
- data/spec/spec_helper.rb +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 71d1e83d17bb3fbcf14fe9da34120322c4411bfeb37b9f6023806467025e5d5f
|
4
|
+
data.tar.gz: 941f1cc4275cf0f64635d6ed5e326a7ebdb9bc6ee98230c495de7e809637d661
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df149b8fcd50164c419c51aa789d4dab1e8409952ec0b4b1f2fcd202948111512931d82a5169635b8690feec9f01d82fba0548b5952691dcf2d3323081b25210
|
7
|
+
data.tar.gz: 54e8f4bcbb4538d6215d94dd3bcd797f59dffa7e120a181b2af62d4f38c1cf8fb737d8298e516feda9f7bfc7b100b894714ea33cab4f8fc00458ab95b4b5c330
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# pulled from repo
|
2
|
+
name: "Rubocop"
|
3
|
+
|
4
|
+
on:
|
5
|
+
push:
|
6
|
+
branches: [ master, rubocop ]
|
7
|
+
pull_request:
|
8
|
+
# The branches below must be a subset of the branches above
|
9
|
+
branches: [ master, rubocop ]
|
10
|
+
schedule:
|
11
|
+
- cron: '37 10 * * 2'
|
12
|
+
|
13
|
+
jobs:
|
14
|
+
rubocop:
|
15
|
+
runs-on: ubuntu-latest
|
16
|
+
strategy:
|
17
|
+
fail-fast: false
|
18
|
+
|
19
|
+
steps:
|
20
|
+
- name: Checkout repository
|
21
|
+
uses: actions/checkout@v2
|
22
|
+
|
23
|
+
# If running on a self-hosted runner, check it meets the requirements
|
24
|
+
# listed at https://github.com/ruby/setup-ruby#using-self-hosted-runners
|
25
|
+
- name: Set up Ruby
|
26
|
+
uses: ruby/setup-ruby@v1
|
27
|
+
with:
|
28
|
+
ruby-version: 2.6
|
29
|
+
|
30
|
+
- name: Install dependencies
|
31
|
+
run: bundle install
|
32
|
+
|
33
|
+
- name: Rubocop run
|
34
|
+
run: |
|
35
|
+
bash -c "
|
36
|
+
bundle exec rubocop --require code_scanning --format CodeScanning::SarifFormatter -o rubocop.sarif
|
37
|
+
[[ $? -ne 2 ]]
|
38
|
+
"
|
39
|
+
|
40
|
+
- name: Upload Sarif output
|
41
|
+
uses: github/codeql-action/upload-sarif@v1
|
42
|
+
with:
|
43
|
+
sarif_file: rubocop.sarif
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
require: rubocop-rspec
|
2
|
+
|
3
|
+
AllCops:
|
4
|
+
TargetRubyVersion: 2.5
|
5
|
+
SuggestExtensions: false
|
6
|
+
|
7
|
+
Style/FrozenStringLiteralComment:
|
8
|
+
Enabled: false
|
9
|
+
|
10
|
+
RSpec/InstanceVariable:
|
11
|
+
Enabled: false
|
12
|
+
|
13
|
+
Metrics/BlockLength:
|
14
|
+
Enabled: false
|
15
|
+
|
16
|
+
RSpec/FilePath:
|
17
|
+
Enabled: false
|
18
|
+
|
19
|
+
Layout/LineLength:
|
20
|
+
Enabled: false
|
21
|
+
|
22
|
+
RSpec/MultipleExpectations:
|
23
|
+
Enabled: false
|
24
|
+
|
25
|
+
RSpec/ExampleLength:
|
26
|
+
Enabled: false
|
27
|
+
|
28
|
+
RSpec/NestedGroups:
|
29
|
+
Enabled: false
|
30
|
+
|
31
|
+
RSpec/MultipleMemoizedHelpers:
|
32
|
+
Enabled: false
|
33
|
+
|
34
|
+
RSpec/MessageSpies:
|
35
|
+
Enabled: false
|
36
|
+
|
37
|
+
RSpec/StubbedMock:
|
38
|
+
Enabled: false
|
39
|
+
|
40
|
+
RSpec/VerifiedDoubles:
|
41
|
+
Enabled: false
|
42
|
+
|
43
|
+
Metrics/MethodLength:
|
44
|
+
Enabled: false
|
45
|
+
|
46
|
+
Metrics/AbcSize:
|
47
|
+
Enabled: false
|
48
|
+
|
49
|
+
Style/ClassVars:
|
50
|
+
Enabled: false
|
51
|
+
|
52
|
+
Gemspec/DateAssignment: # (new in 1.10)
|
53
|
+
Enabled: true
|
54
|
+
Layout/LineEndStringConcatenationIndentation: # (new in 1.18)
|
55
|
+
Enabled: true
|
56
|
+
Layout/SpaceBeforeBrackets: # (new in 1.7)
|
57
|
+
Enabled: true
|
58
|
+
Lint/AmbiguousAssignment: # (new in 1.7)
|
59
|
+
Enabled: true
|
60
|
+
Lint/AmbiguousRange: # (new in 1.19)
|
61
|
+
Enabled: true
|
62
|
+
Lint/DeprecatedConstants: # (new in 1.8)
|
63
|
+
Enabled: true
|
64
|
+
Lint/DuplicateBranch: # (new in 1.3)
|
65
|
+
Enabled: true
|
66
|
+
Lint/DuplicateRegexpCharacterClassElement: # (new in 1.1)
|
67
|
+
Enabled: true
|
68
|
+
Lint/EmptyBlock: # (new in 1.1)
|
69
|
+
Enabled: true
|
70
|
+
Lint/EmptyClass: # (new in 1.3)
|
71
|
+
Enabled: true
|
72
|
+
Lint/EmptyInPattern: # (new in 1.16)
|
73
|
+
Enabled: true
|
74
|
+
Lint/LambdaWithoutLiteralBlock: # (new in 1.8)
|
75
|
+
Enabled: true
|
76
|
+
Lint/NoReturnInBeginEndBlocks: # (new in 1.2)
|
77
|
+
Enabled: true
|
78
|
+
Lint/NumberedParameterAssignment: # (new in 1.9)
|
79
|
+
Enabled: true
|
80
|
+
Lint/OrAssignmentToConstant: # (new in 1.9)
|
81
|
+
Enabled: true
|
82
|
+
Lint/RedundantDirGlobSort: # (new in 1.8)
|
83
|
+
Enabled: true
|
84
|
+
Lint/SymbolConversion: # (new in 1.9)
|
85
|
+
Enabled: true
|
86
|
+
Lint/ToEnumArguments: # (new in 1.1)
|
87
|
+
Enabled: true
|
88
|
+
Lint/TripleQuotes: # (new in 1.9)
|
89
|
+
Enabled: true
|
90
|
+
Lint/UnexpectedBlockArity: # (new in 1.5)
|
91
|
+
Enabled: true
|
92
|
+
Lint/UnmodifiedReduceAccumulator: # (new in 1.1)
|
93
|
+
Enabled: true
|
94
|
+
Naming/InclusiveLanguage: # (new in 1.18)
|
95
|
+
Enabled: true
|
96
|
+
Style/ArgumentsForwarding: # (new in 1.1)
|
97
|
+
Enabled: true
|
98
|
+
Style/CollectionCompact: # (new in 1.2)
|
99
|
+
Enabled: true
|
100
|
+
Style/DocumentDynamicEvalDefinition: # (new in 1.1)
|
101
|
+
Enabled: true
|
102
|
+
Style/EndlessMethod: # (new in 1.8)
|
103
|
+
Enabled: true
|
104
|
+
Style/HashConversion: # (new in 1.10)
|
105
|
+
Enabled: true
|
106
|
+
Style/HashExcept: # (new in 1.7)
|
107
|
+
Enabled: true
|
108
|
+
Style/IfWithBooleanLiteralBranches: # (new in 1.9)
|
109
|
+
Enabled: true
|
110
|
+
Style/InPatternThen: # (new in 1.16)
|
111
|
+
Enabled: true
|
112
|
+
Style/MultilineInPatternThen: # (new in 1.16)
|
113
|
+
Enabled: true
|
114
|
+
Style/NegatedIfElseCondition: # (new in 1.2)
|
115
|
+
Enabled: true
|
116
|
+
Style/NilLambda: # (new in 1.3)
|
117
|
+
Enabled: true
|
118
|
+
Style/QuotedSymbols: # (new in 1.16)
|
119
|
+
Enabled: true
|
120
|
+
Style/RedundantArgument: # (new in 1.4)
|
121
|
+
Enabled: true
|
122
|
+
Style/RedundantSelfAssignmentBranch: # (new in 1.19)
|
123
|
+
Enabled: true
|
124
|
+
Style/StringChars: # (new in 1.12)
|
125
|
+
Enabled: true
|
126
|
+
Style/SwapValues: # (new in 1.1)
|
127
|
+
Enabled: true
|
128
|
+
RSpec/IdenticalEqualityAssertion: # (new in 2.4)
|
129
|
+
Enabled: true
|
130
|
+
RSpec/Rails/AvoidSetupHook: # (new in 2.4)
|
131
|
+
Enabled: true
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,53 +1,99 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
opensrs (0.3.8)
|
5
|
+
|
1
6
|
GEM
|
2
|
-
remote:
|
7
|
+
remote: https://rubygems.org/
|
3
8
|
specs:
|
4
|
-
activesupport (
|
5
|
-
i18n (
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
9
|
+
activesupport (4.2.10)
|
10
|
+
i18n (~> 0.7)
|
11
|
+
minitest (~> 5.1)
|
12
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
13
|
+
tzinfo (~> 1.1)
|
14
|
+
ast (2.4.2)
|
15
|
+
code-scanning-rubocop (0.5.0)
|
16
|
+
rubocop (~> 1.0)
|
17
|
+
coderay (1.1.0)
|
18
|
+
concurrent-ruby (1.0.5)
|
19
|
+
diff-lcs (1.2.5)
|
20
|
+
i18n (0.9.3)
|
21
|
+
concurrent-ruby (~> 1.0)
|
22
|
+
libxml-ruby (3.2.1)
|
23
|
+
method_source (0.8.2)
|
24
|
+
mini_portile2 (2.5.1)
|
25
|
+
minitest (5.11.3)
|
26
|
+
nokogiri (1.11.4)
|
27
|
+
mini_portile2 (~> 2.5.0)
|
28
|
+
racc (~> 1.4)
|
29
|
+
parallel (1.20.1)
|
30
|
+
parser (3.0.2.0)
|
31
|
+
ast (~> 2.4.1)
|
32
|
+
pry (0.10.1)
|
33
|
+
coderay (~> 1.1.0)
|
34
|
+
method_source (~> 0.8.1)
|
35
|
+
slop (~> 3.4)
|
36
|
+
racc (1.5.2)
|
37
|
+
rainbow (3.0.0)
|
38
|
+
rake (13.0.6)
|
39
|
+
regexp_parser (2.1.1)
|
40
|
+
rexml (3.2.5)
|
41
|
+
rspec (3.2.0)
|
42
|
+
rspec-core (~> 3.2.0)
|
43
|
+
rspec-expectations (~> 3.2.0)
|
44
|
+
rspec-mocks (~> 3.2.0)
|
45
|
+
rspec-core (3.2.3)
|
46
|
+
rspec-support (~> 3.2.0)
|
47
|
+
rspec-expectations (3.2.1)
|
48
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
49
|
+
rspec-support (~> 3.2.0)
|
50
|
+
rspec-mocks (3.2.1)
|
51
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
52
|
+
rspec-support (~> 3.2.0)
|
53
|
+
rspec-support (3.2.2)
|
54
|
+
rubocop (1.19.0)
|
55
|
+
parallel (~> 1.10)
|
56
|
+
parser (>= 3.0.0.0)
|
57
|
+
rainbow (>= 2.2.2, < 4.0)
|
58
|
+
regexp_parser (>= 1.8, < 3.0)
|
59
|
+
rexml
|
60
|
+
rubocop-ast (>= 1.9.1, < 2.0)
|
61
|
+
ruby-progressbar (~> 1.7)
|
62
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
63
|
+
rubocop-ast (1.10.0)
|
64
|
+
parser (>= 3.0.1.1)
|
65
|
+
rubocop-rspec (2.4.0)
|
66
|
+
rubocop (~> 1.0)
|
67
|
+
rubocop-ast (>= 1.1.0)
|
68
|
+
ruby-progressbar (1.11.0)
|
69
|
+
shoulda (3.5.0)
|
70
|
+
shoulda-context (~> 1.0, >= 1.0.1)
|
71
|
+
shoulda-matchers (>= 1.4.1, < 3.0)
|
72
|
+
shoulda-context (1.2.1)
|
73
|
+
shoulda-matchers (2.8.0)
|
40
74
|
activesupport (>= 3.0.0)
|
41
|
-
|
75
|
+
slop (3.6.0)
|
76
|
+
thread_safe (0.3.6)
|
77
|
+
tzinfo (1.2.4)
|
78
|
+
thread_safe (~> 0.1)
|
79
|
+
unicode-display_width (2.0.0)
|
42
80
|
|
43
81
|
PLATFORMS
|
44
82
|
ruby
|
45
83
|
|
46
84
|
DEPENDENCIES
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
85
|
+
activesupport (~> 4.2.2)
|
86
|
+
bundler
|
87
|
+
code-scanning-rubocop (~> 0.5)
|
88
|
+
libxml-ruby (~> 3)
|
89
|
+
nokogiri (~> 1.11.4)
|
90
|
+
opensrs!
|
91
|
+
pry
|
51
92
|
rake
|
52
|
-
rspec
|
93
|
+
rspec
|
94
|
+
rubocop (~> 1)
|
95
|
+
rubocop-rspec
|
53
96
|
shoulda
|
97
|
+
|
98
|
+
BUNDLED WITH
|
99
|
+
1.17.2
|
data/{LICENSE → LICENSE.txt}
RENAMED
@@ -1,4 +1,6 @@
|
|
1
|
-
Copyright (c)
|
1
|
+
Copyright (c) 2014 Joshua Delsman
|
2
|
+
|
3
|
+
MIT License
|
2
4
|
|
3
5
|
Permission is hereby granted, free of charge, to any person obtaining
|
4
6
|
a copy of this software and associated documentation files (the
|
@@ -17,4 +19,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
19
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
20
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
21
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
# OpenSRS
|
2
|
+
|
3
|
+
[![Coverage Status](https://img.shields.io/coveralls/voxxit/opensrs.svg)](https://coveralls.io/r/voxxit/opensrs)
|
4
|
+
|
5
|
+
This unofficial OpenSRS gem provides basic support to connect to and utilize the [OpenSRS API.](http://www.opensrs.com/site/resources/documentation/api) This library has been well-tested in high-performance production
|
6
|
+
environments.
|
7
|
+
|
8
|
+
### Requirements
|
9
|
+
|
10
|
+
* Ruby **>= 2.5**
|
11
|
+
|
12
|
+
### Installation
|
13
|
+
|
14
|
+
You can install this gem by doing the following:
|
15
|
+
|
16
|
+
$ gem install opensrs
|
17
|
+
|
18
|
+
You can then include it in a Ruby project, like so:
|
19
|
+
|
20
|
+
require 'opensrs'
|
21
|
+
|
22
|
+
For Rails 3.x and above, add it to the `Gemfile`:
|
23
|
+
|
24
|
+
gem 'opensrs'
|
25
|
+
gem 'nokogiri' # if you want to use nokogiri as the XML parser
|
26
|
+
gem 'libxml-ruby' # if you want to use libxml as the XML parser
|
27
|
+
|
28
|
+
### Usage
|
29
|
+
|
30
|
+
This library provides basic functionality for interacting with the OpenSRS XML API.
|
31
|
+
|
32
|
+
- Connection handling
|
33
|
+
- Error reporting
|
34
|
+
- XML encoding
|
35
|
+
- XML decoding
|
36
|
+
|
37
|
+
Currently, the library supports LibXML and Nokogiri as XML parsers. By default, it uses LibXML to parse and generate XML. If you'd like to use Nokogiri (1.4.7 and below) for parsing XML, then in one of your app initializers add the following line:
|
38
|
+
|
39
|
+
OpenSRS::Server.xml_processor = :nokogiri
|
40
|
+
|
41
|
+
or
|
42
|
+
|
43
|
+
OpenSRS::Server.xml_processor = :libxml
|
44
|
+
|
45
|
+
To connect, instantiate a new <tt>OpenSRS::Server</tt> object:
|
46
|
+
|
47
|
+
server = OpenSRS::Server.new(
|
48
|
+
server: "https://rr-n1-tor.opensrs.net:55443/",
|
49
|
+
username: "testing",
|
50
|
+
password: "53cr3t",
|
51
|
+
key: "c633be3170c7fb3fb29e2f99b84be2410..."
|
52
|
+
)
|
53
|
+
|
54
|
+
**NOTE:** Connecting to OpenSRS requires that you add the IP(s) you're connecting from to their whitelist. Log in to the testing or production servers, and add your IP(s) under Profile Management > Add IPs for Script/API Access. IP changes take about one hour to take effect.
|
55
|
+
|
56
|
+
If you would like, you can provide OpenSRS::Server with a logger to write the contents of the requests and responses
|
57
|
+
with OpenSRS. The assumption is you are using a Rails-like logger, but as long as your logger has an info method you
|
58
|
+
are fine. You can simply assign the logger or pass it in as an initialization option:
|
59
|
+
|
60
|
+
server = OpenSRS::Server.new(
|
61
|
+
server: "https://rr-n1-tor.opensrs.net:55443/",
|
62
|
+
username: "testing",
|
63
|
+
password: "53cr3t",
|
64
|
+
key: "c633be3170c7fb3fb29e2f99b84be2410...",
|
65
|
+
logger: Rails.logger
|
66
|
+
)
|
67
|
+
|
68
|
+
or, if you can change it later:
|
69
|
+
|
70
|
+
server.logger = Rails.logger
|
71
|
+
|
72
|
+
Once you have a server connection class, you can build from this to create the methods that you need. For instance, let's say we want to grab our account balance. The OpenSRS XML API takes a couple of attributes for all commands. You can include those here:
|
73
|
+
|
74
|
+
def get_balance
|
75
|
+
server.call(
|
76
|
+
action: "GET_BALANCE",
|
77
|
+
object: "BALANCE"
|
78
|
+
)
|
79
|
+
end
|
80
|
+
|
81
|
+
Sometimes you might need to include attributes for the command, such as a cookie, or the data attributes themselves. You can do this, too:
|
82
|
+
|
83
|
+
def create_nameserver(nameserver)
|
84
|
+
server.call(
|
85
|
+
action: "CREATE",
|
86
|
+
object: "NAMESERVER",
|
87
|
+
cookie: "366828736:3210384",
|
88
|
+
attributes: {
|
89
|
+
name: nameserver.hostname,
|
90
|
+
ipaddress: "212.112.123.11"
|
91
|
+
}
|
92
|
+
)
|
93
|
+
end
|
94
|
+
|
95
|
+
Responses from OpenSRS are returned in an OpenSRS::Response object, which gives you access to a multitude of things.
|
96
|
+
|
97
|
+
Method | Description
|
98
|
+
---|---
|
99
|
+
`response.response` | This gives you the response in a Hash form, which is highly accessible to most other actions in your application.
|
100
|
+
`response.errors` | If there are errors which come back from OpenSRS, they are returned here. If not, it returns nil.
|
101
|
+
`response.success?` | Returns true if the response was labeled as successful. If not, it returns false.
|
102
|
+
`response.request_xml` | Returns raw request XML.
|
103
|
+
`response.response_xml` | Returns raw response XML.
|
104
|
+
|
105
|
+
### Bugs/Feature Requests
|
106
|
+
|
107
|
+
If you have any bugs or feature requests for this gem, feel free to [open an issue.](http://github.com/voxxit/opensrs/issues/new)
|
108
|
+
|
109
|
+
### How To Contribute
|
110
|
+
|
111
|
+
* Fork the project.
|
112
|
+
* Make your feature addition or bug fix.
|
113
|
+
* Add specs for it.
|
114
|
+
* Commit, but **do not mess with Rakefile or version.**
|
115
|
+
* Send me a pull request. Bonus points for topic branches!
|
116
|
+
|
117
|
+
### Contributors (in order of appearance)
|
118
|
+
|
119
|
+
* [Joshua Delsman](http://github.com/voxxit)
|
120
|
+
* Glenn Roberts
|
121
|
+
|
122
|
+
### Copyright
|
123
|
+
|
124
|
+
Copyright (c) 2010-2021 Joshua Delsman.
|
125
|
+
|
126
|
+
Distributed under the MIT license. See `LICENSE` for details.
|