Skip to content

Commit

Permalink
Merge branch 'integrationTesting' of github.com:transcom/mymove into …
Browse files Browse the repository at this point in the history
…B-17919-INT
  • Loading branch information
r-mettler committed Jan 31, 2024
2 parents f068681 + 56e1635 commit 61eba8c
Show file tree
Hide file tree
Showing 419 changed files with 12,896 additions and 20,751 deletions.
12 changes: 6 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,30 +40,30 @@ references:

# In addition, it's common practice to disable acceptance tests and
# ignore tests for dp3 deploys. See the branch settings below.
dp3-branch: &dp3-branch placeholder_branch_name
dp3-branch: &dp3-branch integrationTesting
# MUST BE ONE OF: loadtest, demo, exp.
# These are used to pull in env vars so the spelling matters!
dp3-env: &dp3-env placeholder_env
dp3-env: &dp3-env loadtest

# set integration-ignore-branch to the branch if you want to IGNORE
# integration tests, or `placeholder_branch_name` if you do want to
# run them
integration-ignore-branch: &integration-ignore-branch placeholder_branch_name
integration-ignore-branch: &integration-ignore-branch integrationTesting

# set integration-mtls-ignore-branch to the branch if you want to
# IGNORE mtls integration tests, or `placeholder_branch_name` if you
# do want to run them
integration-mtls-ignore-branch: &integration-mtls-ignore-branch placeholder_branch_name
integration-mtls-ignore-branch: &integration-mtls-ignore-branch integrationTesting

# set client-ignore-branch to the branch if you want to IGNORE
# client tests, or `placeholder_branch_name` if you do want to run
# them
client-ignore-branch: &client-ignore-branch placeholder_branch_name
client-ignore-branch: &client-ignore-branch integrationTesting

# set server-ignore-branch to the branch if you want to IGNORE
# server tests, or `placeholder_branch_name` if you do want to run
# them
server-ignore-branch: &server-ignore-branch placeholder_branch_name
server-ignore-branch: &server-ignore-branch integrationTesting

executors:
base_small:
Expand Down
4 changes: 4 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ export DB_NAME_TEST=test_db
export DB_RETRY_INTERVAL=5s
export DB_SSL_MODE=disable

# Experimental feature flags, these will be replaced by the config/env/*.env files for live deployments
# Multi Move feature flag
export FEATURE_FLAG_MULTI_MOVE=true

# Okta.mil configuration

# Tenant
Expand Down
73 changes: 16 additions & 57 deletions cmd/generate-shipment-summary/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"bytes"
"fmt"
"log"
"net/http"
Expand All @@ -16,22 +15,20 @@ import (
"go.uber.org/zap"

"github.com/transcom/mymove/pkg/appcontext"
"github.com/transcom/mymove/pkg/assets"
"github.com/transcom/mymove/pkg/auth"
"github.com/transcom/mymove/pkg/cli"
"github.com/transcom/mymove/pkg/logging"
"github.com/transcom/mymove/pkg/models"
"github.com/transcom/mymove/pkg/paperwork"
"github.com/transcom/mymove/pkg/rateengine"
"github.com/transcom/mymove/pkg/route"
shipmentsummaryworksheet "github.com/transcom/mymove/pkg/services/shipment_summary_worksheet"
)

// hereRequestTimeout is how long to wait on HERE request before timing out (15 seconds).
const hereRequestTimeout = time.Duration(15) * time.Second

const (
moveIDFlag string = "move"
debugFlag string = "debug"
PPMShipmentIDFlag string = "ppmshipment"
debugFlag string = "debug"
)

func noErr(err error) {
Expand Down Expand Up @@ -60,7 +57,7 @@ func checkConfig(v *viper.Viper, logger *zap.Logger) error {
func initFlags(flag *pflag.FlagSet) {

// Scenario config
flag.String(moveIDFlag, "", "The move ID to generate a shipment summary worksheet for")
flag.String(PPMShipmentIDFlag, "6d1d9d00-2e5e-4830-a3c1-5c21c951e9c1", "The PPMShipmentID to generate a shipment summary worksheet for")
flag.Bool(debugFlag, false, "show field debug output")

// DB Config
Expand Down Expand Up @@ -119,7 +116,7 @@ func main() {

appCtx := appcontext.NewAppContext(dbConnection, logger, nil)

moveID := v.GetString(moveIDFlag)
moveID := v.GetString(PPMShipmentIDFlag)
if moveID == "" {
log.Fatalf("Usage: %s --move <29cb984e-c70d-46f0-926d-cd89e07a6ec3>", os.Args[0])
}
Expand All @@ -137,9 +134,8 @@ func main() {
formFiller.Debug()
}

move, err := models.FetchMoveByMoveID(dbConnection, parsedID)
if err != nil {
log.Fatalf("error fetching move: %s", moveIDFlag)
log.Fatalf("error fetching ppmshipment: %s", PPMShipmentIDFlag)
}

geocodeEndpoint := os.Getenv("HERE_MAPS_GEOCODE_ENDPOINT")
Expand All @@ -148,62 +144,25 @@ func main() {
testAppCode := os.Getenv("HERE_MAPS_APP_CODE")
hereClient := &http.Client{Timeout: hereRequestTimeout}

// TODO: Future cleanup will need to remap to a different planner, or this command should be removed if it is consider deprecated
// TODO: Future cleanup will need to remap to a different planner, but this command should remain for testing purposes
planner := route.NewHEREPlanner(hereClient, geocodeEndpoint, routingEndpoint, testAppID, testAppCode)
ppmComputer := paperwork.NewSSWPPMComputer(rateengine.NewRateEngine(move))
ppmComputer := shipmentsummaryworksheet.NewSSWPPMComputer()

ssfd, err := models.FetchDataShipmentSummaryWorksheetFormData(dbConnection, &auth.Session{}, parsedID)
ssfd, err := ppmComputer.FetchDataShipmentSummaryWorksheetFormData(appCtx, &auth.Session{}, parsedID)
if err != nil {
log.Fatalf("%s", errors.Wrap(err, "Error fetching shipment summary worksheet data "))
}
ssfd.Obligations, err = ppmComputer.ComputeObligations(appCtx, ssfd, planner)
ssfd.Obligations, err = ppmComputer.ComputeObligations(appCtx, *ssfd, planner)
if err != nil {
log.Fatalf("%s", errors.Wrap(err, "Error calculating obligations "))
}

page1Data, page2Data, page3Data, err := models.FormatValuesShipmentSummaryWorksheet(ssfd)
page1Data, page2Data := ppmComputer.FormatValuesShipmentSummaryWorksheet(*ssfd)
noErr(err)

// page 1
page1Layout := paperwork.ShipmentSummaryPage1Layout
page1Template, err := assets.Asset(page1Layout.TemplateImagePath)
noErr(err)

page1Reader := bytes.NewReader(page1Template)
err = formFiller.AppendPage(page1Reader, page1Layout.FieldsLayout, page1Data)
noErr(err)

// page 2
page2Layout := paperwork.ShipmentSummaryPage2Layout
page2Template, err := assets.Asset(page2Layout.TemplateImagePath)
noErr(err)

page2Reader := bytes.NewReader(page2Template)
err = formFiller.AppendPage(page2Reader, page2Layout.FieldsLayout, page2Data)
noErr(err)

// page 3
page3Layout := paperwork.ShipmentSummaryPage3Layout
page3Template, err := assets.Asset(page3Layout.TemplateImagePath)
ppmGenerator := shipmentsummaryworksheet.NewSSWPPMGenerator()
ssw, info, err := ppmGenerator.FillSSWPDFForm(page1Data, page2Data)
noErr(err)

page3Reader := bytes.NewReader(page3Template)
err = formFiller.AppendPage(page3Reader, page3Layout.FieldsLayout, page3Data)
noErr(err)

filename := fmt.Sprintf("shipment-summary-worksheet-%s.pdf", time.Now().Format(time.RFC3339))

output, err := os.Create(filename)
noErr(err)

defer func() {
if closeErr := output.Close(); closeErr != nil {
logger.Error("Could not close output file", zap.Error(closeErr))
}
}()

err = formFiller.Output(output)
noErr(err)

fmt.Println(filename)
fmt.Println(ssw.Name()) // Should always return
fmt.Println(info.PageCount) // Page count should always be 2
// This is a testing command, above lines log information on whether PDF was generated successfully.
}
8 changes: 7 additions & 1 deletion cmd/milmove/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,12 @@ func buildRoutingConfig(appCtx appcontext.AppContext, v *viper.Viper, redisPool

featureFlagFetcher, err := featureflag.NewFeatureFlagFetcher(cli.GetFliptFetcherConfig(v))
if err != nil {
appCtx.Logger().Fatal("Could not instantiate feature flag featcher", zap.Error(err))
appCtx.Logger().Fatal("Could not instantiate feature flag fetcher", zap.Error(err))
}

envFetcher, err := featureflag.NewEnvFetcher(cli.GetFliptFetcherConfig(v))
if err != nil {
appCtx.Logger().Fatal("Could not instantiate env fetcher", zap.Error(err))
}

routingConfig.HandlerConfig = handlers.NewHandlerConfig(
Expand All @@ -562,6 +567,7 @@ func buildRoutingConfig(appCtx appcontext.AppContext, v *viper.Viper, redisPool
appNames,
sessionManagers,
featureFlagFetcher,
envFetcher,
)

initializeRouteOptions(v, routingConfig)
Expand Down
1 change: 1 addition & 0 deletions config/env/demo.app-client-tls.env
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ TELEMETRY_ENABLED=true
TELEMETRY_ENDPOINT=localhost:4317
TELEMETRY_USE_XRAY_ID=true
TLS_ENABLED=true
FEATURE_FLAG_MULTI_MOVE=false
1 change: 1 addition & 0 deletions config/env/demo.app.env
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ TELEMETRY_ENDPOINT=localhost:4317
TELEMETRY_USE_XRAY_ID=true
TLS_ENABLED=true
SERVE_PRIME_SIMULATOR=true
FEATURE_FLAG_MULTI_MOVE=false
1 change: 1 addition & 0 deletions config/env/exp.app-client-tls.env
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ TLS_ENABLED=true
TELEMETRY_ENABLED=false
TELEMETRY_ENDPOINT=localhost:4317
TELEMETRY_USE_XRAY_ID=false
FEATURE_FLAG_MULTI_MOVE=false
1 change: 1 addition & 0 deletions config/env/exp.app.env
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ SERVE_PRIME_SIMULATOR=true
TELEMETRY_ENABLED=true
TELEMETRY_ENDPOINT=localhost:4317
TELEMETRY_USE_XRAY_ID=true
FEATURE_FLAG_MULTI_MOVE=true
1 change: 1 addition & 0 deletions config/env/loadtest.app-client-tls.env
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ TELEMETRY_ENABLED=true
TELEMETRY_ENDPOINT=localhost:4317
TELEMETRY_USE_XRAY_ID=true
TLS_ENABLED=true
FEATURE_FLAG_MULTI_MOVE=false
6 changes: 5 additions & 1 deletion config/env/loadtest.app.env
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ SERVE_ADMIN=true
SERVE_API_GHC=true
SERVE_API_INTERNAL=true
SERVE_CLIENT_COLLECTOR=true
SERVE_SWAGGER_UI=false
SERVE_SWAGGER_UI=true
TELEMETRY_ENABLED=true
TELEMETRY_ENDPOINT=localhost:4317
TELEMETRY_USE_XRAY_ID=true
TLS_ENABLED=true
SERVE_PRIME_SIMULATOR=true
GEX_SEND_PROD_INVOICE=false
GEX_URL=https://gexb.gw.daas.dla.mil/msg_data/submit/
FEATURE_FLAG_MULTI_MOVE=false
1 change: 1 addition & 0 deletions config/env/prd.app-client-tls.env
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ TELEMETRY_ENABLED=true
TELEMETRY_ENDPOINT=localhost:4317
TELEMETRY_USE_XRAY_ID=true
TLS_ENABLED=true
FEATURE_FLAG_MULTI_MOVE=false
1 change: 1 addition & 0 deletions config/env/prd.app.env
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ TELEMETRY_ENDPOINT=localhost:4317
TELEMETRY_USE_XRAY_ID=true
TLS_ENABLED=true
SERVE_PRIME_SIMULATOR=false
FEATURE_FLAG_MULTI_MOVE=false
1 change: 1 addition & 0 deletions config/env/stg.app-client-tls.env
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ TELEMETRY_ENABLED=true
TELEMETRY_ENDPOINT=localhost:4317
TELEMETRY_USE_XRAY_ID=true
TLS_ENABLED=true
FEATURE_FLAG_MULTI_MOVE=false
1 change: 1 addition & 0 deletions config/env/stg.app.env
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ TELEMETRY_ENDPOINT=localhost:4317
TELEMETRY_USE_XRAY_ID=true
TLS_ENABLED=true
SERVE_PRIME_SIMULATOR=true
FEATURE_FLAG_MULTI_MOVE=false
5 changes: 4 additions & 1 deletion migrations/app/migrations_manifest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -889,5 +889,8 @@
20231226174935_create_ppm_documents_triggers.up.sql
20240103174317_add_customer_expense.up.sql
20240109200110_add_address_columns_to_ppmshipments4.up.sql
20240112205201_remove_ppm_estimated_weight.up.sql
20240119005610_add_authorized_end_date_to_mto_services_items.up.sql
20240123213917_update_shipment_address_update_table_sit_and_distance_columns.up.sql
20240124153121_remove_ppmid_from_signedcertification_table.up.sql
20240124155759_20240124-homesafeconnect-cert.up.sql
20240129153006_20240129-homesafeconnect-cert.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alter table moves drop column ppm_estimated_weight;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE mto_service_items ADD COLUMN sit_authorized_end_date date NULL;
COMMENT ON COLUMN mto_service_items.sit_authorized_end_date IS 'The Date a service item in SIT needs to leave SIT';
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
-- Adds new columns to shipment address update table
ALTER TABLE shipment_address_updates
ADD COLUMN sit_original_address_id uuid DEFAULT NULL,
ADD COLUMN old_sit_distance_between INTEGER DEFAULT NULL,
ADD COLUMN new_sit_distance_between INTEGER DEFAULT NULL;

-- Add foreign key constraint
ALTER TABLE shipment_address_updates
ADD CONSTRAINT fk_sit_original_address
FOREIGN KEY (sit_original_address_id) REFERENCES addresses(id);

-- Comments on new columns
COMMENT on COLUMN shipment_address_updates.sit_original_address_id IS 'SIT address at the original time of SIT approval';
COMMENT on COLUMN shipment_address_updates.old_sit_distance_between IS 'Distance between original SIT address and previous shipment destination address';
COMMENT on COLUMN shipment_address_updates.new_sit_distance_between IS 'Distance between original SIT address and new shipment destination address';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alter table signed_certifications drop column personally_procured_move_id; /* field is deprecrated */
Original file line number Diff line number Diff line change
@@ -1,4 +1,68 @@
-- Local test migration.
-- This will be run on development environments.
-- It should mirror what you intend to apply on prd/stg/exp/demo
-- DO NOT include any sensitive data.
-- This migration allows a CAC cert to have read/write access to all orders and the prime API.
-- The Orders API and the Prime API use client certificate authentication. Only certificates
-- signed by a trusted CA (such as DISA) are allowed which includes CACs.
-- Using a person's CAC as the certificate is a convenient way to permit a
-- single trusted individual to interact with the Orders API and the Prime API. Eventually
-- this CAC certificate should be removed.
INSERT INTO users (
id,
okta_email,
created_at,
updated_at)
VALUES (
'87fc5974-fbc9-4719-a3e2-b609647478d7',
'25b64f60444878e22c3cbfbbfdeb6e3e38832ade1c9704a7bd906b709c15bf38' || '@api.move.mil',
now(),
now());

INSERT INTO users_roles (
id,
role_id,
user_id,
created_at,
updated_at)
VALUES (
uuid_generate_v4(),
(SELECT id FROM roles WHERE role_type = 'prime'),
'87fc5974-fbc9-4719-a3e2-b609647478d7',
now(),
now());

INSERT INTO public.client_certs (
id,
sha256_digest,
subject,
user_id,
allow_orders_api,
allow_prime,
created_at,
updated_at,
allow_air_force_orders_read,
allow_air_force_orders_write,
allow_army_orders_read,
allow_army_orders_write,
allow_coast_guard_orders_read,
allow_coast_guard_orders_write,
allow_marine_corps_orders_read,
allow_marine_corps_orders_write,
allow_navy_orders_read,
allow_navy_orders_write)
VALUES (
'3a80db0d-a204-49f9-a9b2-359f57378e01',
'25b64f60444878e22c3cbfbbfdeb6e3e38832ade1c9704a7bd906b709c15bf38',
'C=US, O=U.S. Government, OU=ECA, OU=IdenTrust, OU=MOVEHQ INC., CN=mmb.gov.uat.homesafeconnect.com',
'87fc5974-fbc9-4719-a3e2-b609647478d7',
true,
true,
now(),
now(),
true,
true,
true,
true,
true,
true,
true,
true,
true,
true);

This file was deleted.

Loading

0 comments on commit 61eba8c

Please sign in to comment.