Skip to content
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
12 changes: 9 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,15 @@ lint_yarn_lock: package.json yarn.lock

lint_lockfiles: lint_gemfile_lock lint_yarn_lock ## Lints to ensure lockfiles are in sync

lintfix: ## Runs rubocop fix
lintfix: ## Try to automatically fix any ruby, ERB, javascript, or CSS lint errors
@echo "--- rubocop fix ---"
bundle exec rubocop -a
@echo "--- erblint fix ---"
bundle exec erblint app/views app/components -a
@echo "--- eslint fix ---"
yarn lint --fix
@echo "--- stylelint fix ---"
yarn lint:css --fix

brakeman: ## Runs brakeman
bundle exec brakeman
Expand Down Expand Up @@ -159,8 +165,8 @@ run-https: tmp/$(HOST)-$(PORT).key tmp/$(HOST)-$(PORT).crt ## Runs the developme

normalize_yaml: ## Normalizes YAML files (alphabetizes keys, fixes line length, smart quotes)
yarn normalize-yaml .rubocop.yml --disable-sort-keys --disable-smart-punctuation
find ./config/locales/telephony -type f | xargs yarn normalize-yaml --disable-smart-punctuation
find ./config/locales -not -path "./config/locales/telephony*" -type f | xargs yarn normalize-yaml \
find ./config/locales/telephony -type f -name '*.yml' | xargs yarn normalize-yaml --disable-smart-punctuation
find ./config/locales -not -path "./config/locales/telephony*" -type f -name '*.yml' | xargs yarn normalize-yaml \
config/pinpoint_supported_countries.yml \
config/pinpoint_overrides.yml \
config/country_dialing_codes.yml
Expand Down
12 changes: 5 additions & 7 deletions app/controllers/api/irs_attempts_api_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class IrsAttemptsApiController < ApplicationController
def create
start_time = Time.zone.now.to_f
if timestamp
if IdentityConfig.store.irs_attempt_api_aws_s3_enabled
if s3_helper.attempts_serve_events_from_s3
if IrsAttemptApiLogFile.find_by(requested_time: timestamp_key(key: timestamp))
log_file_record = IrsAttemptApiLogFile.find_by(
requested_time: timestamp_key(key: timestamp),
Expand All @@ -29,10 +29,8 @@ def create
headers['X-Payload-Key'] = log_file_record.encrypted_key
headers['X-Payload-IV'] = log_file_record.iv

bucket_name = IdentityConfig.store.irs_attempt_api_bucket_name

requested_data = s3_client.get_object(
bucket: bucket_name,
requested_data = s3_helper.s3_client.get_object(
bucket: s3_helper.attempts_bucket_name,
key: log_file_record.filename,
)

Expand Down Expand Up @@ -102,8 +100,8 @@ def redis_client
@redis_client ||= IrsAttemptsApi::RedisClient.new
end

def s3_client
@s3_client ||= JobHelpers::S3Helper.new.s3_client
def s3_helper
@s3_helper ||= JobHelpers::S3Helper.new
end

def valid_auth_tokens
Expand Down
1 change: 1 addition & 0 deletions app/javascript/packages/build-sass/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
### Improvements

- Improves watch mode error recovery to monitor changes to all files in the stack trace of the error.
- Adds support for `--load-path=` flag to include additional default paths in Sass path resolution.

## 1.0.0 (2022-11-21)

Expand Down
3 changes: 2 additions & 1 deletion app/javascript/packages/build-sass/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ Default behavior includes:
Invoke the included `build-sass` executable with the source files and any relevant command flags.

```
npx build-sass path/to/sass/*.css.scss --out-dir=build
npx build-sass path/to/sass/*.css.scss --out-dir=build --load-path=node_modules/@uswds/uswds/packages
```

Flags:

- `--out-dir`: The output directory
- `--watch`: Run in watch mode, recompiling files on change
- `--load-path`: Include additional path in Sass path resolution

### API

Expand Down
5 changes: 4 additions & 1 deletion app/javascript/packages/build-sass/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@ const flags = args.filter((arg) => arg.startsWith('-'));

const isWatching = flags.includes('--watch');
const outDir = flags.find((flag) => flag.startsWith('--out-dir='))?.slice(10);
const loadPaths = flags
.filter((flag) => flag.startsWith('--load-path='))
.map((flag) => flag.slice(12));

/** @type {BuildOptions & SyncSassOptions} */
const options = { outDir, optimize: isProduction };
const options = { outDir, loadPaths, optimize: isProduction };

/**
* Watches given file path(s), triggering the callback on the first change.
Expand Down
4 changes: 2 additions & 2 deletions app/javascript/packages/build-sass/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ const TARGETS = browserslistToTargets(
* @return {Promise<CompileResult>}
*/
export async function buildFile(file, options) {
const { outDir, optimize, ...sassOptions } = options;
const { outDir, optimize, loadPaths = [], ...sassOptions } = options;
const sassResult = sass.compile(file, {
style: optimize ? 'compressed' : 'expanded',
...sassOptions,
loadPaths: ['node_modules'],
loadPaths: ['node_modules', ...loadPaths],
quietDeps: true,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ import InPersonLocations, { FormattedLocation } from './in-person-locations';
interface PostOffice {
address: string;
city: string;
distance: string;
name: string;
phone: string;
saturday_hours: string;
state: string;
sunday_hours: string;
tty: string;
weekday_hours: string;
zip_code_4: string;
zip_code_5: string;
Expand All @@ -37,11 +39,13 @@ const formatLocation = (postOffices: PostOffice[]) => {
const location = {
formattedCityStateZip: `${po.city}, ${po.state}, ${po.zip_code_5}-${po.zip_code_4}`,
id: index,
distance: po.distance,
name: po.name,
phone: po.phone,
saturdayHours: po.saturday_hours,
streetAddress: po.address,
sundayHours: po.sunday_hours,
tty: po.tty,
weekdayHours: po.weekday_hours,
} as FormattedLocation;
formattedLocations.push(location);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import LocationCollectionItem from './location-collection-item';

export interface FormattedLocation {
formattedCityStateZip: string;
distance: string;
id: number;
name: string;
phone: string;
tty: string;
saturdayHours: string;
streetAddress: string;
sundayHours: string;
Expand Down Expand Up @@ -47,10 +49,12 @@ function InPersonLocations({ locations, onSelect, address }: InPersonLocationsPr
<LocationCollectionItem
key={`${index}-${item.name}`}
handleSelect={onSelect}
name={`${item.name} — ${t('in_person_proofing.body.location.post_office')}`}
distance={item.distance}
streetAddress={item.streetAddress}
selectId={item.id}
formattedCityStateZip={item.formattedCityStateZip}
phone={item.phone}
tty={item.tty}
weekdayHours={item.weekdayHours}
saturdayHours={item.saturdayHours}
sundayHours={item.sundayHours}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,28 @@ describe('LocationCollectionItem', () => {
.parentElement!;
expect(sunHours.textContent).to.contain('Closed');
});

it('renders the component that includes contact information with expected data', () => {
const onClick = sinon.stub();
const { getByText } = render(
<LocationCollectionItem
distance="1.0 mi"
phone="555-123-4567"
tty="222-222-2222"
name=""
streetAddress="123 Test Address"
formattedCityStateZip=""
handleSelect={onClick}
weekdayHours=""
saturdayHours=""
selectId={0}
sundayHours=""
/>,
);

const addressParent = getByText('123 Test Address').parentElement!;
expect(addressParent.textContent).to.contain('in_person_proofing.body.location.distance');
expect(addressParent.textContent).to.contain('555-123-4567');
expect(addressParent.textContent).to.contain('222-222-2222');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,47 @@ import { Button } from '@18f/identity-components';
import { useI18n } from '@18f/identity-react-i18n';

interface LocationCollectionItemProps {
distance?: string;
formattedCityStateZip: string;
handleSelect: (event: React.FormEvent<HTMLInputElement>, selection: number) => void;
name: string;
name?: string;
phone?: string;
saturdayHours: string;
selectId: number;
streetAddress: string;
sundayHours: string;
tty?: string;
weekdayHours: string;
}

function LocationCollectionItem({
distance,
formattedCityStateZip,
handleSelect,
name,
phone,
saturdayHours,
selectId,
streetAddress,
sundayHours,
tty,
weekdayHours,
}: LocationCollectionItemProps) {
const { t } = useI18n();
const numericDistance = distance?.split(' ')[0];

return (
<li className="location-collection-item">
<div className="usa-collection__body">
<div className="display-flex flex-justify">
<h3 className="usa-collection__heading">{name}</h3>
{numericDistance && (
<h3 className="usa-collection__heading">
{t('in_person_proofing.body.location.distance', {
count: parseFloat(numericDistance),
})}
</h3>
)}
{!distance && <h3 className="usa-collection__heading">{name}</h3>}
<Button
id={`location_button_desktop_${selectId}`}
className="display-none tablet:display-inline-block"
Expand All @@ -46,6 +60,13 @@ function LocationCollectionItem({
<div>{`${t('in_person_proofing.body.location.retail_hours_weekday')} ${weekdayHours}`}</div>
<div>{`${t('in_person_proofing.body.location.retail_hours_sat')} ${saturdayHours}`}</div>
<div>{`${t('in_person_proofing.body.location.retail_hours_sun')} ${sundayHours}`}</div>
{(phone || tty) && (
<div>
<h4>{t('in_person_proofing.body.location.contact_info_heading')}</h4>
<div>{`${t('in_person_proofing.body.location.phone')} ${phone}`}</div>
<div>{`${t('in_person_proofing.body.location.tty')} ${tty}`}</div>
</div>
)}
<Button
id={`location_button_mobile_${selectId}`}
className="tablet:display-none margin-top-2 width-full"
Expand Down
12 changes: 6 additions & 6 deletions app/jobs/irs_attempts_events_batch_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ class IrsAttemptsEventsBatchJob < ApplicationJob
queue_as :default

def perform(timestamp = Time.zone.now - 1.hour)
enabled = IdentityConfig.store.irs_attempt_api_enabled &&
IdentityConfig.store.irs_attempt_api_aws_s3_enabled &&
IdentityConfig.store.irs_attempt_api_bucket_name
enabled = IdentityConfig.store.irs_attempt_api_enabled && s3_helper.attempts_s3_write_enabled
return nil unless enabled

events = IrsAttemptsApi::RedisClient.new.read_events(timestamp: timestamp)
Expand All @@ -16,10 +14,8 @@ def perform(timestamp = Time.zone.now - 1.hour)
data: event_values, timestamp: timestamp, public_key_str: public_key,
)

bucket_name = IdentityConfig.store.irs_attempt_api_bucket_name

create_and_upload_to_attempts_s3_resource(
bucket_name: bucket_name, filename: result.filename,
bucket_name: s3_helper.attempts_bucket_name, filename: result.filename,
encrypted_data: result.encrypted_data
)

Expand All @@ -42,4 +38,8 @@ def create_and_upload_to_attempts_s3_resource(bucket_name:, filename:, encrypted
def redis_client
@redis_client ||= IrsAttemptsApi::RedisClient.new
end

def s3_helper
@s3_helper ||= JobHelpers::S3Helper.new
end
end
12 changes: 12 additions & 0 deletions app/jobs/job_helpers/s3_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,17 @@ def s3_client
compute_checksums: false,
)
end

def attempts_bucket_name
IdentityConfig.store.irs_attempt_api_bucket_name
end

def attempts_s3_write_enabled
(attempts_bucket_name && attempts_bucket_name != 'default-placeholder')
end

def attempts_serve_events_from_s3
IdentityConfig.store.irs_attempt_api_aws_s3_enabled && attempts_s3_write_enabled
end
end
end
1 change: 1 addition & 0 deletions app/models/profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class Profile < ApplicationRecord
verification_cancelled: 4,
in_person_verification_pending: 5,
threatmetrix_review_pending: 6,
threatmetrix_review_rejected: 7,
}

attr_reader :personal_key
Expand Down
4 changes: 4 additions & 0 deletions app/models/proofing_component.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
class ProofingComponent < ApplicationRecord
belongs_to :user

def review_eligible?
verified_at.after?(30.days.ago)
end
end
4 changes: 1 addition & 3 deletions app/presenters/two_factor_login_options_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,7 @@ def account_reset_link
end

def account_reset_url(locale:)
IdentityConfig.store.show_account_recovery_recovery_options ?
account_reset_recovery_options_path(locale: locale) :
account_reset_request_path(locale: locale)
account_reset_recovery_options_path(locale: locale)
end

def account_reset_cancel_link
Expand Down
1 change: 1 addition & 0 deletions app/services/usps_in_person_proofing/post_office.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module UspsInPersonProofing
:saturday_hours,
:state,
:sunday_hours,
:tty,
:weekday_hours,
:zip_code_4,
:zip_code_5,
Expand Down
1 change: 1 addition & 0 deletions app/services/usps_in_person_proofing/proofer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ def parse_facilities(facilities)
saturday_hours: hours['saturdayHours'],
state: post_office['state'],
sunday_hours: hours['sundayHours'],
tty: post_office['tty'],
weekday_hours: hours['weekdayHours'],
zip_code_4: post_office['zip4'],
zip_code_5: post_office['zip5'],
Expand Down
12 changes: 8 additions & 4 deletions app/views/devise/passwords/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@
url: user_password_path,
html: { autocomplete: 'off', method: :post },
) do |f| %>
<%= f.input :email,
required: true,
input_html: { autocorrect: 'off',
aria: { invalid: false, describedby: 'email-description' } } %>
<%= render ValidatedFieldComponent.new(
form: f,
name: :email,
label: t('account.index.email'),
required: true,
input_html: { autocorrect: 'off',
aria: { describedby: 'email-description' } },
) %>
<%= f.input :request_id, as: :hidden, input_html: { value: request_id } %>
<%= f.submit t('forms.buttons.continue'), class: 'display-block margin-y-5' %>
<% end %>
Expand Down
6 changes: 3 additions & 3 deletions app/views/idv/setup_errors/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
title: t('titles.failure.information_not_verified'),
heading: t('idv.failure.setup.heading'),
) do %>
<p>
<%= t('idv.failure.setup.fail_html', contact_form_link: link_to(t('idv.failure.setup.link_text'), contact_redirect_url(flow: :idv, step: :secure_account)), support_code: IdentityConfig.store.lexisnexis_threatmetrix_support_code) %>
</p>
<p>
<%= t('idv.failure.setup.fail_html', support_code: IdentityConfig.store.lexisnexis_threatmetrix_support_code, contact_number: IdentityConfig.store.idv_contact_phone_number) %>
</p>
<% end %>
Loading