Skip to content

Commit

Permalink
BCDA-8162: Update cli commands to be more inclusive. (#973)
Browse files Browse the repository at this point in the history
## 🎫 Ticket

https://jira.cms.gov/browse/BCDA-8162

## 🛠 Changes

Updated cli references + models to blacklist, updated to denylist.

## ℹ️ Context

As part of making BCDA's code more inclusive, we are removing the terms
"blacklist" and "whitelist."

## 🧪 Validation

Smoke tests + unit tests passing. Note, there is going to be an
associated PR to the jenkins job for the denylist that references the
new cli command name.
  • Loading branch information
alex-dzeda committed Jul 11, 2024
1 parent 95f1d55 commit 25c1e26
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 56 deletions.
2 changes: 1 addition & 1 deletion bcda/auth/ssas.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func (s SSASPlugin) getAuthDataFromClaims(claims *CommonClaims) (AuthData, error
return ad, entityNotFoundError
}
ad.ACOID = aco.UUID.String()
ad.Blacklisted = aco.Blacklisted()
ad.Blacklisted = aco.Denylisted()

return ad, nil
}
Expand Down
16 changes: 8 additions & 8 deletions bcda/bcdacli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -625,9 +625,9 @@ func setUpApp() *cli.App {
},
},
{
Name: "blacklist-aco",
Name: "denylist-aco",
Category: constants.CliAuthToolsCategory,
Usage: "Blacklists an ACO by their CMS ID",
Usage: "Denylists an ACO by their CMS ID",
Flags: []cli.Flag{
cli.StringFlag{
Name: constants.CliCMSIDArg,
Expand All @@ -639,15 +639,15 @@ func setUpApp() *cli.App {
td := &models.Termination{
TerminationDate: time.Now(),
CutoffDate: time.Now(),
BlacklistType: models.Involuntary,
DenylistType: models.Involuntary,
}
return setBlacklistState(acoCMSID, td)
return setDenylistState(acoCMSID, td)
},
},
{
Name: "unblacklist-aco",
Name: "undenylist-aco",
Category: constants.CliAuthToolsCategory,
Usage: "Unblacklists an ACO by their CMS ID",
Usage: "Undenylists an ACO by their CMS ID",
Flags: []cli.Flag{
cli.StringFlag{
Name: constants.CliCMSIDArg,
Expand All @@ -656,7 +656,7 @@ func setUpApp() *cli.App {
},
},
Action: func(c *cli.Context) error {
return setBlacklistState(acoCMSID, nil)
return setDenylistState(acoCMSID, nil)
},
},
}
Expand Down Expand Up @@ -851,7 +851,7 @@ func cleanupJobData(jobID uint, rootDirs ...string) error {
return nil
}

func setBlacklistState(cmsID string, td *models.Termination) error {
func setDenylistState(cmsID string, td *models.Termination) error {
aco, err := r.GetACOByCMSID(context.Background(), cmsID)
if err != nil {
return err
Expand Down
36 changes: 18 additions & 18 deletions bcda/bcdacli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -872,39 +872,39 @@ func (s *CLITestSuite) TestImportSuppressionDirectory_Failed() {
assert.Contains(buf.String(), "Files skipped: 0")
}

func (s *CLITestSuite) TestBlacklistACO() {
blacklistedCMSID := testUtils.RandomHexID()[0:4]
notBlacklistedCMSID := testUtils.RandomHexID()[0:4]
func (s *CLITestSuite) TestDenylistACO() {
denylistedCMSID := testUtils.RandomHexID()[0:4]
notDenylistedCMSID := testUtils.RandomHexID()[0:4]
notFoundCMSID := testUtils.RandomHexID()[0:4]

blacklistedACO := models.ACO{UUID: uuid.NewUUID(), CMSID: &blacklistedCMSID,
denylistedACO := models.ACO{UUID: uuid.NewUUID(), CMSID: &denylistedCMSID,
TerminationDetails: &models.Termination{
TerminationDate: time.Date(2020, time.December, 31, 23, 59, 59, 0, time.Local),
CutoffDate: time.Date(2020, time.December, 31, 23, 59, 59, 0, time.Local),
BlacklistType: models.Involuntary,
DenylistType: models.Involuntary,
}}
notBlacklistedACO := models.ACO{UUID: uuid.NewUUID(), CMSID: &notBlacklistedCMSID,
notDenylistedACO := models.ACO{UUID: uuid.NewUUID(), CMSID: &notDenylistedCMSID,
TerminationDetails: nil}

defer func() {
postgrestest.DeleteACO(s.T(), s.db, blacklistedACO.UUID)
postgrestest.DeleteACO(s.T(), s.db, notBlacklistedACO.UUID)
postgrestest.DeleteACO(s.T(), s.db, denylistedACO.UUID)
postgrestest.DeleteACO(s.T(), s.db, notDenylistedACO.UUID)
}()

postgrestest.CreateACO(s.T(), s.db, blacklistedACO)
postgrestest.CreateACO(s.T(), s.db, notBlacklistedACO)
postgrestest.CreateACO(s.T(), s.db, denylistedACO)
postgrestest.CreateACO(s.T(), s.db, notDenylistedACO)

s.NoError(s.testApp.Run([]string{"bcda", "unblacklist-aco", constants.CMSIDArg, blacklistedCMSID}))
s.NoError(s.testApp.Run([]string{"bcda", "blacklist-aco", constants.CMSIDArg, notBlacklistedCMSID}))
s.NoError(s.testApp.Run([]string{"bcda", "undenylist-aco", constants.CMSIDArg, denylistedCMSID}))
s.NoError(s.testApp.Run([]string{"bcda", "denylist-aco", constants.CMSIDArg, notDenylistedCMSID}))

s.Error(s.testApp.Run([]string{"bcda", "unblacklist-aco", constants.CMSIDArg, notFoundCMSID}))
s.Error(s.testApp.Run([]string{"bcda", "blacklist-aco", constants.CMSIDArg, notFoundCMSID}))
s.Error(s.testApp.Run([]string{"bcda", "undenylist-aco", constants.CMSIDArg, notFoundCMSID}))
s.Error(s.testApp.Run([]string{"bcda", "denylist-aco", constants.CMSIDArg, notFoundCMSID}))

newlyUnblacklistedACO := postgrestest.GetACOByUUID(s.T(), s.db, blacklistedACO.UUID)
s.False(newlyUnblacklistedACO.Blacklisted())
newlyUndenylistedACO := postgrestest.GetACOByUUID(s.T(), s.db, denylistedACO.UUID)
s.False(newlyUndenylistedACO.Denylisted())

newlyBlacklistedACO := postgrestest.GetACOByUUID(s.T(), s.db, notBlacklistedACO.UUID)
s.True(newlyBlacklistedACO.Blacklisted())
newlyDenylistedACO := postgrestest.GetACOByUUID(s.T(), s.db, notDenylistedACO.UUID)
s.True(newlyDenylistedACO.Denylisted())
}

func getRandomPort(t *testing.T) int {
Expand Down
6 changes: 3 additions & 3 deletions bcda/models/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ type ACO struct {
TerminationDetails *Termination `json:"termination"`
}

// Blacklisted returns bool based on TerminationDetails.
func (aco *ACO) Blacklisted() bool {
// Denylisted returns bool based on TerminationDetails.
func (aco *ACO) Denylisted() bool {
if aco.TerminationDetails != nil {
if aco.TerminationDetails.BlacklistType == Involuntary || aco.TerminationDetails.BlacklistType == Voluntary {
if aco.TerminationDetails.DenylistType == Involuntary || aco.TerminationDetails.DenylistType == Voluntary {
return true
} else {
return false
Expand Down
34 changes: 17 additions & 17 deletions bcda/models/models_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,33 +30,33 @@ func (s *ModelsTestSuite) TestJobStatusMessage() {
assert.Equal(s.T(), string(JobStatusCompleted), j.StatusMessage(25))
}

func (s *ModelsTestSuite) TestACOBlacklist() {
blackListDate := time.Date(2020, time.December, 31, 23, 59, 59, 0, time.Local)
blackListValues := []Termination{
func (s *ModelsTestSuite) TestACODenylist() {
denyListDate := time.Date(2020, time.December, 31, 23, 59, 59, 0, time.Local)
denyListValues := []Termination{
{
TerminationDate: blackListDate,
CutoffDate: blackListDate,
BlacklistType: Involuntary,
TerminationDate: denyListDate,
CutoffDate: denyListDate,
DenylistType: Involuntary,
},
{
TerminationDate: blackListDate,
CutoffDate: blackListDate,
BlacklistType: Voluntary,
TerminationDate: denyListDate,
CutoffDate: denyListDate,
DenylistType: Voluntary,
},
{
TerminationDate: blackListDate,
CutoffDate: blackListDate,
BlacklistType: Limited,
TerminationDate: denyListDate,
CutoffDate: denyListDate,
DenylistType: Limited,
},
}
tests := []struct {
title string
td *Termination
expectedResult bool
}{
{"Details Involuntary", &blackListValues[0], true},
{"Details Voluntary", &blackListValues[1], true},
{"Details Limited", &blackListValues[2], false},
{"Details Involuntary", &denyListValues[0], true},
{"Details Voluntary", &denyListValues[1], true},
{"Details Limited", &denyListValues[2], false},
{"Details Missing", &Termination{}, true},
{"Null", nil, false},
}
Expand All @@ -67,10 +67,10 @@ func (s *ModelsTestSuite) TestACOBlacklist() {
aco := ACO{
UUID: uuid.NewUUID(),
CMSID: &cmsID,
Name: "Blacklisted ACO",
Name: "Denylisted ACO",
TerminationDetails: tt.td,
}
assert.Equal(s.T(), aco.Blacklisted(), tt.expectedResult)
assert.Equal(s.T(), aco.Denylisted(), tt.expectedResult)
})
}
}
2 changes: 1 addition & 1 deletion bcda/models/postgres/repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ func (r *RepositoryTestSuite) TestACOMethods() {
termination := &models.Termination{
TerminationDate: now,
CutoffDate: now.Add(time.Hour).Round(time.Millisecond),
BlacklistType: models.Voluntary,
DenylistType: models.Voluntary,
AttributionStrategy: models.AttributionHistorical,
OptOutStrategy: models.OptOutLatest,
ClaimsStrategy: models.ClaimsHistorical,
Expand Down
6 changes: 3 additions & 3 deletions bcda/models/termination.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import (
"time"
)

type Blacklist uint8
type Denylist uint8

const (
// Involuntary means the caller had access revoked immediately
Involuntary Blacklist = iota
Involuntary Denylist = iota
// Voluntary means the caller had limited access then had their access completely revoked
Voluntary
// Limited means the caller has limited access to the service
Expand Down Expand Up @@ -41,7 +41,7 @@ type Termination struct {
TerminationDate time.Time // When caller moved from full to limited access
CutoffDate time.Time // When caller moved to no access

BlacklistType Blacklist
DenylistType Denylist
AttributionStrategy Attribution
OptOutStrategy OptOut
ClaimsStrategy Claims
Expand Down
8 changes: 4 additions & 4 deletions bcda/web/router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ func createExpectedAuthData(cmsID string, aco models.ACO) auth.AuthData {
ACOID: cmsID,
CMSID: cmsID,
TokenID: uuid.NewRandom().String(),
Blacklisted: aco.Blacklisted(),
Blacklisted: aco.Denylisted(),
}
}

Expand Down Expand Up @@ -370,7 +370,7 @@ func (s *RouterTestSuite) TestBlacklistedACOReturn403WhenACOBlacklisted() {

TerminationDate: time.Date(2020, time.December, 31, 23, 59, 59, 0, time.Local),
CutoffDate: time.Date(2020, time.December, 31, 23, 59, 59, 0, time.Local),
BlacklistType: models.Involuntary,
DenylistType: models.Involuntary,
}

aco := createACO(cmsID, blackListValue)
Expand All @@ -391,7 +391,7 @@ func (s *RouterTestSuite) TestBlacklistedACOReturn403WhenACOBlacklisted() {
for _, path := range config.paths {

s.T().Run(fmt.Sprintf("blacklist-value-%v-%s", blackListValue, path), func(t *testing.T) {
fmt.Println(aco.Blacklisted())
fmt.Println(aco.Denylisted())
fmt.Println(aco.UUID.String())
postgrestest.UpdateACO(t, db, aco)
rr := httptest.NewRecorder()
Expand Down Expand Up @@ -436,7 +436,7 @@ func (s *RouterTestSuite) TestBlacklistedACOReturnNOT403WhenACONOTBlacklisted()
for _, path := range config.paths {

s.T().Run(fmt.Sprintf("blacklist-value-%v-%s", nil, path), func(t *testing.T) {
fmt.Println(aco.Blacklisted())
fmt.Println(aco.Denylisted())
fmt.Println(aco.UUID.String())
postgrestest.UpdateACO(t, db, aco)
rr := httptest.NewRecorder()
Expand Down
2 changes: 1 addition & 1 deletion db/migrations/migrations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ func (s *MigrationTestSuite) TestBCDAMigration() {
TerminationDetails: &models.Termination{
TerminationDate: time.Date(2020, time.December, 31, 23, 59, 59, 0, time.Local),
CutoffDate: time.Date(2020, time.December, 31, 23, 59, 59, 0, time.Local),
BlacklistType: models.Involuntary,
DenylistType: models.Involuntary,
}}

defer postgrestest.DeleteACO(t, db, aco.UUID)
Expand Down

0 comments on commit 25c1e26

Please sign in to comment.