net-imap 0.3.7 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/pages.yml +46 -0
  3. data/.github/workflows/test.yml +5 -12
  4. data/Gemfile +1 -0
  5. data/README.md +15 -4
  6. data/Rakefile +0 -7
  7. data/benchmarks/generate_parser_benchmarks +52 -0
  8. data/benchmarks/parser.yml +578 -0
  9. data/benchmarks/stringprep.yml +1 -1
  10. data/lib/net/imap/authenticators.rb +26 -57
  11. data/lib/net/imap/command_data.rb +13 -6
  12. data/lib/net/imap/deprecated_client_options.rb +139 -0
  13. data/lib/net/imap/response_data.rb +46 -41
  14. data/lib/net/imap/response_parser/parser_utils.rb +230 -0
  15. data/lib/net/imap/response_parser.rb +665 -627
  16. data/lib/net/imap/sasl/anonymous_authenticator.rb +68 -0
  17. data/lib/net/imap/sasl/authentication_exchange.rb +107 -0
  18. data/lib/net/imap/sasl/authenticators.rb +118 -0
  19. data/lib/net/imap/sasl/client_adapter.rb +72 -0
  20. data/lib/net/imap/{authenticators/cram_md5.rb → sasl/cram_md5_authenticator.rb} +15 -9
  21. data/lib/net/imap/{authenticators/digest_md5.rb → sasl/digest_md5_authenticator.rb} +74 -21
  22. data/lib/net/imap/sasl/external_authenticator.rb +62 -0
  23. data/lib/net/imap/sasl/gs2_header.rb +80 -0
  24. data/lib/net/imap/{authenticators/login.rb → sasl/login_authenticator.rb} +19 -14
  25. data/lib/net/imap/sasl/oauthbearer_authenticator.rb +164 -0
  26. data/lib/net/imap/sasl/plain_authenticator.rb +93 -0
  27. data/lib/net/imap/sasl/protocol_adapters.rb +45 -0
  28. data/lib/net/imap/sasl/scram_algorithm.rb +58 -0
  29. data/lib/net/imap/sasl/scram_authenticator.rb +278 -0
  30. data/lib/net/imap/sasl/stringprep.rb +6 -66
  31. data/lib/net/imap/sasl/xoauth2_authenticator.rb +88 -0
  32. data/lib/net/imap/sasl.rb +144 -43
  33. data/lib/net/imap/sasl_adapter.rb +21 -0
  34. data/lib/net/imap/stringprep/nameprep.rb +70 -0
  35. data/lib/net/imap/stringprep/saslprep.rb +69 -0
  36. data/lib/net/imap/stringprep/saslprep_tables.rb +96 -0
  37. data/lib/net/imap/stringprep/tables.rb +146 -0
  38. data/lib/net/imap/stringprep/trace.rb +85 -0
  39. data/lib/net/imap/stringprep.rb +159 -0
  40. data/lib/net/imap.rb +976 -590
  41. data/net-imap.gemspec +1 -1
  42. data/rakelib/saslprep.rake +4 -4
  43. data/rakelib/string_prep_tables_generator.rb +82 -60
  44. metadata +30 -11
  45. data/lib/net/imap/authenticators/plain.rb +0 -41
  46. data/lib/net/imap/authenticators/xoauth2.rb +0 -20
  47. data/lib/net/imap/sasl/saslprep.rb +0 -55
  48. data/lib/net/imap/sasl/saslprep_tables.rb +0 -98
  49. data/lib/net/imap/sasl/stringprep_tables.rb +0 -153
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 30f6313663bc3f6e896e6166ad97a16296b52e59f9f2ef93f5b6ceb8a3031caa
4
- data.tar.gz: e916c89df8b3d7bbf7c310c0299a6b7134caf71a0514091f4f87a171247750a2
3
+ metadata.gz: 2bba73e8db611b37b7c5b9be540d99c2288e9188e7f12620259862b30db47815
4
+ data.tar.gz: fde1bcda99236beafea397d36768fb9fe185ec20ca2cd5d9c991b48cfdf51bd3
5
5
  SHA512:
6
- metadata.gz: f19ca9b2808b3d293b1a6ffef2c8b3287f1f69471c914bf775d51b3259d3dc837cee635d647c575dab70795b06b54c37214d2c51e9138a2093df5d3e20d5b478
7
- data.tar.gz: d6c5b5c78de3f328486d4e107f1d6c336bb13be4738ad0d1b4e3b7b9b6af89f1a7bc77d09a7a27bd9f61160f38f4a5dc6c3a1ec5ae3f9f33705d6c52188e41f5
6
+ metadata.gz: 6ee43fab9eaea8c870940e0cc625e3223722e4b722e1055da6f3629707aaf12e580143139abb97ae1294757a99db977428c8aa23bc57d8e9a23ff9ab5eb695cf
7
+ data.tar.gz: 67a965fdd6b4af0480917241a8efad57c3356c82ec975bcc10373242e477718a1751e78cc9f0e51286b553e6222c26cddca119dbaa9dfef855c9611de6a55a64
@@ -0,0 +1,46 @@
1
+ name: Deploy RDoc site to Pages
2
+
3
+ on:
4
+ push:
5
+ branches: [ 'master' ]
6
+ workflow_dispatch:
7
+
8
+ permissions:
9
+ contents: read
10
+ pages: write
11
+ id-token: write
12
+
13
+ concurrency:
14
+ group: "pages"
15
+ cancel-in-progress: true
16
+
17
+ jobs:
18
+ build:
19
+ runs-on: ubuntu-latest
20
+ steps:
21
+ - name: Checkout
22
+ uses: actions/checkout@v4
23
+ - name: Setup Ruby
24
+ uses: ruby/setup-ruby@250fcd6a742febb1123a77a841497ccaa8b9e939 # v1.152.0
25
+ with:
26
+ ruby-version: '3.2'
27
+ bundler-cache: true
28
+ - name: Setup Pages
29
+ id: pages
30
+ uses: actions/configure-pages@v3
31
+ - name: Build with RDoc
32
+ run: bundle exec rake rdoc
33
+ - name: Upload artifact
34
+ uses: actions/upload-pages-artifact@v2
35
+ with: { path: 'doc' }
36
+
37
+ deploy:
38
+ environment:
39
+ name: github-pages
40
+ url: ${{ steps.deployment.outputs.page_url }}
41
+ runs-on: ubuntu-latest
42
+ needs: build
43
+ steps:
44
+ - name: Deploy to GitHub Pages
45
+ id: deployment
46
+ uses: actions/deploy-pages@v2
@@ -7,7 +7,7 @@ jobs:
7
7
  uses: ruby/actions/.github/workflows/ruby_versions.yml@master
8
8
  with:
9
9
  engine: cruby
10
- min_version: 2.6
10
+ min_version: 2.7
11
11
 
12
12
  build:
13
13
  needs: ruby-versions
@@ -17,22 +17,15 @@ jobs:
17
17
  ruby: ${{ fromJson(needs.ruby-versions.outputs.versions) }}
18
18
  os: [ ubuntu-latest, macos-latest ]
19
19
  experimental: [false]
20
- include:
21
- # - ruby: 2.6
22
- # os: ubuntu-latest
23
- # experimental: true
24
- - ruby: 2.6
25
- os: macos-latest
26
- experimental: false
27
20
  runs-on: ${{ matrix.os }}
28
21
  continue-on-error: ${{ matrix.experimental }}
29
22
  steps:
30
- - uses: actions/checkout@v3
23
+ - uses: actions/checkout@v4
31
24
  - name: Set up Ruby
32
25
  uses: ruby/setup-ruby@v1
33
26
  with:
34
27
  ruby-version: ${{ matrix.ruby }}
35
- - name: Install dependencies
36
- run: bundle install
28
+ bundler-cache: true
29
+ rubygems: latest
37
30
  - name: Run test
38
- run: rake test
31
+ run: bundle exec rake test
data/Gemfile CHANGED
@@ -7,3 +7,4 @@ gemspec
7
7
  gem "rake"
8
8
  gem "rdoc"
9
9
  gem "test-unit"
10
+ gem "test-unit-ruby-core", git: "https://github.com/ruby/test-unit-ruby-core"
data/README.md CHANGED
@@ -21,11 +21,24 @@ Or install it yourself as:
21
21
 
22
22
  ## Usage
23
23
 
24
+ ### Connect with TLS to port 993
25
+
26
+ ```ruby
27
+ imap = Net::IMAP.new('mail.example.com', ssl: true)
28
+ imap.port => 993
29
+ imap.tls_verified? => true
30
+ case imap.greeting.name
31
+ in /OK/i
32
+ # The client is connected in the "Not Authenticated" state.
33
+ imap.authenticate("PLAIN", "joe_user", "joes_password")
34
+ in /PREAUTH/i
35
+ # The client is connected in the "Authenticated" state.
36
+ end
37
+ ```
38
+
24
39
  ### List sender and subject of all recent messages in the default mailbox
25
40
 
26
41
  ```ruby
27
- imap = Net::IMAP.new('mail.example.com')
28
- imap.authenticate('LOGIN', 'joe_user', 'joes_password')
29
42
  imap.examine('INBOX')
30
43
  imap.search(["RECENT"]).each do |message_id|
31
44
  envelope = imap.fetch(message_id, "ENVELOPE")[0].attr["ENVELOPE"]
@@ -36,8 +49,6 @@ end
36
49
  ### Move all messages from April 2003 from "Mail/sent-mail" to "Mail/sent-apr03"
37
50
 
38
51
  ```ruby
39
- imap = Net::IMAP.new('mail.example.com')
40
- imap.authenticate('LOGIN', 'joe_user', 'joes_password')
41
52
  imap.select('Mail/sent-mail')
42
53
  if not imap.list('Mail/', 'sent-apr03')
43
54
  imap.create('Mail/sent-apr03')
data/Rakefile CHANGED
@@ -10,11 +10,4 @@ Rake::TestTask.new(:test) do |t|
10
10
  t.test_files = FileList["test/**/test_*.rb"]
11
11
  end
12
12
 
13
- task :sync_tool do
14
- require 'fileutils'
15
- FileUtils.cp "../ruby/tool/lib/core_assertions.rb", "./test/lib"
16
- FileUtils.cp "../ruby/tool/lib/envutil.rb", "./test/lib"
17
- FileUtils.cp "../ruby/tool/lib/find_executable.rb", "./test/lib"
18
- end
19
-
20
13
  task :default => :test
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "yaml"
4
+ require "pathname"
5
+ require "net/imap"
6
+
7
+ path = Pathname.new(__dir__) / "../test/net/imap/fixtures/response_parser"
8
+ files = path.glob("*.yml")
9
+ tests = files.flat_map {|file|
10
+ file.to_s
11
+ .then { YAML.unsafe_load_file _1 }
12
+ .fetch(:tests)
13
+ .select {|test_name, test|
14
+ :parser_assert_equal == test.fetch(:test_type) {
15
+ test.key?(:expected) ? :parser_assert_equal : :parser_pending
16
+ }
17
+ }
18
+ .map {|test_name, _|
19
+ [
20
+ file.relative_path_from(__dir__).to_s,
21
+ test_name.to_s,
22
+ ]
23
+ }
24
+ }
25
+
26
+ init = <<RUBY
27
+ require "yaml"
28
+ require "net/imap"
29
+
30
+ def load_response(file, name)
31
+ YAML.unsafe_load_file(file).dig(:tests, name, :response)
32
+ .force_encoding "ASCII-8BIT" \\
33
+ or abort "ERRORO: missing %p fixture data in %p" % [name, file]
34
+ end
35
+
36
+ parser = Net::IMAP::ResponseParser.new
37
+ RUBY
38
+
39
+ prelude = <<RUBY
40
+ response = load_response(%p,
41
+ %p)
42
+ RUBY
43
+ script = "parser.parse(response)"
44
+
45
+ benchmarks = tests.map {|file, fixture_name|
46
+ name = fixture_name.delete_prefix("test_")
47
+ {name:, prelude: prelude % [file, fixture_name], script:}
48
+ .transform_keys(&:to_s)
49
+ }
50
+ .sort_by { _1["name"] }
51
+
52
+ puts YAML.dump({"prelude" => init, "benchmark" => benchmarks})