diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml new file mode 100644 index 0000000..1131471 --- /dev/null +++ b/.github/workflows/ruby.yml @@ -0,0 +1,37 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. +# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake +# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby + +name: Ruby + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +permissions: + contents: read + +jobs: + test: + + runs-on: ubuntu-latest + strategy: + matrix: + ruby-version: ['2.7', '3.0'] + + steps: + - uses: actions/checkout@v4 + - name: Set up Ruby + # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby, + # change this to (see https://github.com/ruby/setup-ruby#versioning): + uses: ruby/setup-ruby@v1 # v1.146.0 + with: + ruby-version: ${{ matrix.ruby-version }} + bundler-cache: true # runs 'bundle install' and caches installed gems automatically + - name: Run tests + run: bundle exec rake diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index b6e28c4..0000000 --- a/.travis.yml +++ /dev/null @@ -1,12 +0,0 @@ -sudo: false -language: ruby -rvm: - - 2.6.6 - - 2.7.2 - - 3.0.0 -before_install: - - sudo apt-get update - - sudo apt-get install -y libsodium-dev - - gem update --system - - gem --version - - gem install bundler diff --git a/README.md b/README.md index a081da0..83d8c0f 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,5 @@ # threema -[![Build Status](https://travis-ci.org/thorsteneckel/threema.svg?branch=master)](https://travis-ci.org/thorsteneckel/threema) -[![codecov](https://codecov.io/gh/thorsteneckel/threema/branch/master/graph/badge.svg)](https://codecov.io/gh/thorsteneckel/threema) -[![Code Climate](https://codeclimate.com/github/thorsteneckel/threema/badges/gpa.svg)](https://codeclimate.com/github/thorsteneckel/threema) -[![Gem](https://img.shields.io/gem/v/threema.svg?maxAge=2592000)]() - - This gem provides access to the Threema Gateway API. ## Installation diff --git a/lib/threema/blob.rb b/lib/threema/blob.rb index 5d98281..b3bd3cc 100644 --- a/lib/threema/blob.rb +++ b/lib/threema/blob.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true -require 'case_transform' require 'threema/exceptions' class Threema diff --git a/lib/threema/capabilities.rb b/lib/threema/capabilities.rb index c5b1305..e12d486 100644 --- a/lib/threema/capabilities.rb +++ b/lib/threema/capabilities.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true -require 'case_transform' - class Threema class Capabilities class << self diff --git a/lib/threema/lookup.rb b/lib/threema/lookup.rb index 956a0e4..9baab6e 100644 --- a/lib/threema/lookup.rb +++ b/lib/threema/lookup.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true -require 'case_transform' - class Threema class Lookup URL_PATH = { @@ -67,7 +65,7 @@ def bulk(params) def keys_camel_lower(params) cameled = {} params.each do |key, value| - cameled[CaseTransform.camel_lower(key.to_s)] = value + cameled[key.to_s.camelize(:lower)] = value end cameled end @@ -76,7 +74,7 @@ def underscore_entry_keys(list) list.collect do |response_entry| result_entry = {} response_entry.each do |key, value| - result_entry[CaseTransform.underscore(key).to_sym] = value + result_entry[key.underscore.to_sym] = value end result_entry diff --git a/lib/threema/receive.rb b/lib/threema/receive.rb index 2d1e874..4cca456 100644 --- a/lib/threema/receive.rb +++ b/lib/threema/receive.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true -require 'case_transform' require 'threema/e2e/mac' require 'threema/typed_message' require 'threema/lookup' @@ -65,7 +64,7 @@ def classify(type) end def class_name(type) - class_name = CaseTransform.camel(type.to_s) + class_name = type.to_s.camelize "Threema::Receive::#{class_name}" end diff --git a/lib/threema/send.rb b/lib/threema/send.rb index 19f876f..954632f 100644 --- a/lib/threema/send.rb +++ b/lib/threema/send.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true -require 'case_transform' require 'threema/exceptions' require 'threema/send/simple' require 'threema/send/text' diff --git a/spec/factories/threema.rb b/spec/factories/threema.rb index 7535db8..9c9e2ce 100644 --- a/spec/factories/threema.rb +++ b/spec/factories/threema.rb @@ -4,6 +4,7 @@ factory :threema do api_identity { test_from } api_secret { test_api_secret } + private_key { test_private_key } initialize_with do new(**attributes) diff --git a/spec/factories/threema_client.rb b/spec/factories/threema_client.rb index ff24ee7..d572fc4 100644 --- a/spec/factories/threema_client.rb +++ b/spec/factories/threema_client.rb @@ -2,7 +2,7 @@ FactoryBot.define do factory :threema_client, class: Threema::Client do - threema { FactoryBot.build(:threema) } + threema initialize_with do new(**attributes) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 055d526..347d6b1 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -10,19 +10,13 @@ require 'pry' require 'simplecov' -require 'codecov' -require 'codeclimate-test-reporter' SimpleCov.start do # Don't get coverage on the test cases themselves. add_filter '/spec/' add_filter '/test/' - # Codecov doesn't automatically ignore vendored files. - add_filter '/vendor/' end -SimpleCov.formatter = SimpleCov::Formatter::Codecov - -CodeClimate::TestReporter.start +SimpleCov.formatter = SimpleCov::Formatter::HTMLFormatter require 'threema' diff --git a/spec/support/shared_values.rb b/spec/support/shared_values.rb index dc6b355..61af51b 100644 --- a/spec/support/shared_values.rb +++ b/spec/support/shared_values.rb @@ -9,11 +9,11 @@ def hello_world end def test_public_key - ENV['THREEMARB_PUBLIC'] + 'd981f35570026a9551fbb27709087fe9c268b8f1395998b4ae5019476cd58fae' end def test_private_key - ENV['THREEMARB_PRIVATE'] + '2edf856e8a0f8f8e761be57f895f8827f42c6be0c6c891b95494faa7d264f7d9' end def test_auth_params @@ -24,11 +24,11 @@ def test_auth_params end def test_from - ENV['THREEMARB_API_IDENTITY'] + '*VALID1' end def test_api_secret - ENV['THREEMARB_API_SECRET'] + 'CWWuNaFDkEZLiRSt' end def test_blob_id diff --git a/spec/threema/client_spec.rb b/spec/threema/client_spec.rb index 0a7d4d0..0e65d0c 100644 --- a/spec/threema/client_spec.rb +++ b/spec/threema/client_spec.rb @@ -11,8 +11,8 @@ expect(described_class).to respond_to(:url) end - let(:instance) { build(:threema_client, threema: threema) } - let(:threema) { build(:threema) } + let(:instance) { build(:threema_client) } + let!(:threema) { build(:threema) } context '#not_found_ok' do it 'responds to not_found_ok' do @@ -53,8 +53,8 @@ before(:each) do instance.configure do |config| - # Threema API fingerprint as of 2021-02-27 - fingerprint = '42b1038e72f00c8c4dad78a3ebdc6d7a50c5ef288da9019b9171e4d675c08a17' + # Threema API fingerprint as of 2024-04-30 + fingerprint = '317bc8626c34a2ccd9052164828f4eb71a6bc6290e2569acee5b3a2cbde13d2a' # See: http://stackoverflow.com/a/22108461 config.use_ssl = true @@ -74,8 +74,8 @@ end end - # this is needed due to internet access restrictions - # in the (travis) CI environment + # skipped in CI because this test requires actual + # private key, identity, etc set in .env variables if !ENV['CI'] context 'given Threema Message API URL with matching certificate' do let(:url) { described_class::API_URL } @@ -87,7 +87,7 @@ end context 'given another URL without matching certificate' do - let(:url) { 'https://github.com/thorsteneckel/threema' } + let(:url) { 'https://github.com/threemarb/threema' } it { should raise_error(OpenSSL::SSL::SSLError) } context 'but if static certificate pinning is disabled' do diff --git a/threema.gemspec b/threema.gemspec index 38ff347..9f38b4b 100644 --- a/threema.gemspec +++ b/threema.gemspec @@ -16,12 +16,12 @@ Gem::Specification.new do |spec| spec.homepage = 'https://github.com/thorsteneckel/threema' spec.license = 'MIT' - spec.required_ruby_version = '>= 2.6.0' + spec.required_ruby_version = '>= 2.7.0' spec.files = Dir['{lib}/**/*'] spec.require_paths = ['lib'] - spec.add_runtime_dependency 'case_transform' + spec.add_runtime_dependency 'activesupport', '~> 7.0.8' spec.add_runtime_dependency 'dotenv' spec.add_runtime_dependency 'mimemagic' spec.add_runtime_dependency 'mime-types' @@ -29,8 +29,6 @@ Gem::Specification.new do |spec| spec.add_runtime_dependency 'rbnacl' spec.add_development_dependency 'bundler' - spec.add_development_dependency 'codeclimate-test-reporter', '~> 0.6' - spec.add_development_dependency 'codecov' spec.add_development_dependency 'factory_bot' spec.add_development_dependency 'fakefs' spec.add_development_dependency 'pry'