Skip to content

Commit

Permalink
Merge branch 'master' into ds-mb-8798-react-file-viewer-update-fix-de…
Browse files Browse the repository at this point in the history
…precation-msg
  • Loading branch information
duncan-truss committed Jul 22, 2021
2 parents 9e7d727 + 7c96a2e commit 8a310fa
Show file tree
Hide file tree
Showing 23 changed files with 344 additions and 58 deletions.
2 changes: 1 addition & 1 deletion go.mod
Expand Up @@ -56,7 +56,7 @@ require (
github.com/pdfcpu/pdfcpu v0.2.5
github.com/pkg/errors v0.9.1
github.com/pkg/sftp v1.13.2
github.com/pterm/pterm v0.12.28
github.com/pterm/pterm v0.12.29
github.com/rickar/cal v1.0.5
github.com/spf13/afero v1.6.0
github.com/spf13/cobra v1.2.1
Expand Down
8 changes: 6 additions & 2 deletions go.sum
Expand Up @@ -51,6 +51,8 @@ github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym
github.com/DATA-DOG/go-txdb v0.1.4 h1:6On4TAD6V33/QlE6Y5l0A4KngRzYrUQ7bgPsDrFrtQo=
github.com/DATA-DOG/go-txdb v0.1.4/go.mod h1:DhAhxMXZpUJVGnT+p9IbzJoRKvlArO2pkHjnGX7o0n0=
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
github.com/MarvinJWendt/testza v0.1.0 h1:4m+JkB/4e0nUlXdIa10Mg0poUz9CanQKjB3L+xecjAo=
github.com/MarvinJWendt/testza v0.1.0/go.mod h1:7AxNvlfeHP7Z/hDQ5JtE3OKYT3XFUeLCDE2DQninSqs=
github.com/Masterminds/semver/v3 v3.0.3/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs=
github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc=
github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs=
Expand Down Expand Up @@ -820,8 +822,9 @@ github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7z
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A=
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
github.com/pterm/pterm v0.12.28 h1:G2PVa6EZuILXDJqBiTRfzkgKCWTS9PaVRS/53ImHjhI=
github.com/pterm/pterm v0.12.28/go.mod h1:pcEzRwDT/cBbz/Ba7+AXNQCLS+TOd0fT2us4OA23pwU=
github.com/pterm/pterm v0.12.27/go.mod h1:PhQ89w4i95rhgE+xedAoqous6K9X+r6aSOI2eFF7DZI=
github.com/pterm/pterm v0.12.29 h1:wWRNFkC3+fk/agzHIO4aaXtQuRYdXJKngP3ed+LZlMU=
github.com/pterm/pterm v0.12.29/go.mod h1:WI3qxgvoQFFGKGjGnJR849gU0TsEOvKn5Q8LlY1U7lg=
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
github.com/rickar/cal v1.0.5 h1:ccTH7okdpqbT+X7hlWgQM4Hv3rTvpV8Stu7enQx7ywY=
github.com/rickar/cal v1.0.5/go.mod h1:3GBx8OBrvh4/y/JTxM0e1bUUIHMnqILl1rMANHWExxQ=
Expand Down Expand Up @@ -1211,6 +1214,7 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22 h1:RqytpXGR1iVNX7psjB3ff8y7sNFinVFvkx1c8SjBkio=
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b h1:9zKuko04nR4gjZ4+DNjHqRlAJqbJETHwiNKDqTfOjfE=
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand Down
2 changes: 2 additions & 0 deletions migrations/app/migrations_manifest.txt
Expand Up @@ -652,3 +652,5 @@
20210706214857_felipe_cac.up.sql
20210713232711_remove_can_stand_alone_parameter.up.sql
20210714221936_change_cubic_feet_crating_to_decimal.up.sql
20210720183133_create_rds_pgaudit_role.up.sql
20210721192603_remove_erin_cac_certs.up.sql
@@ -0,0 +1,7 @@
-- Assume the master role, which has the ability to create roles.
SET ROLE master;

-- Create a new role named "rds_pgaudit" as indicated by the AWS documentation:
-- https://aws.amazon.com/premiumsupport/knowledge-center/rds-postgresql-pgaudit/
-- https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Appendix.PostgreSQL.CommonDBATasks.html#Appendix.PostgreSQL.CommonDBATasks.pgaudit
CREATE ROLE rds_pgaudit;
@@ -0,0 +1,2 @@
-- Remove erin CAC using unique sha256 digest of client cert
DELETE FROM client_certs WHERE sha256_digest='d72d8acfa6c5e8e6aa036f69a817a000db8387dfa5ed4397d1aa636b82949330';
14 changes: 14 additions & 0 deletions pkg/gen/primeapi/embedded_spec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions pkg/gen/primemessages/m_t_o_service_item_domestic_crating.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pkg/handlers/primeapi/mto_service_item_test.go
Expand Up @@ -309,6 +309,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemDomesticCratingHandler() {
},
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
Reason: handlers.FmtString("reason"),
}

suite.T().Run("Successful POST - Integration Test - Domestic Crating", func(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions pkg/handlers/primeapi/payloads/model_to_payload.go
Expand Up @@ -464,6 +464,7 @@ func MTOServiceItem(mtoServiceItem *models.MTOServiceItem) primemessages.MTOServ
Width: crate.Width.Int32Ptr(),
},
Description: mtoServiceItem.Description,
Reason: mtoServiceItem.Reason,
}
case models.ReServiceCodeDDSHUT, models.ReServiceCodeDOSHUT:
payload = &primemessages.MTOServiceItemShuttle{
Expand Down
17 changes: 11 additions & 6 deletions pkg/handlers/primeapi/payloads/payload_to_model.go
Expand Up @@ -307,6 +307,7 @@ func MTOServiceItemModel(mtoServiceItem primemessages.MTOServiceItem) (*models.M
// have to get code from payload
model.ReService.Code = models.ReServiceCode(*domesticCrating.ReServiceCode)
model.Description = domesticCrating.Description
model.Reason = domesticCrating.Reason
model.Dimensions = models.MTOServiceItemDimensions{
models.MTOServiceItemDimension{
Type: models.DimensionTypeItem,
Expand Down Expand Up @@ -365,18 +366,22 @@ func MTOServiceItemModelFromUpdate(mtoServiceItemID string, mtoServiceItem prime
if verrs != nil && verrs.HasAny() {
return nil, verrs
}

return model, nil
case primemessages.UpdateMTOServiceItemModelTypeUpdateMTOServiceItemShuttle:
shuttle := mtoServiceItem.(*primemessages.UpdateMTOServiceItemShuttle)
model.EstimatedWeight = handlers.PoundPtrFromInt64Ptr(shuttle.EstimatedWeight)
model.ActualWeight = handlers.PoundPtrFromInt64Ptr(shuttle.ActualWeight)
return model, nil
}

verrs.Add("mtoServiceItem", "The model type of the service item is not allowed")
return nil, verrs
if verrs != nil && verrs.HasAny() {
return nil, verrs
}
default:
// assume basic service item
if verrs != nil && verrs.HasAny() {
return nil, verrs
}
}

return model, nil
}

// validateDomesticCrating validates this mto service item domestic crating
Expand Down
113 changes: 113 additions & 0 deletions pkg/handlers/primeapi/payloads/payload_to_model_test.go
@@ -0,0 +1,113 @@
package payloads

import (
"testing"

"github.com/gofrs/uuid"

"github.com/transcom/mymove/pkg/gen/primemessages"
"github.com/transcom/mymove/pkg/handlers"
"github.com/transcom/mymove/pkg/models"
"github.com/transcom/mymove/pkg/unit"
)

func (suite *PayloadsSuite) TestMTOServiceItemModel() {
moveTaskOrderIDField, _ := uuid.NewV4()
mtoShipmentIDField, _ := uuid.NewV4()
mtoShipmentIDString := handlers.FmtUUID(mtoShipmentIDField)

// Basic Service Item
basicServieItem := &primemessages.MTOServiceItemBasic{
ReServiceCode: "FSC",
}

basicServieItem.SetMoveTaskOrderID(handlers.FmtUUID(moveTaskOrderIDField))
basicServieItem.SetMtoShipmentID(*mtoShipmentIDString)

// DCRT Service Item
itemMeasurement := int32(1100)
crateMeasurement := int32(1200)
dcrtCode := "DCRT"
reason := "Reason"
description := "Description"

item := &primemessages.MTOServiceItemDimension{
Height: &itemMeasurement,
Width: &itemMeasurement,
Length: &itemMeasurement,
}

crate := &primemessages.MTOServiceItemDimension{
Height: &crateMeasurement,
Width: &crateMeasurement,
Length: &crateMeasurement,
}

DCRTServiceItem := &primemessages.MTOServiceItemDomesticCrating{
ReServiceCode: &dcrtCode,
Reason: &reason,
Description: &description,
Item: item,
Crate: crate,
}

DCRTServiceItem.SetMoveTaskOrderID(handlers.FmtUUID(moveTaskOrderIDField))
DCRTServiceItem.SetMtoShipmentID(*mtoShipmentIDString)

suite.T().Run("Success - Returns a basic service item model", func(t *testing.T) {
returnedModel, verrs := MTOServiceItemModel(basicServieItem)

suite.NoVerrs(verrs)
suite.Equal(moveTaskOrderIDField.String(), returnedModel.MoveTaskOrderID.String())
suite.Equal(mtoShipmentIDField.String(), returnedModel.MTOShipmentID.String())
suite.Equal(models.ReServiceCode("FSC"), returnedModel.ReService.Code)
})

suite.T().Run("Success - Returns a DCRT service item model", func(t *testing.T) {
returnedModel, verrs := MTOServiceItemModel(DCRTServiceItem)

var returnedItem, returnedCrate models.MTOServiceItemDimension
for _, dimension := range returnedModel.Dimensions {
if dimension.Type == models.DimensionTypeItem {
returnedItem = dimension
} else {
returnedCrate = dimension
}
}

suite.NoVerrs(verrs)
suite.Equal(moveTaskOrderIDField.String(), returnedModel.MoveTaskOrderID.String())
suite.Equal(mtoShipmentIDField.String(), returnedModel.MTOShipmentID.String())
suite.Equal(models.ReServiceCode("DCRT"), returnedModel.ReService.Code)
suite.Equal(DCRTServiceItem.Reason, returnedModel.Reason)
suite.Equal(DCRTServiceItem.Description, returnedModel.Description)
suite.Equal(unit.ThousandthInches(*DCRTServiceItem.Item.Length), returnedItem.Length)
suite.Equal(unit.ThousandthInches(*DCRTServiceItem.Crate.Length), returnedCrate.Length)
})

suite.T().Run("Fail - Returns error for DCRT service item because of validation error", func(t *testing.T) {
badCrateMeasurement := int32(200)
badCrate := &primemessages.MTOServiceItemDimension{
Height: &badCrateMeasurement,
Width: &badCrateMeasurement,
Length: &badCrateMeasurement,
}

badDCRTServiceItem := &primemessages.MTOServiceItemDomesticCrating{
ReServiceCode: &dcrtCode,
Reason: &reason,
Description: &description,
Item: item,
Crate: badCrate,
}

badDCRTServiceItem.SetMoveTaskOrderID(handlers.FmtUUID(moveTaskOrderIDField))
badDCRTServiceItem.SetMtoShipmentID(*mtoShipmentIDString)

returnedModel, verrs := MTOServiceItemModel(badDCRTServiceItem)

suite.True(verrs.HasAny(), "invalid crate dimensions for DCRT service item")
suite.Nil(returnedModel, "returned a model when erroring")

})
}
34 changes: 34 additions & 0 deletions pkg/handlers/primeapi/payloads/payloads_test.go
@@ -0,0 +1,34 @@
package payloads

import (
"log"
"testing"

"github.com/transcom/mymove/pkg/testingsuite"

"github.com/stretchr/testify/suite"
"go.uber.org/zap"

"github.com/transcom/mymove/pkg/handlers"
"github.com/transcom/mymove/pkg/notifications"
)

// HandlerSuite is an abstraction of our original suite
type PayloadsSuite struct {
handlers.BaseHandlerTestSuite
}

// TestHandlerSuite creates our test suite
func TestHandlerSuite(t *testing.T) {
logger, err := zap.NewDevelopment()
if err != nil {
log.Panic(err)
}

hs := &PayloadsSuite{
BaseHandlerTestSuite: handlers.NewBaseHandlerTestSuite(logger, notifications.NewStubNotificationSender("milmovelocal", logger), testingsuite.CurrentPackage()),
}

suite.Run(t, hs)
hs.PopTestSuite.TearDown()
}

0 comments on commit 8a310fa

Please sign in to comment.