From 45e381c2f1db864b892e0f1917c277fb5e4e54b3 Mon Sep 17 00:00:00 2001 From: Mandeep Khinda <32844597+mkhinda29@users.noreply.github.com> Date: Mon, 25 Sep 2023 10:57:40 -0400 Subject: [PATCH 01/19] update and set ruby version, add style and spec ci --- .github/workflows/style.yml | 52 +++++++++++++++ .github/workflows/tests.yml | 46 +++++++++++++ .rubocop.yml | 118 +++++++++++++++++++++++++++++++++- .ruby-version | 1 + Gemfile | 16 ++++- Gemfile.lock | 51 +++++++++------ omniauth-azure-devops.gemspec | 27 ++++---- 7 files changed, 274 insertions(+), 37 deletions(-) create mode 100644 .github/workflows/style.yml create mode 100644 .github/workflows/tests.yml create mode 100644 .ruby-version diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml new file mode 100644 index 0000000..1c4cedb --- /dev/null +++ b/.github/workflows/style.yml @@ -0,0 +1,52 @@ +name: Style Checks + +on: pull_request + +jobs: + changelog: + name: changelog + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v4 + + - name: Get version + id: get_version + run: | + version_file=$(find ./lib -name version.rb) + version=$(grep VERSION $version_file |cut -f 2 -d= |tr -d \'|tr -d [:space:]) + echo version=$version >> $GITHUB_OUTPUT + echo version_tag=v$version >> $GITHUB_OUTPUT + + - name: validate changelog exists + env: + GEM_VERSION: ${{steps.get_version.outputs.version}} + run: | + error_code=0 + grep "\[${GEM_VERSION}\]" CHANGELOG.md || error_code=$? + + if [ "${error_code}" -eq 1 ]; then + echo "No changelog entry found for version ${GEM_VERSION}" + exit 1 + fi + + rubocop: + name: runner / rubocop + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v4 + + - name: Install Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.2.2 + + - name: rubocop + uses: reviewdog/action-rubocop@a434f50eaae1589b90edcb14cabf70555571577a # v1.11.0 + with: + rubocop_version: gemfile + rubocop_extensions: rubocop-performance + github_token: ${{ secrets.github_token }} + filter_mode: file + fail_on_error: true diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..dda2c25 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,46 @@ +name: Tests + +on: pull_request + +jobs: + rspec: + name: rspec tests + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v4 + + - name: Install Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.2.2 + bundler-cache: true + + - name: Run rspec tests + run: | + bundle exec rspec + + + - name: Upload coverage results + uses: actions/upload-artifact@v3 + with: + name: coverage-results + path: coverage + retention-days: 5 + + coverage: + needs: rspec + runs-on: ubuntu-latest + steps: + - name: Download coverage results + uses: actions/download-artifact@v3 + with: + name: coverage-results + path: coverage + + - name: Simplecov Report + uses: aki77/simplecov-report-action@7fd5fa551dd583dd437a11c640b2a1cf23d6cdaa # v1.5.2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + failedThreshold: 100 + resultPath: coverage/.last_run.json diff --git a/.rubocop.yml b/.rubocop.yml index 9474c5d..17b2e91 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,2 +1,116 @@ -inherit_gem: - rewind-ruby-style: rubocop.yml +require: + - rubocop-performance + - rubocop-rspec + +AllCops: + DisplayCopNames: true + TargetRubyVersion: 3.2 + StyleGuideBaseURL: https://github.com/rewindio/ruby-style-configs/ + NewCops: enable + Exclude: + - .git/**/* + - bin/**/* + - log/**/* + - tmp/**/* + - vendor/**/* + +# Layout cop configuration + +Layout/LineLength: + Max: 160 + +# Lint cop configuration + +Lint/Debugger: + Enabled: true +Lint/SuppressedException: + AllowComments: true + +# Metrics cop configuration + +Metrics/AbcSize: + Enabled: false +Metrics/BlockLength: + Enabled: false +Metrics/ClassLength: + Enabled: false +Metrics/CyclomaticComplexity: + Enabled: false +Metrics/MethodLength: + Enabled: false +Metrics/ModuleLength: + Enabled: false +Metrics/ParameterLists: + Enabled: false +Metrics/PerceivedComplexity: + Enabled: false + +# Naming cop configuration + +Naming/MethodParameterName: + Enabled: true + Exclude: + - spec/support/helpers.rb + +Naming/BlockForwarding: + EnforcedStyle: explicit + +# Minitest cop configuration + +# Performance cop configuration + +# Rails cop configuration + +# RSpec cop configuration + +RSpec/ExampleLength: + Max: 15 + CountAsOne: ['array', 'heredoc', 'hash'] +RSpec/MultipleExpectations: + Max: 5 +# This cop does more harm than good and makes certain data-heavy classes difficult to test. +# Even Rubocop themselves disables this one. +# https://github.com/rubocop/rubocop/blob/efb1e628adfec08d2fe7875779fc16b42bde9f77/.rubocop.yml#L145 +# https://stackoverflow.com/a/67149191 +RSpec/MultipleMemoizedHelpers: + Enabled: false +RSpec/NestedGroups: + Max: 5 + +# Style cop configuration +Style/ArgumentsForwarding: + UseAnonymousForwarding: false +Style/AsciiComments: + Enabled: false +Style/ClassAndModuleChildren: + EnforcedStyle: compact + Exclude: + - config/**/*.rb + - lib/**/*.rb +Style/DateTime: + Enabled: false +Style/Documentation: + Enabled: false +Style/FrozenStringLiteralComment: + Details: >- + Add `# frozen_string_literal: true` to the top of the file. Frozen string + literals will become the default in a future Ruby version, and we want to + make sure we're ready. + EnforcedStyle: always + SupportedStyles: + - always + - never +Style/HashEachMethods: + Enabled: true +Style/HashSyntax: + EnforcedShorthandSyntax: either +Style/HashTransformKeys: + Enabled: true +Style/HashTransformValues: + Enabled: true +Style/NumericPredicate: + Enabled: false # This is an unsafe setting which has the potential to introduce bugs because nil == 0 is false, where nil.zero? throws an exception. +Style/RedundantSelf: + Enabled: true +Style/RescueStandardError: + Enabled: false diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000..be94e6f --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +3.2.2 diff --git a/Gemfile b/Gemfile index b4e2a20..7670318 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,17 @@ -source "https://rubygems.org" +# frozen_string_literal: true + +source 'https://rubygems.org' gemspec + +group :development, :test do + gem 'bundler', '~> 2.4' + gem 'pry' + gem 'rake', '~> 13.0' + gem 'rspec', '~> 3.9.0' + gem 'rubocop' + gem 'rubocop-performance' + gem 'rubocop-rspec' + gem 'simplecov', '~> 0.22' + gem 'simplecov-console', '~> 0.9' +end diff --git a/Gemfile.lock b/Gemfile.lock index 875aa49..8600136 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - omniauth-azure-devops (0.1.0) + omniauth-azure-devops (1.0.0) omniauth (>= 1, < 3) omniauth-oauth2 @@ -20,7 +20,9 @@ GEM ruby2_keywords (>= 0.0.4) faraday-net_http (3.0.2) hashie (5.0.0) + json (2.6.3) jwt (2.7.1) + language_server-protocol (3.17.0.3) method_source (1.0.0) multi_xml (0.6.0) oauth2 (2.0.9) @@ -51,8 +53,6 @@ GEM rainbow (3.1.1) rake (13.0.6) regexp_parser (2.8.1) - rewind-ruby-style (1.0.10) - rubocop (>= 0.85, < 0.89) rexml (3.2.6) rspec (3.9.0) rspec-core (~> 3.9.0) @@ -67,17 +67,31 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.9.0) rspec-support (3.9.4) - rubocop (0.87.1) + rubocop (1.56.3) + base64 (~> 0.1.1) + json (~> 2.3) + language_server-protocol (>= 3.17.0) parallel (~> 1.10) - parser (>= 2.7.1.1) + parser (>= 3.2.2.3) rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 1.7) - rexml - rubocop-ast (>= 0.1.0, < 1.0) + regexp_parser (>= 1.8, < 3.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.28.1, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 2.0) - rubocop-ast (0.8.0) - parser (>= 2.7.1.5) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.29.0) + parser (>= 3.2.1.0) + rubocop-capybara (2.19.0) + rubocop (~> 1.41) + rubocop-factory_bot (2.24.0) + rubocop (~> 1.33) + rubocop-performance (1.19.1) + rubocop (>= 1.7.0, < 2.0) + rubocop-ast (>= 0.4.0) + rubocop-rspec (2.24.1) + rubocop (~> 1.33) + rubocop-capybara (~> 2.17) + rubocop-factory_bot (~> 2.22) ruby-progressbar (1.13.0) ruby2_keywords (0.0.5) simplecov (0.22.0) @@ -95,22 +109,23 @@ GEM version_gem (~> 1.1, >= 1.1.1) terminal-table (3.0.2) unicode-display_width (>= 1.1.1, < 3) - unicode-display_width (1.8.0) + unicode-display_width (2.4.2) version_gem (1.1.3) PLATFORMS ruby DEPENDENCIES - bundler (= 2.0.1) + bundler (~> 2.4) omniauth-azure-devops! pry rake (~> 13.0) - rewind-ruby-style rspec (~> 3.9.0) - rubocop (~> 0.87.0) - simplecov (~> 0.19) - simplecov-console (~> 0.4) + rubocop + rubocop-performance + rubocop-rspec + simplecov (~> 0.22) + simplecov-console (~> 0.9) BUNDLED WITH - 2.0.1 + 2.4.19 diff --git a/omniauth-azure-devops.gemspec b/omniauth-azure-devops.gemspec index 432898e..d199def 100644 --- a/omniauth-azure-devops.gemspec +++ b/omniauth-azure-devops.gemspec @@ -1,32 +1,27 @@ -# -*- encoding: utf-8 -*- -require File.expand_path('../lib/omniauth-azure-devops/version', __FILE__) +# frozen_string_literal: true + +require File.expand_path('lib/omniauth-azure-devops/version', __dir__) Gem::Specification.new do |gem| - gem.name = "omniauth-azure-devops" + gem.name = 'omniauth-azure-devops' gem.version = Omniauth::AzureDevops::VERSION gem.authors = ['Rewind Software Inc. | Parth Chandgadhiya'] gem.email = ['team@rewind.io'] - gem.summary = %q{An Azure Devops OAuth strategy for OmniAuth 2.0} - gem.description = %q{An Azure Devops OAuth strategy for OmniAuth 2.0} - gem.homepage = "https://github.com/rewind/omniauth-azure-devops" + gem.summary = 'An Azure Devops OAuth strategy for OmniAuth 2.0' + gem.description = 'An Azure Devops OAuth strategy for OmniAuth 2.0' + gem.homepage = 'https://github.com/rewind/omniauth-azure-devops' gem.license = 'MIT' gem.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec|.github|examples)/}) } gem.bindir = 'exe' gem.executables = gem.files.grep(%r{^exe/}) { |f| File.basename(f) } - gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) - gem.require_paths = ["lib"] + gem.require_paths = ['lib'] + + gem.required_ruby_version = '>= 3.2' gem.add_runtime_dependency 'omniauth', '>= 1', '< 3' gem.add_runtime_dependency 'omniauth-oauth2' - gem.add_development_dependency 'pry' - gem.add_development_dependency 'bundler', '2.0.1' - gem.add_development_dependency 'rake', '~> 13.0' - gem.add_development_dependency 'rewind-ruby-style' - gem.add_development_dependency 'rspec', '~> 3.9.0' - gem.add_development_dependency 'rubocop', '~> 0.87.0' - gem.add_development_dependency 'simplecov', '~> 0.19' - gem.add_development_dependency 'simplecov-console', '~> 0.4' + gem.metadata['rubygems_mfa_required'] = 'true' end From b19a2df4649acb3ef292699dd83a8e52e701d476 Mon Sep 17 00:00:00 2001 From: Mandeep Khinda <32844597+mkhinda29@users.noreply.github.com> Date: Mon, 25 Sep 2023 11:01:21 -0400 Subject: [PATCH 02/19] add rspec ext --- .github/workflows/style.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml index 1c4cedb..ac5a25e 100644 --- a/.github/workflows/style.yml +++ b/.github/workflows/style.yml @@ -46,7 +46,7 @@ jobs: uses: reviewdog/action-rubocop@a434f50eaae1589b90edcb14cabf70555571577a # v1.11.0 with: rubocop_version: gemfile - rubocop_extensions: rubocop-performance + rubocop_extensions: rubocop-performance rubocop-rspec github_token: ${{ secrets.github_token }} filter_mode: file fail_on_error: true From 4992d257ee83ee59122b251a725bc001c7489d63 Mon Sep 17 00:00:00 2001 From: Mandeep Khinda <32844597+mkhinda29@users.noreply.github.com> Date: Mon, 25 Sep 2023 11:08:59 -0400 Subject: [PATCH 03/19] update reviewdog --- .github/workflows/style.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml index ac5a25e..6c0dafd 100644 --- a/.github/workflows/style.yml +++ b/.github/workflows/style.yml @@ -43,10 +43,11 @@ jobs: ruby-version: 3.2.2 - name: rubocop - uses: reviewdog/action-rubocop@a434f50eaae1589b90edcb14cabf70555571577a # v1.11.0 + uses: reviewdog/action-rubocop@e70b014b8062c447d6b515ee0209f834ea93e696 #v2.5.0 with: rubocop_version: gemfile - rubocop_extensions: rubocop-performance rubocop-rspec + rubocop_extensions: rubocop-performance:gemfile rubocop-rspec:gemfile github_token: ${{ secrets.github_token }} filter_mode: file fail_on_error: true + use_bundler: true From 6857f67f29db926e204a154a7d880bf38150a323 Mon Sep 17 00:00:00 2001 From: Mandeep Khinda <32844597+mkhinda29@users.noreply.github.com> Date: Mon, 25 Sep 2023 11:11:03 -0400 Subject: [PATCH 04/19] bundler?? --- .github/workflows/style.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml index 6c0dafd..39d1baa 100644 --- a/.github/workflows/style.yml +++ b/.github/workflows/style.yml @@ -41,6 +41,7 @@ jobs: uses: ruby/setup-ruby@v1 with: ruby-version: 3.2.2 + bundler-cache: true - name: rubocop uses: reviewdog/action-rubocop@e70b014b8062c447d6b515ee0209f834ea93e696 #v2.5.0 From b8ad38b4988282dc5c0f16bfe797a4e1a63a6521 Mon Sep 17 00:00:00 2001 From: Mandeep Khinda <32844597+mkhinda29@users.noreply.github.com> Date: Mon, 25 Sep 2023 11:14:57 -0400 Subject: [PATCH 05/19] rubocop autocorrect, changelog, version --- CHANGELOG.md | 5 + lib/omniauth-azure-devops/version.rb | 2 +- lib/omniauth/strategies/azure_devops.rb | 3 +- spec/omniauth-azure-devops/version_spec.rb | 2 +- spec/omniauth/strategies/azure_devops_spec.rb | 47 ++++---- spec/spec_helper.rb | 114 +++++++++--------- 6 files changed, 91 insertions(+), 82 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ad340a..f0ada1f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ # Changelog +## [1.1.0] + +- Update ruby version, add CI, rubocop autocorrect + ## [1.0.0] + - Initial Release ## [0.1.0] diff --git a/lib/omniauth-azure-devops/version.rb b/lib/omniauth-azure-devops/version.rb index 3f2ba76..5a9c7ac 100644 --- a/lib/omniauth-azure-devops/version.rb +++ b/lib/omniauth-azure-devops/version.rb @@ -2,6 +2,6 @@ module Omniauth module AzureDevops - VERSION = '1.0.0' + VERSION = '1.0.1' end end diff --git a/lib/omniauth/strategies/azure_devops.rb b/lib/omniauth/strategies/azure_devops.rb index 2565251..255e3b8 100644 --- a/lib/omniauth/strategies/azure_devops.rb +++ b/lib/omniauth/strategies/azure_devops.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'omniauth/strategies/oauth2' module OmniAuth @@ -37,7 +38,7 @@ def raw_info def token_params super.tap do |params| - params[:headers] = {'Content-Type': "application/x-www-form-urlencoded"} + params[:headers] = { 'Content-Type': 'application/x-www-form-urlencoded' } params[:client_assertion_type] = 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer' params[:client_assertion] = client.secret params[:grant_type] = 'urn:ietf:params:oauth:grant-type:jwt-bearer' diff --git a/spec/omniauth-azure-devops/version_spec.rb b/spec/omniauth-azure-devops/version_spec.rb index ce704e8..6b398ff 100644 --- a/spec/omniauth-azure-devops/version_spec.rb +++ b/spec/omniauth-azure-devops/version_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true describe Omniauth::AzureDevops do - it 'should have a version number' do + it 'has a version number' do expect(Omniauth::AzureDevops::VERSION).not_to be_nil end end diff --git a/spec/omniauth/strategies/azure_devops_spec.rb b/spec/omniauth/strategies/azure_devops_spec.rb index 79665a3..b397725 100644 --- a/spec/omniauth/strategies/azure_devops_spec.rb +++ b/spec/omniauth/strategies/azure_devops_spec.rb @@ -1,20 +1,20 @@ +# frozen_string_literal: true + require 'spec_helper' describe OmniAuth::Strategies::AzureDevops do - before :each do - @request = double('Request') - allow(@request).to receive(:params) { {} } - allow(@request).to receive(:scheme) { 'https' } - allow(@request).to receive(:url) { '/auth/azure_devops/callback' } - allow(@request).to receive(:env) { { 'rack.input' => StringIO.new } } - end - subject do - OmniAuth::Strategies::AzureDevops.new(nil, @options || {}).tap do |strategy| + described_class.new(nil, @options || {}).tap do |strategy| allow(strategy).to receive(:request) { @request } end end + before do + @request = double('Request') + allow(@request).to receive_messages(params: {}, scheme: 'https', url: '/auth/azure_devops/callback') + allow(@request).to receive(:env) { { 'rack.input' => StringIO.new } } + end + describe '#client' do it 'has correct Azure Devops api site' do expect(subject.options.client_options.site).to eq('https://app.vssps.visualstudio.com/') @@ -36,11 +36,11 @@ allow(subject).to receive(:raw_info).and_return(raw_info) end - it 'should return the correct name' do + it 'returns the correct name' do expect(subject.info[:name]).to eq('John Doe') end - it 'should return the correct email address' do + it 'returns the correct email address' do expect(subject.info[:email_address]).to eq('john.doe@example.com') end end @@ -52,54 +52,57 @@ allow(subject).to receive(:raw_info).and_return(raw_info) end - it 'should include the raw_info in extra data' do + it 'includes the raw_info in extra data' do expect(subject.extra[:raw_info]).to eq(raw_info) end end describe '#callback_path' do - it 'should have the correct callback path' do + it 'has the correct callback path' do expect(subject.callback_path).to eq('/auth/azure_devops/callback') end end describe '#callback_url' do - it 'should have the correct callback path' do + it 'has the correct callback path' do expect(subject.callback_url).to eq('/auth/azure_devops/callback') end end describe '#token_params' do - it 'should have the correct Content-Type' do + it 'has the correct Content-Type' do expect(subject.token_params[:headers]['Content-Type']).to eq('application/x-www-form-urlencoded') end - it 'should have the correct client_assertion_type' do + it 'has the correct client_assertion_type' do expect(subject.token_params[:client_assertion_type]).to eq('urn:ietf:params:oauth:client-assertion-type:jwt-bearer') end - it 'should have the correct grant_type' do + it 'has the correct grant_type' do expect(subject.token_params[:grant_type]).to eq('urn:ietf:params:oauth:grant-type:jwt-bearer') end - it 'should have the correct assertion' do - allow(@request).to receive(:params) { { 'code' => 'q0398109283019283019830192830192830192830129' } } + it 'has the correct assertion' do + allow(@request).to receive(:params).and_return({ 'code' => 'q0398109283019283019830192830192830192830129' }) expect(subject.token_params[:assertion]).to eq('q0398109283019283019830192830192830192830129') end - it 'should have the correct redirect_uri' do + it 'has the correct redirect_uri' do expect(subject.token_params[:redirect_uri]).to eq('/auth/azure_devops/callback') end end describe '#raw_info' do - let(:access_token) { instance_double('AccessToken', get: instance_double('Response', parsed: { 'id' => '123', 'display_name' => 'John Doe', 'email_address' => 'john.doe@example.com' })) } + let(:access_token) do + instance_double(AccessToken, + get: instance_double(Response, parsed: { 'id' => '123', 'display_name' => 'John Doe', 'email_address' => 'john.doe@example.com' })) + end before do allow(subject).to receive(:access_token).and_return(access_token) end - it 'should fetch and parse user profile information' do + it 'fetches and parse user profile information' do expect(subject.raw_info['id']).to eq('123') expect(subject.raw_info['display_name']).to eq('John Doe') expect(subject.raw_info['email_address']).to eq('john.doe@example.com') diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 6cc4449..728be62 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This file was generated by the `rspec --init` command. Conventionally, all # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. # The generated `.rspec` file contains `--require spec_helper` which will cause @@ -16,16 +18,16 @@ RSpec.configure do |config| require 'omniauth' require 'omniauth-azure-devops' - config.extend OmniAuth::Test::StrategyMacros, :type => :strategy + config.extend OmniAuth::Test::StrategyMacros, type: :strategy OmniAuth.config.test_mode = true require 'simplecov' require 'simplecov-console' SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new [ - SimpleCov::Formatter::HTMLFormatter, - SimpleCov::Formatter::Console - ] + SimpleCov::Formatter::HTMLFormatter, + SimpleCov::Formatter::Console + ] SimpleCov.start # rspec-expectations config goes here. You can use an alternate @@ -58,57 +60,55 @@ # triggering implicit auto-inclusion in groups with matching metadata. config.shared_context_metadata_behavior = :apply_to_host_groups -# The settings below are suggested to provide a good initial experience -# with RSpec, but feel free to customize to your heart's content. -=begin - # This allows you to limit a spec run to individual examples or groups - # you care about by tagging them with `:focus` metadata. When nothing - # is tagged with `:focus`, all examples get run. RSpec also provides - # aliases for `it`, `describe`, and `context` that include `:focus` - # metadata: `fit`, `fdescribe` and `fcontext`, respectively. - config.filter_run_when_matching :focus - - # Allows RSpec to persist some state between runs in order to support - # the `--only-failures` and `--next-failure` CLI options. We recommend - # you configure your source control system to ignore this file. - config.example_status_persistence_file_path = "spec/examples.txt" - - # Limits the available syntax to the non-monkey patched syntax that is - # recommended. For more details, see: - # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/ - # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ - # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode - config.disable_monkey_patching! - - # This setting enables warnings. It's recommended, but in some cases may - # be too noisy due to issues in dependencies. - config.warnings = true - - # Many RSpec users commonly either run the entire suite or an individual - # file, and it's useful to allow more verbose output when running an - # individual spec file. - if config.files_to_run.one? - # Use the documentation formatter for detailed output, - # unless a formatter has already been configured - # (e.g. via a command-line flag). - config.default_formatter = "doc" - end - - # Print the 10 slowest examples and example groups at the - # end of the spec run, to help surface which specs are running - # particularly slow. - config.profile_examples = 10 - - # Run specs in random order to surface order dependencies. If you find an - # order dependency and want to debug it, you can fix the order by providing - # the seed, which is printed after each run. - # --seed 1234 - config.order = :random - - # Seed global randomization in this process using the `--seed` CLI option. - # Setting this allows you to use `--seed` to deterministically reproduce - # test failures related to randomization by passing the same `--seed` value - # as the one that triggered the failure. - Kernel.srand config.seed -=end + # The settings below are suggested to provide a good initial experience + # with RSpec, but feel free to customize to your heart's content. + # # This allows you to limit a spec run to individual examples or groups + # # you care about by tagging them with `:focus` metadata. When nothing + # # is tagged with `:focus`, all examples get run. RSpec also provides + # # aliases for `it`, `describe`, and `context` that include `:focus` + # # metadata: `fit`, `fdescribe` and `fcontext`, respectively. + # config.filter_run_when_matching :focus + # + # # Allows RSpec to persist some state between runs in order to support + # # the `--only-failures` and `--next-failure` CLI options. We recommend + # # you configure your source control system to ignore this file. + # config.example_status_persistence_file_path = "spec/examples.txt" + # + # # Limits the available syntax to the non-monkey patched syntax that is + # # recommended. For more details, see: + # # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/ + # # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ + # # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode + # config.disable_monkey_patching! + # + # # This setting enables warnings. It's recommended, but in some cases may + # # be too noisy due to issues in dependencies. + # config.warnings = true + # + # # Many RSpec users commonly either run the entire suite or an individual + # # file, and it's useful to allow more verbose output when running an + # # individual spec file. + # if config.files_to_run.one? + # # Use the documentation formatter for detailed output, + # # unless a formatter has already been configured + # # (e.g. via a command-line flag). + # config.default_formatter = "doc" + # end + # + # # Print the 10 slowest examples and example groups at the + # # end of the spec run, to help surface which specs are running + # # particularly slow. + # config.profile_examples = 10 + # + # # Run specs in random order to surface order dependencies. If you find an + # # order dependency and want to debug it, you can fix the order by providing + # # the seed, which is printed after each run. + # # --seed 1234 + # config.order = :random + # + # # Seed global randomization in this process using the `--seed` CLI option. + # # Setting this allows you to use `--seed` to deterministically reproduce + # # test failures related to randomization by passing the same `--seed` value + # # as the one that triggered the failure. + # Kernel.srand config.seed end From ede1d6254208a5b12937461a27c070ceb6872abf Mon Sep 17 00:00:00 2001 From: Mandeep Khinda <32844597+mkhinda29@users.noreply.github.com> Date: Mon, 25 Sep 2023 11:17:46 -0400 Subject: [PATCH 06/19] bundle install --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 8600136..0643ea7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - omniauth-azure-devops (1.0.0) + omniauth-azure-devops (1.0.1) omniauth (>= 1, < 3) omniauth-oauth2 From a8d4dfa18aa044ca5ba34b784255295ab55205cb Mon Sep 17 00:00:00 2001 From: Mandeep Khinda <32844597+mkhinda29@users.noreply.github.com> Date: Mon, 25 Sep 2023 11:18:35 -0400 Subject: [PATCH 07/19] correct the version --- lib/omniauth-azure-devops/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/omniauth-azure-devops/version.rb b/lib/omniauth-azure-devops/version.rb index 5a9c7ac..222a82c 100644 --- a/lib/omniauth-azure-devops/version.rb +++ b/lib/omniauth-azure-devops/version.rb @@ -2,6 +2,6 @@ module Omniauth module AzureDevops - VERSION = '1.0.1' + VERSION = '1.1.0' end end From a9036918c5c76948b526bae4299e2c5c99364507 Mon Sep 17 00:00:00 2001 From: Mandeep Khinda <32844597+mkhinda29@users.noreply.github.com> Date: Mon, 25 Sep 2023 11:25:09 -0400 Subject: [PATCH 08/19] remove bundler cache --- .github/workflows/style.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml index 39d1baa..6c0dafd 100644 --- a/.github/workflows/style.yml +++ b/.github/workflows/style.yml @@ -41,7 +41,6 @@ jobs: uses: ruby/setup-ruby@v1 with: ruby-version: 3.2.2 - bundler-cache: true - name: rubocop uses: reviewdog/action-rubocop@e70b014b8062c447d6b515ee0209f834ea93e696 #v2.5.0 From 7d76588d6ad358e3d2b7c10485e03005e67639f3 Mon Sep 17 00:00:00 2001 From: Mandeep Khinda <32844597+mkhinda29@users.noreply.github.com> Date: Mon, 25 Sep 2023 11:26:23 -0400 Subject: [PATCH 09/19] remove use of bundler by reviewdog --- .github/workflows/style.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml index 6c0dafd..06e503e 100644 --- a/.github/workflows/style.yml +++ b/.github/workflows/style.yml @@ -50,4 +50,3 @@ jobs: github_token: ${{ secrets.github_token }} filter_mode: file fail_on_error: true - use_bundler: true From c165351de6869dc90e1760bd67bd86f8233a18dc Mon Sep 17 00:00:00 2001 From: Mandeep Khinda <32844597+mkhinda29@users.noreply.github.com> Date: Mon, 25 Sep 2023 11:27:50 -0400 Subject: [PATCH 10/19] bundle the corrected version --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 0643ea7..0fa0513 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - omniauth-azure-devops (1.0.1) + omniauth-azure-devops (1.1.0) omniauth (>= 1, < 3) omniauth-oauth2 From d39e65bfb63f0e00de2aa472808dee5aefdc06cf Mon Sep 17 00:00:00 2001 From: Mandeep Khinda <32844597+mkhinda29@users.noreply.github.com> Date: Mon, 25 Sep 2023 11:51:24 -0400 Subject: [PATCH 11/19] revert changes to spec --- spec/omniauth/strategies/azure_devops_spec.rb | 45 +++++++++---------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/spec/omniauth/strategies/azure_devops_spec.rb b/spec/omniauth/strategies/azure_devops_spec.rb index b397725..ce39619 100644 --- a/spec/omniauth/strategies/azure_devops_spec.rb +++ b/spec/omniauth/strategies/azure_devops_spec.rb @@ -3,18 +3,20 @@ require 'spec_helper' describe OmniAuth::Strategies::AzureDevops do + before :each do + @request = double('Request') + allow(@request).to receive(:params) { {} } + allow(@request).to receive(:scheme) { 'https' } + allow(@request).to receive(:url) { '/auth/azure_devops/callback' } + allow(@request).to receive(:env) { { 'rack.input' => StringIO.new } } + end + subject do - described_class.new(nil, @options || {}).tap do |strategy| + OmniAuth::Strategies::AzureDevops.new(nil, @options || {}).tap do |strategy| allow(strategy).to receive(:request) { @request } end end - before do - @request = double('Request') - allow(@request).to receive_messages(params: {}, scheme: 'https', url: '/auth/azure_devops/callback') - allow(@request).to receive(:env) { { 'rack.input' => StringIO.new } } - end - describe '#client' do it 'has correct Azure Devops api site' do expect(subject.options.client_options.site).to eq('https://app.vssps.visualstudio.com/') @@ -36,11 +38,11 @@ allow(subject).to receive(:raw_info).and_return(raw_info) end - it 'returns the correct name' do + it 'should return the correct name' do expect(subject.info[:name]).to eq('John Doe') end - it 'returns the correct email address' do + it 'should return the correct email address' do expect(subject.info[:email_address]).to eq('john.doe@example.com') end end @@ -52,57 +54,54 @@ allow(subject).to receive(:raw_info).and_return(raw_info) end - it 'includes the raw_info in extra data' do + it 'should include the raw_info in extra data' do expect(subject.extra[:raw_info]).to eq(raw_info) end end describe '#callback_path' do - it 'has the correct callback path' do + it 'should have the correct callback path' do expect(subject.callback_path).to eq('/auth/azure_devops/callback') end end describe '#callback_url' do - it 'has the correct callback path' do + it 'should have the correct callback path' do expect(subject.callback_url).to eq('/auth/azure_devops/callback') end end describe '#token_params' do - it 'has the correct Content-Type' do + it 'should have the correct Content-Type' do expect(subject.token_params[:headers]['Content-Type']).to eq('application/x-www-form-urlencoded') end - it 'has the correct client_assertion_type' do + it 'should have the correct client_assertion_type' do expect(subject.token_params[:client_assertion_type]).to eq('urn:ietf:params:oauth:client-assertion-type:jwt-bearer') end - it 'has the correct grant_type' do + it 'should have the correct grant_type' do expect(subject.token_params[:grant_type]).to eq('urn:ietf:params:oauth:grant-type:jwt-bearer') end - it 'has the correct assertion' do - allow(@request).to receive(:params).and_return({ 'code' => 'q0398109283019283019830192830192830192830129' }) + it 'should have the correct assertion' do + allow(@request).to receive(:params) { { 'code' => 'q0398109283019283019830192830192830192830129' } } expect(subject.token_params[:assertion]).to eq('q0398109283019283019830192830192830192830129') end - it 'has the correct redirect_uri' do + it 'should have the correct redirect_uri' do expect(subject.token_params[:redirect_uri]).to eq('/auth/azure_devops/callback') end end describe '#raw_info' do - let(:access_token) do - instance_double(AccessToken, - get: instance_double(Response, parsed: { 'id' => '123', 'display_name' => 'John Doe', 'email_address' => 'john.doe@example.com' })) - end + let(:access_token) { instance_double('AccessToken', get: instance_double('Response', parsed: { 'id' => '123', 'display_name' => 'John Doe', 'email_address' => 'john.doe@example.com' })) } before do allow(subject).to receive(:access_token).and_return(access_token) end - it 'fetches and parse user profile information' do + it 'should fetch and parse user profile information' do expect(subject.raw_info['id']).to eq('123') expect(subject.raw_info['display_name']).to eq('John Doe') expect(subject.raw_info['email_address']).to eq('john.doe@example.com') From 7f371615b892eebba2dc091722e11cd42d53fd5f Mon Sep 17 00:00:00 2001 From: Parth Chandgadhiya <73950482+Parth-Rewind@users.noreply.github.com> Date: Mon, 25 Sep 2023 11:08:49 -0600 Subject: [PATCH 12/19] Update rubocop yml --- .rubocop.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.rubocop.yml b/.rubocop.yml index 17b2e91..3c852f9 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -46,7 +46,8 @@ Metrics/PerceivedComplexity: Enabled: false # Naming cop configuration - +Naming/FileName: + Enabled: false Naming/MethodParameterName: Enabled: true Exclude: @@ -76,6 +77,12 @@ RSpec/MultipleMemoizedHelpers: Enabled: false RSpec/NestedGroups: Max: 5 +RSpec/VerifiedDoubleReference: + Enabled: false +RSpec/FilePath: + Enabled: false +RSpec/SpecFilePathFormat: + Enabled: false # Style cop configuration Style/ArgumentsForwarding: From d771c360a229e238f0604350106d5d44aea276c6 Mon Sep 17 00:00:00 2001 From: Parth Chandgadhiya <73950482+Parth-Rewind@users.noreply.github.com> Date: Mon, 25 Sep 2023 11:09:08 -0600 Subject: [PATCH 13/19] Fix rubocop errors --- spec/omniauth/strategies/azure_devops_spec.rb | 89 +++++++++---------- 1 file changed, 44 insertions(+), 45 deletions(-) diff --git a/spec/omniauth/strategies/azure_devops_spec.rb b/spec/omniauth/strategies/azure_devops_spec.rb index ce39619..ba7bb1c 100644 --- a/spec/omniauth/strategies/azure_devops_spec.rb +++ b/spec/omniauth/strategies/azure_devops_spec.rb @@ -1,33 +1,24 @@ # frozen_string_literal: true -require 'spec_helper' - describe OmniAuth::Strategies::AzureDevops do - before :each do - @request = double('Request') - allow(@request).to receive(:params) { {} } - allow(@request).to receive(:scheme) { 'https' } - allow(@request).to receive(:url) { '/auth/azure_devops/callback' } - allow(@request).to receive(:env) { { 'rack.input' => StringIO.new } } - end + let(:azure_devops_strategy) { described_class.new(nil) } + let(:request) { instance_double('Request', params: {}, scheme: 'https', url: '/auth/azure_devops/callback', env: { 'rack.input' => StringIO.new }) } - subject do - OmniAuth::Strategies::AzureDevops.new(nil, @options || {}).tap do |strategy| - allow(strategy).to receive(:request) { @request } - end + before do + allow(azure_devops_strategy).to receive(:request).and_return(request) end describe '#client' do it 'has correct Azure Devops api site' do - expect(subject.options.client_options.site).to eq('https://app.vssps.visualstudio.com/') + expect(azure_devops_strategy.options.client_options.site).to eq('https://app.vssps.visualstudio.com/') end it 'has correct access token path' do - expect(subject.options.client_options.token_url).to eq('https://app.vssps.visualstudio.com/oauth2/token') + expect(azure_devops_strategy.options.client_options.token_url).to eq('https://app.vssps.visualstudio.com/oauth2/token') end it 'has correct authorize url' do - expect(subject.options.client_options.authorize_url).to eq('https://app.vssps.visualstudio.com/oauth2/authorize') + expect(azure_devops_strategy.options.client_options.authorize_url).to eq('https://app.vssps.visualstudio.com/oauth2/authorize') end end @@ -35,15 +26,15 @@ let(:raw_info) { { 'display_name' => 'John Doe', 'email_address' => 'john.doe@example.com' } } before do - allow(subject).to receive(:raw_info).and_return(raw_info) + allow(azure_devops_strategy).to receive(:raw_info).and_return(raw_info) end - it 'should return the correct name' do - expect(subject.info[:name]).to eq('John Doe') + it 'returns the correct name' do + expect(azure_devops_strategy.info[:name]).to eq('John Doe') end - it 'should return the correct email address' do - expect(subject.info[:email_address]).to eq('john.doe@example.com') + it 'returns the correct email address' do + expect(azure_devops_strategy.info[:email_address]).to eq('john.doe@example.com') end end @@ -51,60 +42,68 @@ let(:raw_info) { { 'display_name' => 'John Doe', 'email_address' => 'john.doe@example.com' } } before do - allow(subject).to receive(:raw_info).and_return(raw_info) + allow(azure_devops_strategy).to receive(:raw_info).and_return(raw_info) end - it 'should include the raw_info in extra data' do - expect(subject.extra[:raw_info]).to eq(raw_info) + it 'includes the raw_info in extra data' do + expect(azure_devops_strategy.extra[:raw_info]).to eq(raw_info) end end describe '#callback_path' do - it 'should have the correct callback path' do - expect(subject.callback_path).to eq('/auth/azure_devops/callback') + it 'has the correct callback path' do + expect(azure_devops_strategy.callback_path).to eq('/auth/azure_devops/callback') end end describe '#callback_url' do - it 'should have the correct callback path' do - expect(subject.callback_url).to eq('/auth/azure_devops/callback') + it 'has the correct callback path' do + expect(azure_devops_strategy.callback_url).to eq('/auth/azure_devops/callback') end end describe '#token_params' do - it 'should have the correct Content-Type' do - expect(subject.token_params[:headers]['Content-Type']).to eq('application/x-www-form-urlencoded') + it 'has the correct Content-Type' do + expect(azure_devops_strategy.token_params[:headers]['Content-Type']).to eq('application/x-www-form-urlencoded') end - it 'should have the correct client_assertion_type' do - expect(subject.token_params[:client_assertion_type]).to eq('urn:ietf:params:oauth:client-assertion-type:jwt-bearer') + it 'has the correct client_assertion_type' do + expect(azure_devops_strategy.token_params[:client_assertion_type]).to eq('urn:ietf:params:oauth:client-assertion-type:jwt-bearer') end - it 'should have the correct grant_type' do - expect(subject.token_params[:grant_type]).to eq('urn:ietf:params:oauth:grant-type:jwt-bearer') + it 'has the correct grant_type' do + expect(azure_devops_strategy.token_params[:grant_type]).to eq('urn:ietf:params:oauth:grant-type:jwt-bearer') end - it 'should have the correct assertion' do - allow(@request).to receive(:params) { { 'code' => 'q0398109283019283019830192830192830192830129' } } - expect(subject.token_params[:assertion]).to eq('q0398109283019283019830192830192830192830129') + it 'has the correct assertion' do + allow(request).to receive(:params).and_return({ 'code' => 'q0398109283019283019830192830192830192830129' }) + expect(azure_devops_strategy.token_params[:assertion]).to eq('q0398109283019283019830192830192830192830129') end - it 'should have the correct redirect_uri' do - expect(subject.token_params[:redirect_uri]).to eq('/auth/azure_devops/callback') + it 'has the correct redirect_uri' do + expect(azure_devops_strategy.token_params[:redirect_uri]).to eq('/auth/azure_devops/callback') end end describe '#raw_info' do - let(:access_token) { instance_double('AccessToken', get: instance_double('Response', parsed: { 'id' => '123', 'display_name' => 'John Doe', 'email_address' => 'john.doe@example.com' })) } + let(:access_token) do + instance_double('AccessToken', + get: instance_double('Response', + parsed: { + 'id' => '123', + 'display_name' => 'John Doe', + 'email_address' => 'john.doe@example.com' + })) + end before do - allow(subject).to receive(:access_token).and_return(access_token) + allow(azure_devops_strategy).to receive(:access_token).and_return(access_token) end - it 'should fetch and parse user profile information' do - expect(subject.raw_info['id']).to eq('123') - expect(subject.raw_info['display_name']).to eq('John Doe') - expect(subject.raw_info['email_address']).to eq('john.doe@example.com') + it 'fetches and parses the user profile information' do + expect(azure_devops_strategy.raw_info['id']).to eq('123') + expect(azure_devops_strategy.raw_info['display_name']).to eq('John Doe') + expect(azure_devops_strategy.raw_info['email_address']).to eq('john.doe@example.com') end end end From b468c798628edded1dd15a064dd3dcf6ad6fc3cf Mon Sep 17 00:00:00 2001 From: Parth Chandgadhiya <73950482+Parth-Rewind@users.noreply.github.com> Date: Mon, 25 Sep 2023 12:10:50 -0600 Subject: [PATCH 14/19] Update Gemfile.lock --- Gemfile.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 0fa0513..440d4eb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -36,9 +36,9 @@ GEM hashie (>= 3.4.6) rack (>= 2.2.3) rack-protection - omniauth-oauth2 (1.7.3) + omniauth-oauth2 (1.8.0) oauth2 (>= 1.4, < 3) - omniauth (>= 1.9, < 3) + omniauth (~> 2.0) parallel (1.23.0) parser (3.2.2.3) ast (~> 2.4.1) @@ -113,7 +113,7 @@ GEM version_gem (1.1.3) PLATFORMS - ruby + x86_64-darwin-22 DEPENDENCIES bundler (~> 2.4) @@ -128,4 +128,4 @@ DEPENDENCIES simplecov-console (~> 0.9) BUNDLED WITH - 2.4.19 + 2.4.14 From 06267c40b6da6a9acca58c66de7e87747e56dc94 Mon Sep 17 00:00:00 2001 From: Parth Chandgadhiya <73950482+Parth-Rewind@users.noreply.github.com> Date: Mon, 25 Sep 2023 12:26:19 -0600 Subject: [PATCH 15/19] Refactor file names to follow rubygem guideline --- .rubocop.yml | 10 ++++++---- .../azure_devops}/version.rb | 2 +- lib/{omniauth => omni_auth}/strategies/azure_devops.rb | 0 lib/omniauth-azure-devops.rb | 4 ---- lib/omniauth_azure_devops.rb | 4 ++++ omniauth-azure-devops.gemspec | 4 ++-- spec/omni_auth/azure_devops/version_spec.rb | 7 +++++++ .../strategies/azure_devops_spec.rb | 0 spec/omniauth-azure-devops/version_spec.rb | 7 ------- spec/spec_helper.rb | 2 +- 10 files changed, 21 insertions(+), 19 deletions(-) rename lib/{omniauth-azure-devops => omni_auth/azure_devops}/version.rb (84%) rename lib/{omniauth => omni_auth}/strategies/azure_devops.rb (100%) delete mode 100644 lib/omniauth-azure-devops.rb create mode 100644 lib/omniauth_azure_devops.rb create mode 100644 spec/omni_auth/azure_devops/version_spec.rb rename spec/{omniauth => omni_auth}/strategies/azure_devops_spec.rb (100%) delete mode 100644 spec/omniauth-azure-devops/version_spec.rb diff --git a/.rubocop.yml b/.rubocop.yml index 3c852f9..bdace35 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -46,8 +46,8 @@ Metrics/PerceivedComplexity: Enabled: false # Naming cop configuration -Naming/FileName: - Enabled: false +#Naming/FileName: +# Enabled: false Naming/MethodParameterName: Enabled: true Exclude: @@ -80,9 +80,11 @@ RSpec/NestedGroups: RSpec/VerifiedDoubleReference: Enabled: false RSpec/FilePath: - Enabled: false + Exclude: + - spec/omni_auth/azure_devops/version_spec.rb RSpec/SpecFilePathFormat: - Enabled: false + Exclude: + - spec/omni_auth/azure_devops/version_spec.rb # Style cop configuration Style/ArgumentsForwarding: diff --git a/lib/omniauth-azure-devops/version.rb b/lib/omni_auth/azure_devops/version.rb similarity index 84% rename from lib/omniauth-azure-devops/version.rb rename to lib/omni_auth/azure_devops/version.rb index 222a82c..521d2c0 100644 --- a/lib/omniauth-azure-devops/version.rb +++ b/lib/omni_auth/azure_devops/version.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Omniauth +module OmniAuth module AzureDevops VERSION = '1.1.0' end diff --git a/lib/omniauth/strategies/azure_devops.rb b/lib/omni_auth/strategies/azure_devops.rb similarity index 100% rename from lib/omniauth/strategies/azure_devops.rb rename to lib/omni_auth/strategies/azure_devops.rb diff --git a/lib/omniauth-azure-devops.rb b/lib/omniauth-azure-devops.rb deleted file mode 100644 index e99f365..0000000 --- a/lib/omniauth-azure-devops.rb +++ /dev/null @@ -1,4 +0,0 @@ -# frozen_string_literal: true - -require 'omniauth-azure-devops/version' -require 'omniauth/strategies/azure_devops' diff --git a/lib/omniauth_azure_devops.rb b/lib/omniauth_azure_devops.rb new file mode 100644 index 0000000..a41214a --- /dev/null +++ b/lib/omniauth_azure_devops.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +require 'omni_auth/azure_devops/version' +require 'omni_auth/strategies/azure_devops' diff --git a/omniauth-azure-devops.gemspec b/omniauth-azure-devops.gemspec index d199def..0445d69 100644 --- a/omniauth-azure-devops.gemspec +++ b/omniauth-azure-devops.gemspec @@ -1,10 +1,10 @@ # frozen_string_literal: true -require File.expand_path('lib/omniauth-azure-devops/version', __dir__) +require File.expand_path('lib/omni_auth/azure_devops/version', __dir__) Gem::Specification.new do |gem| gem.name = 'omniauth-azure-devops' - gem.version = Omniauth::AzureDevops::VERSION + gem.version = OmniAuth::AzureDevops::VERSION gem.authors = ['Rewind Software Inc. | Parth Chandgadhiya'] gem.email = ['team@rewind.io'] diff --git a/spec/omni_auth/azure_devops/version_spec.rb b/spec/omni_auth/azure_devops/version_spec.rb new file mode 100644 index 0000000..fbf4e5c --- /dev/null +++ b/spec/omni_auth/azure_devops/version_spec.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +describe OmniAuth::AzureDevops do + it 'has a version number' do + expect(OmniAuth::AzureDevops::VERSION).not_to be_nil + end +end diff --git a/spec/omniauth/strategies/azure_devops_spec.rb b/spec/omni_auth/strategies/azure_devops_spec.rb similarity index 100% rename from spec/omniauth/strategies/azure_devops_spec.rb rename to spec/omni_auth/strategies/azure_devops_spec.rb diff --git a/spec/omniauth-azure-devops/version_spec.rb b/spec/omniauth-azure-devops/version_spec.rb deleted file mode 100644 index 6b398ff..0000000 --- a/spec/omniauth-azure-devops/version_spec.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -describe Omniauth::AzureDevops do - it 'has a version number' do - expect(Omniauth::AzureDevops::VERSION).not_to be_nil - end -end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 728be62..8bca50c 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -17,7 +17,7 @@ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration RSpec.configure do |config| require 'omniauth' - require 'omniauth-azure-devops' + require 'omniauth_azure_devops' config.extend OmniAuth::Test::StrategyMacros, type: :strategy OmniAuth.config.test_mode = true From 4206ecff97bc42d92a177f325d7467a50cad366a Mon Sep 17 00:00:00 2001 From: Parth Chandgadhiya <73950482+Parth-Rewind@users.noreply.github.com> Date: Mon, 25 Sep 2023 12:31:33 -0600 Subject: [PATCH 16/19] Update Gemfile.lock --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 440d4eb..65e87ab 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -113,7 +113,7 @@ GEM version_gem (1.1.3) PLATFORMS - x86_64-darwin-22 + ruby DEPENDENCIES bundler (~> 2.4) @@ -128,4 +128,4 @@ DEPENDENCIES simplecov-console (~> 0.9) BUNDLED WITH - 2.4.14 + 2.4.19 From ec7a1281ee7059c00032010047879f91218a47a5 Mon Sep 17 00:00:00 2001 From: Parth Chandgadhiya <73950482+Parth-Rewind@users.noreply.github.com> Date: Mon, 25 Sep 2023 12:35:43 -0600 Subject: [PATCH 17/19] Update gem spec --- omniauth-azure-devops.gemspec | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/omniauth-azure-devops.gemspec b/omniauth-azure-devops.gemspec index 0445d69..35dd5e1 100644 --- a/omniauth-azure-devops.gemspec +++ b/omniauth-azure-devops.gemspec @@ -12,6 +12,13 @@ Gem::Specification.new do |gem| gem.description = 'An Azure Devops OAuth strategy for OmniAuth 2.0' gem.homepage = 'https://github.com/rewind/omniauth-azure-devops' gem.license = 'MIT' + gem.metadata = { + "bug_tracker_uri" => "#{gem.homepage}/issues", + "changelog_uri" => "#{gem.homepage}/blob/main/CHANGELOG.md", + "documentation_uri" => gem.homepage.to_s, + "homepage_uri" => gem.homepage.to_s, + "source_code_uri" => gem.homepage.to_s, + } gem.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec|.github|examples)/}) } gem.bindir = 'exe' From cb3d7e182586010635d8e858e2911b36563ab554 Mon Sep 17 00:00:00 2001 From: Parth Chandgadhiya <73950482+Parth-Rewind@users.noreply.github.com> Date: Mon, 25 Sep 2023 12:39:54 -0600 Subject: [PATCH 18/19] rubocop fix --- omniauth-azure-devops.gemspec | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/omniauth-azure-devops.gemspec b/omniauth-azure-devops.gemspec index 35dd5e1..ecff9e8 100644 --- a/omniauth-azure-devops.gemspec +++ b/omniauth-azure-devops.gemspec @@ -13,11 +13,11 @@ Gem::Specification.new do |gem| gem.homepage = 'https://github.com/rewind/omniauth-azure-devops' gem.license = 'MIT' gem.metadata = { - "bug_tracker_uri" => "#{gem.homepage}/issues", - "changelog_uri" => "#{gem.homepage}/blob/main/CHANGELOG.md", - "documentation_uri" => gem.homepage.to_s, - "homepage_uri" => gem.homepage.to_s, - "source_code_uri" => gem.homepage.to_s, + 'bug_tracker_uri' => "#{gem.homepage}/issues", + 'changelog_uri' => "#{gem.homepage}/blob/main/CHANGELOG.md", + 'documentation_uri' => gem.homepage.to_s, + 'homepage_uri' => gem.homepage.to_s, + 'source_code_uri' => gem.homepage.to_s, } gem.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec|.github|examples)/}) } From 55ae707e99f71d6bd5b193577e9d3c223f405e6b Mon Sep 17 00:00:00 2001 From: Parth Chandgadhiya <73950482+Parth-Rewind@users.noreply.github.com> Date: Mon, 25 Sep 2023 12:45:45 -0600 Subject: [PATCH 19/19] Refactor gem metadata to include rubygems_mfa_required --- omniauth-azure-devops.gemspec | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/omniauth-azure-devops.gemspec b/omniauth-azure-devops.gemspec index ecff9e8..f5e99d5 100644 --- a/omniauth-azure-devops.gemspec +++ b/omniauth-azure-devops.gemspec @@ -13,11 +13,12 @@ Gem::Specification.new do |gem| gem.homepage = 'https://github.com/rewind/omniauth-azure-devops' gem.license = 'MIT' gem.metadata = { + 'rubygems_mfa_required' => 'true', 'bug_tracker_uri' => "#{gem.homepage}/issues", 'changelog_uri' => "#{gem.homepage}/blob/main/CHANGELOG.md", 'documentation_uri' => gem.homepage.to_s, 'homepage_uri' => gem.homepage.to_s, - 'source_code_uri' => gem.homepage.to_s, + 'source_code_uri' => gem.homepage.to_s } gem.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec|.github|examples)/}) } @@ -29,6 +30,4 @@ Gem::Specification.new do |gem| gem.add_runtime_dependency 'omniauth', '>= 1', '< 3' gem.add_runtime_dependency 'omniauth-oauth2' - - gem.metadata['rubygems_mfa_required'] = 'true' end