@@ -5,6 +5,7 @@ package sign
55
66import (
77 "context"
8+ "errors"
89 "sync"
910 "testing"
1011 "time"
@@ -82,6 +83,42 @@ func newTestSSSClient(t *testing.T) *sss.Client {
8283 return client
8384}
8485
86+ // checkCompanyCompliance routes an unexpected (non-clean/non-flagged) SSS status through
87+ // complianceUnavailable; these cover its decision so an ambiguous status never auto-clears
88+ // or caches a sanction.
89+ func TestComplianceUnavailableRequiredBlocks (t * testing.T ) {
90+ svc := & service {sssRequired : true }
91+ blocked , err := svc .complianceUnavailable (logrus.Fields {}, & models.Company {CompanyID : "company-id" }, errors .New (`unexpected SSS status "weird"` ))
92+ if err == nil {
93+ t .Fatal ("expected required mode to block (error) on an ambiguous result" )
94+ }
95+ if blocked {
96+ t .Fatal ("expected blocked=false alongside the error in required mode" )
97+ }
98+ }
99+
100+ func TestComplianceUnavailableOptionalAllowsUnsanctioned (t * testing.T ) {
101+ svc := & service {sssRequired : false }
102+ blocked , err := svc .complianceUnavailable (logrus.Fields {}, & models.Company {CompanyID : "company-id" , IsSanctioned : false }, errors .New (`unexpected SSS status "weird"` ))
103+ if err != nil {
104+ t .Fatalf ("optional mode should not error on an ambiguous result, got %v" , err )
105+ }
106+ if blocked {
107+ t .Fatal ("optional mode with no persisted sanction should allow" )
108+ }
109+ }
110+
111+ func TestComplianceUnavailableOptionalHonorsPersistedSanction (t * testing.T ) {
112+ svc := & service {sssRequired : false }
113+ blocked , err := svc .complianceUnavailable (logrus.Fields {}, & models.Company {CompanyID : "company-id" , IsSanctioned : true , SanctionOrigin : "sss" }, errors .New (`unexpected SSS status "weird"` ))
114+ if err != nil {
115+ t .Fatalf ("optional mode should not error on an ambiguous result, got %v" , err )
116+ }
117+ if ! blocked {
118+ t .Fatal ("optional mode must keep blocking a persisted sanction (no auto-clear) on an ambiguous result" )
119+ }
120+ }
121+
85122func TestCheckCompanyComplianceRequiredBlocksMissingExternalID (t * testing.T ) {
86123 svc := & service {sssRequired : true , sssClient : newTestSSSClient (t )}
87124
0 commit comments