Skip to content

Commit

Permalink
Merge branch 'master' into MHV-56068/tracking-list-data-serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
dcloud authored Mar 26, 2024
2 parents 720bdde + 137d71f commit 940788f
Show file tree
Hide file tree
Showing 158 changed files with 6,375 additions and 632 deletions.
64 changes: 64 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"name": "vets-api native setup",
"image": "mcr.microsoft.com/devcontainers/base:bullseye",

"features": {
"ghcr.io/devcontainers-contrib/features/ruby-asdf:0": {
"version": "3.2.3"
},
"ghcr.io/robbert229/devcontainer-features/postgresql-client:1": {
"version": "15"
},
"ghcr.io/devcontainers-contrib/features/redis-homebrew:1": {
"version": "6.2"
}
},

"forwardPorts": [
3000,
9293,
5432,
6379
],
"portsAttributes": {
"3000": {
"label": "vets-api",
"onAutoForward": "notify",
"requireLocalPort": true
},
"9293": {
"label": "vets-api-healthcheck",
"onAutoForward": "silent",
"requireLocalPort": true
},
"5432": {
"label": "postgis",
"onAutoForward": "silent",
"requireLocalPort": true
},
"6379": {
"label": "redis",
"onAutoForward": "silent",
"requireLocalPort": true
}
},

"postCreateCommand": "sh .devcontainer/post-create.sh",
"postStartCommand": "sh .devcontainer/post-start.sh",

"customizations": {
"codespaces": {
"repositories": {
"department-of-veterans-affairs/vets-api-mockdata": {
"permissions": {
"contents": "read",
"pull_requests": "write"
}
}
}
},
"vscode": {
"extensions": ["ms-azuretools.vscode-docker", "Shopify.ruby-lsp"]
}
}
}
51 changes: 51 additions & 0 deletions .devcontainer/post-create.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/sh

# Add welcome message
sudo cp .devcontainer/welcome.txt /usr/local/etc/vscode-dev-containers/first-run-notice.txt

# Switch to vets-api ruby version
export PATH="${HOME}/.asdf/shims:${HOME}/.asdf/bin:${PATH}"
asdf install ruby $( cat .ruby-version )
asdf global ruby $( cat .ruby-version )

git clone https://github.com/department-of-veterans-affairs/vets-api-mockdata.git ../vets-api-mockdata

sudo apt update
sudo apt install -y libpq-dev pdftk shared-mime-info postgresql-15-postgis-3

gem install bundler
NUM_CORES=$( cat /proc/cpuinfo | grep '^processor'|wc -l )
bundle config --global jobs `expr $NUM_CORES - 1`

# Update test DB config
echo 'test_database_url: postgis://postgres:password@localhost:5432/vets_api_test?pool=4' > config/settings/test.local.yml

# Add service config
if [ ! -f config/settings.local.yml ]; then
cp config/settings.local.yml.example config/settings.local.yml
cat <<EOT >> config/settings.local.yml
database_url: postgis://postgres:password@localhost:5432/vets_api_development?pool=4
test_database_url: postgis://postgres:password@localhost:5432/vets_api_test?pool=4
redis:
host: localhost
port: 6379
app_data:
url: redis://localhost:6379
sidekiq:
url: redis://localhost:6379
betamocks:
cache_dir: ../vets-api-mockdata
# Allow access from localhost and shared github URLs.
virtual_hosts: ["127.0.0.1", "localhost", !ruby/regexp /.*\.app\.github\.dev/]
EOT
fi

mkdir -p log
nohup bash -c '/home/linuxbrew/.linuxbrew/opt/[email protected]/bin/redis-server /home/linuxbrew/.linuxbrew/etc/redis.conf' >> log/redis.log 2>&1 &
sudo /etc/init.d/postgresql restart
pg_isready -t 60
sudo -u root sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'password';"
./bin/setup
9 changes: 9 additions & 0 deletions .devcontainer/post-start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

echo "Starting redis..."
nohup /home/linuxbrew/.linuxbrew/opt/[email protected]/bin/redis-server /home/linuxbrew/.linuxbrew/etc/redis.conf >> log/redis.log 2>&1 &

echo "Starting postgres..."
sudo /etc/init.d/postgresql restart
echo "Waiting for postgres to be ready..."
pg_isready -t 60
9 changes: 9 additions & 0 deletions .devcontainer/welcome.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
~~~~~~ Welcome to vets-api on codespaces! ~~~~~~

For more information, see the codespaces README in docs/setup.

~~~~~~ Quickstart ~~~~~

To start vets-api, run this command:

foreman start -m all=1,clamd=0,freshclam=0
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Gemfile @department-of-veterans-affairs/backend-review-group
Gemfile.lock @department-of-veterans-affairs/backend-review-group
Jenkinsfile @department-of-veterans-affairs/backend-review-group
Makefile @department-of-veterans-affairs/backend-review-group
.devcontainer @department-of-veterans-affairs/backend-review-group @department-of-veterans-affairs/cto-engineers
app/controllers/appeals_base_controller.rb @department-of-veterans-affairs/backend-review-group
app/controllers/appeals_base_controller_v1.rb @department-of-veterans-affairs/backend-review-group
app/controllers/application_controller.rb @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
Expand Down Expand Up @@ -777,6 +778,7 @@ docs/setup/native.md @department-of-veterans-affairs/backend-review-group @depar
docs/setup/rswag_setup.md @department-of-veterans-affairs/backend-review-group @department-of-veterans-affairs/va-api-engineers
docs/setup/running_docker.md @department-of-veterans-affairs/backend-review-group @department-of-veterans-affairs/va-api-engineers
docs/setup/running_natively.md @department-of-veterans-affairs/backend-review-group @department-of-veterans-affairs/va-api-engineers
docs/setup/codespaces.md @department-of-veterans-affairs/backend-review-group @department-of-veterans-affairs/cto-engineers
docs/setup/va_forms.md @department-of-veterans-affairs/platform-va-product-forms @department-of-veterans-affairs/backend-review-group @department-of-veterans-affairs/va-api-engineers
docs/setup/virtual_machine_access.md @department-of-veterans-affairs/backend-review-group @department-of-veterans-affairs/va-api-engineers
.github @department-of-veterans-affairs/backend-review-group
Expand Down
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ end

group :test do
gem 'apivore', git: 'https://github.com/department-of-veterans-affairs/apivore', tag: 'v2.0.0.vsp'
gem 'fakeredis'
gem 'mock_redis'
gem 'pdf-inspector'
gem 'rspec_junit_formatter'
gem 'rspec-retry'
Expand Down Expand Up @@ -215,7 +215,7 @@ group :development, :test do
gem 'rubocop-rails'
gem 'rubocop-rspec'
gem 'rubocop-thread_safety'
gem 'sidekiq', '>= 6.4.0'
gem 'sidekiq', '~> 7.2.0'
gem 'timecop'
gem 'webmock'
gem 'yard'
Expand Down
44 changes: 24 additions & 20 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,13 @@ PATH
GEM
remote: https://enterprise.contribsys.com/
specs:
sidekiq-ent (2.5.3)
einhorn (>= 0.7.4)
sidekiq (>= 6.5.0, < 7)
sidekiq-pro (>= 5.5.0, < 6)
sidekiq-pro (5.5.8)
sidekiq (~> 6.0, >= 6.5.6)
sidekiq-ent (7.2.2)
einhorn (~> 1.0)
gserver
sidekiq (>= 7.2.0, < 8)
sidekiq-pro (>= 7.2.0, < 8)
sidekiq-pro (7.2.0)
sidekiq (>= 7.2.0, < 8)

GEM
remote: https://rubygems.org/
Expand Down Expand Up @@ -282,7 +283,7 @@ GEM
bundler (>= 1.2.0, < 3)
thor (~> 1.0)
byebug (11.1.3)
carrierwave (3.0.6)
carrierwave (3.0.7)
activemodel (>= 6.0.0)
activesupport (>= 6.0.0)
addressable (~> 2.6)
Expand Down Expand Up @@ -415,10 +416,8 @@ GEM
factory_bot_rails (6.4.3)
factory_bot (~> 6.4)
railties (>= 5.0.0)
faker (3.2.3)
faker (3.3.0)
i18n (>= 1.8.11, < 2)
fakeredis (0.9.2)
redis (~> 4.8)
faraday (2.9.0)
faraday-net_http (>= 2.0, < 3.2)
faraday-follow_redirects (0.3.0)
Expand Down Expand Up @@ -634,6 +633,7 @@ GEM
mini_mime (1.1.5)
mini_portile2 (2.8.5)
minitest (5.22.3)
mock_redis (0.44.0)
msgpack (1.7.2)
msgpack (1.7.2-java)
multi_json (1.15.0)
Expand Down Expand Up @@ -691,7 +691,7 @@ GEM
os (1.1.4)
ox (2.14.18)
parallel (1.24.0)
parallel_tests (4.5.2)
parallel_tests (4.6.0)
parallel
parser (3.3.0.5)
ast (~> 2.4.1)
Expand Down Expand Up @@ -810,9 +810,12 @@ GEM
rb-inotify (0.10.1)
ffi (~> 1.0)
rchardet (1.8.0)
rdoc (6.6.2)
rdoc (6.6.3.1)
psych (>= 4.0.0)
redis (4.8.1)
redis (5.1.0)
redis-client (>= 0.17.0)
redis-client (0.20.0)
connection_pool
redis-namespace (1.11.0)
redis (>= 4)
regexp_parser (2.9.0)
Expand Down Expand Up @@ -904,7 +907,7 @@ GEM
rubocop-factory_bot (2.25.1)
rubocop (~> 1.41)
rubocop-junit-formatter (0.1.4)
rubocop-rails (2.24.0)
rubocop-rails (2.24.1)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
Expand Down Expand Up @@ -954,10 +957,11 @@ GEM
shrine (3.5.0)
content_disposition (~> 1.0)
down (~> 5.1)
sidekiq (6.5.12)
connection_pool (>= 2.2.5, < 3)
rack (~> 2.0)
redis (>= 4.5.0, < 5)
sidekiq (7.2.2)
concurrent-ruby (< 2)
connection_pool (>= 2.3.0)
rack (>= 2.2.4)
redis-client (>= 0.19.0)
sidekiq_alive (2.4.0)
gserver (~> 0.0.1)
sidekiq (>= 5, < 8)
Expand Down Expand Up @@ -1122,7 +1126,6 @@ DEPENDENCIES
facilities_api!
factory_bot_rails
faker
fakeredis
faraday (~> 2.9)
faraday-follow_redirects
faraday-httpclient
Expand Down Expand Up @@ -1170,6 +1173,7 @@ DEPENDENCIES
mimemagic
mini_magick
mobile!
mock_redis
mocked_authentication!
my_health!
net-sftp
Expand Down Expand Up @@ -1234,7 +1238,7 @@ DEPENDENCIES
sentry-ruby
shoulda-matchers
shrine
sidekiq (>= 6.4.0)
sidekiq (~> 7.2.0)
sidekiq-ent!
sidekiq-pro!
sidekiq_alive
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ For frontend, see [vets-website](https://github.com/department-of-veterans-affai
- [Native setup](docs/setup/native.md) (OSX/Ubuntu)
- [Docker setup](docs/setup/docker.md)
- [Hybrid setup](docs/setup/hybrid.md)
- [Codespaces setup](docs/setup/codespaces.md)
## Running the app
Expand Down
8 changes: 1 addition & 7 deletions app/controllers/concerns/headers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,7 @@
module Headers
extend ActiveSupport::Concern

included { prepend_before_action :block_unknown_hosts, :set_app_info_headers }

# returns a Bad Request if the incoming host header is unsafe.
def block_unknown_hosts
return if controller_name == 'example'
raise Common::Exceptions::NotASafeHostError, request.host unless Settings.virtual_hosts.include?(request.host)
end
included { prepend_before_action :set_app_info_headers }

def set_app_info_headers
headers['X-Git-SHA'] = AppInfo::GIT_REVISION
Expand Down
12 changes: 9 additions & 3 deletions app/controllers/v0/burial_claims_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,24 @@ class BurialClaimsController < ClaimsBaseController

def create
PensionBurial::TagSentry.tag_sentry
claim = claim_class.new(form: filtered_params[:form])

claim = if Flipper.enabled?(:va_burial_v2)
# cannot parse a nil form, to pass unit tests do a check for form presence
form = filtered_params[:form]
claim_class.new(form:, formV2: form.present? ? JSON.parse(form)['formV2'] : nil)
else
claim_class.new(form: filtered_params[:form])
end

unless claim.save
StatsD.increment("#{stats_key}.failure")
Sentry.set_tags(team: 'benefits-memorial-1') # tag sentry logs with team name
raise Common::Exceptions::ValidationErrors, claim
end

# this method also calls claim.process_attachments!
claim.submit_to_structured_data_services!

Rails.logger.info "ClaimID=#{claim.confirmation_number} Form=#{claim.class::FORM}"
Rails.logger.info "ClaimID=#{claim.confirmation_number} Form=#{claim.form_id}"
clear_saved_form(claim.form_id)
render(json: claim)
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/v0/claim_documents_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def create

def klass
case form_id
when '21P-527EZ', '21P-530'
when '21P-527EZ', '21P-530', '21P-530V2'
PensionBurial::TagSentry.tag_sentry
PersistentAttachments::PensionBurial
when '21-686C', '686C-674'
Expand Down
4 changes: 3 additions & 1 deletion app/controllers/v0/pension_claims_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require 'pension_21p527ez/tag_sentry'

module V0
class PensionClaimsController < ClaimsBaseController
service_tag 'pension-application'
Expand Down Expand Up @@ -45,7 +47,7 @@ def show
# Creates and validates an instance of the class, removing any copies of
# the form that had been previously saved by the user.
def create
PensionBurial::TagSentry.tag_sentry
Pension21p527ez::TagSentry.tag_sentry

claim = claim_class.new(form: filtered_params[:form])
user_uuid = current_user&.uuid
Expand Down
Loading

0 comments on commit 940788f

Please sign in to comment.