Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRM457-2216 part 8: Stop pub sub #850

Merged
merged 1 commit into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/actions/delete-dev-release/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ runs:

if [[ ! -z "$found" ]]
then
kubectl exec deploy/$release_name -it -- bundle exec rails app_store:unsubscribe
helm delete $release_name
kubectl delete pvc data-$release_name-postgresql-0
kubectl delete pvc redis-data-$release_name-redis-master-0
Expand Down
18 changes: 0 additions & 18 deletions app/controllers/sync_controller.rb

This file was deleted.

22 changes: 0 additions & 22 deletions app/services/app_store_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,6 @@ class AppStoreClient
include HTTParty
headers 'Content-Type' => 'application/json'

def get_all_submissions(last_update)
url = "/v1/applications?since=#{last_update.to_i}"
response = self.class.get "#{host}#{url}", **options

process_response(
response,
"Unexpected response from AppStore - status #{response.code} for '#{url}'",
200 => ->(body) { JSON.parse(body) },
)
end

def get_submission(submission_id)
url = "/v1/submissions/#{submission_id}"
response = self.class.get "#{host}#{url}", **options
Expand Down Expand Up @@ -49,17 +38,6 @@ def update_submission_metadata(submission, payload)
)
end

def trigger_subscription(payload, action: :create)
method = action == :create ? :post : :delete
response = self.class.send(method, "#{host}/v1/subscriber", **options(payload))

process_response(
response,
"Unexpected response from AppStore - status #{response.code} on #{action} subscription",
200..204 => :success,
)
end

def create_events(submission_id, payload)
response = self.class.post("#{host}/v1/submissions/#{submission_id}/events", **options(payload))

Expand Down
45 changes: 0 additions & 45 deletions app/services/app_store_subscriber.rb

This file was deleted.

46 changes: 0 additions & 46 deletions app/services/app_store_token_authenticator.rb

This file was deleted.

2 changes: 1 addition & 1 deletion app/views/prior_authority/applications/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</div>
<div class="govuk-grid-column-two-thirds">
<h2 class="govuk-heading-m"><%= t('.overview') %></h2>
<% if @details.assessment_comment.present? %>
<% if @summary.assessed? && @details.assessment_comment.present? %>
<div class="govuk-inset-text">
<p><strong><%= t(".assessed_statuses.#{@details.submission.state}") %></strong></p>
<p> <%= simple_format @details.assessment_comment %></p>
Expand Down
4 changes: 0 additions & 4 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,5 @@ class Application < Rails::Application
end

config.x.contact.feedback_url = 'tbc'
config.after_initialize do
Rails.application.reload_routes!
AppStoreSubscriber.subscribe
end
end
end
5 changes: 0 additions & 5 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,7 @@
resource :search, only: %i[new show]
end

if ENV.fetch("ENABLE_SYNC_TRIGGER_ENDPOINT", false) == "true"
get "sync", to: "sync#sync_all"
end
get "robots.txt", to: "robots#index"

post :app_store_webhook, to: 'sync#sync_individual'

resource :dashboard, only: %i[new show]
end
7 changes: 0 additions & 7 deletions lib/tasks/app_store.rake

This file was deleted.

21 changes: 0 additions & 21 deletions spec/lib/tasks/app_store_unsubscribe_spec.rb

This file was deleted.

76 changes: 0 additions & 76 deletions spec/requests/sync_spec.rb

This file was deleted.

85 changes: 0 additions & 85 deletions spec/services/app_store_client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,47 +13,6 @@
.and_return(response)
end

describe '#get_all_submissions' do
context 'when APP_STORE_URL is present' do
before do
allow(ENV).to receive(:fetch).with('APP_STORE_URL', 'http://localhost:8000')
.and_return('http://some.url')
end

it 'get the claims to the specified URL' do
expect(described_class).to receive(:get).with('http://some.url/v1/applications?since=1',
headers: { authorization: 'Bearer test-bearer-token' })

subject.get_all_submissions(1)
end
end

context 'when APP_STORE_URL is not present' do
it 'get the claims to default localhost url' do
expect(described_class).to receive(:get).with('https://appstore.example.com/v1/applications?since=1',
headers: { authorization: 'Bearer test-bearer-token' })

subject.get_all_submissions(1)
end
end

context 'when response code is 200 - ok' do
it 'returns the parsed json' do
expect(subject.get_all_submissions(1)).to eq('some' => 'data')
end
end

context 'when response code is unexpected (neither 201 or 209)' do
let(:code) { 501 }

it 'raises and error' do
expect { subject.get_all_submissions(1) }.to raise_error(
"Unexpected response from AppStore - status 501 for '/v1/applications?since=1'"
)
end
end
end

describe '#update_submission' do
let(:application_id) { SecureRandom.uuid }
let(:message) { { application_id: } }
Expand Down Expand Up @@ -138,50 +97,6 @@
end
end

describe '#trigger_subscription' do
let(:application_id) { SecureRandom.uuid }
let(:message) { { application_id: } }
let(:response) { double(:response, code:) }
let(:code) { 201 }
let(:username) { nil }

before do
allow(described_class).to receive_messages(post: response, delete: response)
end

it 'posts the message to host url' do
expect(described_class).to receive(:post).with('https://appstore.example.com/v1/subscriber',
body: message.to_json,
headers: { authorization: 'Bearer test-bearer-token' })

subject.trigger_subscription(message)
end

it 'uses delete if a destroy action is specified' do
expect(described_class).to receive(:delete).with('https://appstore.example.com/v1/subscriber',
body: message.to_json,
headers: { authorization: 'Bearer test-bearer-token' })

subject.trigger_subscription(message, action: :destroy)
end

context 'when response code is 201 - created' do
it 'returns a created status' do
expect(subject.trigger_subscription(message)).to eq(:success)
end
end

context 'when response code is unexpected (neither 200 or 201)' do
let(:code) { 501 }

it 'raises an error' do
expect { subject.trigger_subscription(message) }.to raise_error(
'Unexpected response from AppStore - status 501 on create subscription'
)
end
end
end

describe '#create_events' do
let(:application_id) { SecureRandom.uuid }
let(:message) { [{ event: :data }] }
Expand Down
Loading