net-imap 0.3.7 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) 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/authenticators.rb +112 -0
  18. data/lib/net/imap/{authenticators/cram_md5.rb → sasl/cram_md5_authenticator.rb} +15 -9
  19. data/lib/net/imap/{authenticators/digest_md5.rb → sasl/digest_md5_authenticator.rb} +74 -21
  20. data/lib/net/imap/sasl/external_authenticator.rb +62 -0
  21. data/lib/net/imap/sasl/gs2_header.rb +80 -0
  22. data/lib/net/imap/{authenticators/login.rb → sasl/login_authenticator.rb} +19 -14
  23. data/lib/net/imap/sasl/oauthbearer_authenticator.rb +164 -0
  24. data/lib/net/imap/sasl/plain_authenticator.rb +93 -0
  25. data/lib/net/imap/sasl/scram_algorithm.rb +58 -0
  26. data/lib/net/imap/sasl/scram_authenticator.rb +278 -0
  27. data/lib/net/imap/sasl/stringprep.rb +6 -66
  28. data/lib/net/imap/sasl/xoauth2_authenticator.rb +88 -0
  29. data/lib/net/imap/sasl.rb +139 -44
  30. data/lib/net/imap/stringprep/nameprep.rb +70 -0
  31. data/lib/net/imap/stringprep/saslprep.rb +69 -0
  32. data/lib/net/imap/stringprep/saslprep_tables.rb +96 -0
  33. data/lib/net/imap/stringprep/tables.rb +146 -0
  34. data/lib/net/imap/stringprep/trace.rb +85 -0
  35. data/lib/net/imap/stringprep.rb +159 -0
  36. data/lib/net/imap.rb +967 -588
  37. data/net-imap.gemspec +1 -1
  38. data/rakelib/saslprep.rake +4 -4
  39. data/rakelib/string_prep_tables_generator.rb +82 -60
  40. metadata +26 -11
  41. data/lib/net/imap/authenticators/plain.rb +0 -41
  42. data/lib/net/imap/authenticators/xoauth2.rb +0 -20
  43. data/lib/net/imap/sasl/saslprep.rb +0 -55
  44. data/lib/net/imap/sasl/saslprep_tables.rb +0 -98
  45. 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: 473842922edfdfd112a9cd3fa96df2831efa0d4640a38c0969725d6c04f45dbe
4
+ data.tar.gz: 7f93b8a1882f2225f404db0d175c29ead931de531f918e17cbb6f8515300b9e9
5
5
  SHA512:
6
- metadata.gz: f19ca9b2808b3d293b1a6ffef2c8b3287f1f69471c914bf775d51b3259d3dc837cee635d647c575dab70795b06b54c37214d2c51e9138a2093df5d3e20d5b478
7
- data.tar.gz: d6c5b5c78de3f328486d4e107f1d6c336bb13be4738ad0d1b4e3b7b9b6af89f1a7bc77d09a7a27bd9f61160f38f4a5dc6c3a1ec5ae3f9f33705d6c52188e41f5
6
+ metadata.gz: d9470c52ca3b689a1dd314501a91f5651d1b11fd26cc5628cb6ccf4bf59aeb93ebdcca141ab12d0ec5e69b0e5aa5e29881c85433d9c6dcdeb5902591c1c62aaa
7
+ data.tar.gz: 6caae2c7cf684d10ca54ac8b53b498acb5c8d210135d2f583d254fa3dbdc41b7e50382c43aeb05438713b723d9d5da7d48980569024e36d55683e9e5b041df8a
@@ -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})