Skip to content

Commit

Permalink
Fix ready to submit logic (#1048)
Browse files Browse the repository at this point in the history
  • Loading branch information
pdeziel authored Jun 1, 2023
1 parent d70b427 commit d8e0f6e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 54 deletions.
2 changes: 1 addition & 1 deletion pkg/bff/models/v1/organization.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func NewRegisterForm() *RegistrationForm {
// response to ensure that we're able to submit valid forms and that validation only
// occurs in one place in the code.
func (r *RegistrationForm) ReadyToSubmit(network string) bool {
if r.VaspCategories == nil || r.Entity == nil || r.Contacts == nil || r.Trixo == nil {
if r.Entity == nil || r.Contacts == nil || r.Trixo == nil {
return false
}

Expand Down
85 changes: 32 additions & 53 deletions pkg/bff/models/v1/organization_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,119 +129,98 @@ func TestReadyToSubmit(t *testing.T) {
},
{
r: &models.RegistrationForm{
Entity: &ivms101.LegalPerson{CountryOfRegistration: "GY"},
Contacts: &gds.Contacts{Technical: &gds.Contact{Email: "[email protected]"}},
Trixo: &gds.TRIXOQuestionnaire{PrimaryNationalJurisdiction: "GY"},
Testnet: &models.NetworkDetails{CommonName: "test.trisa.example.com"},
Mainnet: &models.NetworkDetails{CommonName: "trisa.example.com"},
},
assert: require.False,
networks: []string{"testnet", "mainnet", "all", "both", ""},
message: "registration form without vasp categories should not be ready to submit",
},
{
r: &models.RegistrationForm{
VaspCategories: []string{"P2P", "other"},
Contacts: &gds.Contacts{Technical: &gds.Contact{Email: "[email protected]"}},
Trixo: &gds.TRIXOQuestionnaire{PrimaryNationalJurisdiction: "GY"},
Testnet: &models.NetworkDetails{CommonName: "test.trisa.example.com"},
Mainnet: &models.NetworkDetails{CommonName: "trisa.example.com"},
},
assert: require.False,
networks: []string{"testnet", "mainnet", "all", "both", ""},
message: "registration form without entity should not be ready to submit",
},
{
r: &models.RegistrationForm{
VaspCategories: []string{"P2P", "other"},
Entity: &ivms101.LegalPerson{CountryOfRegistration: "GY"},
Trixo: &gds.TRIXOQuestionnaire{PrimaryNationalJurisdiction: "GY"},
Testnet: &models.NetworkDetails{CommonName: "test.trisa.example.com"},
Mainnet: &models.NetworkDetails{CommonName: "trisa.example.com"},
Entity: &ivms101.LegalPerson{CountryOfRegistration: "GY"},
Trixo: &gds.TRIXOQuestionnaire{PrimaryNationalJurisdiction: "GY"},
Testnet: &models.NetworkDetails{CommonName: "test.trisa.example.com"},
Mainnet: &models.NetworkDetails{CommonName: "trisa.example.com"},
},
assert: require.False,
networks: []string{"testnet", "mainnet", "all", "both", ""},
message: "registration form without contacts should not be ready to submit",
},
{
r: &models.RegistrationForm{
VaspCategories: []string{"P2P", "other"},
Entity: &ivms101.LegalPerson{CountryOfRegistration: "GY"},
Contacts: &gds.Contacts{Technical: &gds.Contact{Email: "[email protected]"}},
Testnet: &models.NetworkDetails{CommonName: "test.trisa.example.com"},
Mainnet: &models.NetworkDetails{CommonName: "trisa.example.com"},
Entity: &ivms101.LegalPerson{CountryOfRegistration: "GY"},
Contacts: &gds.Contacts{Technical: &gds.Contact{Email: "[email protected]"}},
Testnet: &models.NetworkDetails{CommonName: "test.trisa.example.com"},
Mainnet: &models.NetworkDetails{CommonName: "trisa.example.com"},
},
assert: require.False,
networks: []string{"testnet", "mainnet", "all", "both", ""},
message: "registration form without trixo should not be ready to submit",
},
{
r: &models.RegistrationForm{
VaspCategories: []string{"P2P", "other"},
Entity: &ivms101.LegalPerson{CountryOfRegistration: "GY"},
Contacts: &gds.Contacts{Technical: &gds.Contact{Email: "[email protected]"}},
Trixo: &gds.TRIXOQuestionnaire{PrimaryNationalJurisdiction: "GY"},
Entity: &ivms101.LegalPerson{CountryOfRegistration: "GY"},
Contacts: &gds.Contacts{Technical: &gds.Contact{Email: "[email protected]"}},
Trixo: &gds.TRIXOQuestionnaire{PrimaryNationalJurisdiction: "GY"},
},
assert: require.False,
networks: []string{"testnet", "mainnet", "all", "both", ""},
message: "registration form without network details should not be ready to submit",
},
{
r: &models.RegistrationForm{
VaspCategories: []string{"P2P", "other"},
Entity: &ivms101.LegalPerson{CountryOfRegistration: "GY"},
Contacts: &gds.Contacts{Technical: &gds.Contact{Email: "[email protected]"}},
Trixo: &gds.TRIXOQuestionnaire{PrimaryNationalJurisdiction: "GY"},
Testnet: &models.NetworkDetails{CommonName: "test.trisa.example.com"},
Entity: &ivms101.LegalPerson{CountryOfRegistration: "GY"},
Contacts: &gds.Contacts{Technical: &gds.Contact{Email: "[email protected]"}},
Trixo: &gds.TRIXOQuestionnaire{PrimaryNationalJurisdiction: "GY"},
Testnet: &models.NetworkDetails{CommonName: "test.trisa.example.com"},
},
assert: require.False,
networks: []string{"mainnet", "all", "both", ""},
message: "registration form with testnet network details should not be ready to submit",
},
{
r: &models.RegistrationForm{
VaspCategories: []string{"P2P", "other"},
Entity: &ivms101.LegalPerson{CountryOfRegistration: "GY"},
Contacts: &gds.Contacts{Technical: &gds.Contact{Email: "[email protected]"}},
Trixo: &gds.TRIXOQuestionnaire{PrimaryNationalJurisdiction: "GY"},
Testnet: &models.NetworkDetails{CommonName: "test.trisa.example.com"},
Entity: &ivms101.LegalPerson{CountryOfRegistration: "GY"},
Contacts: &gds.Contacts{Technical: &gds.Contact{Email: "[email protected]"}},
Trixo: &gds.TRIXOQuestionnaire{PrimaryNationalJurisdiction: "GY"},
Testnet: &models.NetworkDetails{CommonName: "test.trisa.example.com"},
},
assert: require.True,
networks: []string{"testnet"},
message: "registration form with testnet network details should be ready to submit",
},
{
r: &models.RegistrationForm{
VaspCategories: []string{"P2P", "other"},
Entity: &ivms101.LegalPerson{CountryOfRegistration: "GY"},
Contacts: &gds.Contacts{Technical: &gds.Contact{Email: "[email protected]"}},
Trixo: &gds.TRIXOQuestionnaire{PrimaryNationalJurisdiction: "GY"},
Mainnet: &models.NetworkDetails{CommonName: "trisa.example.com"},
Entity: &ivms101.LegalPerson{CountryOfRegistration: "GY"},
Contacts: &gds.Contacts{Technical: &gds.Contact{Email: "[email protected]"}},
Trixo: &gds.TRIXOQuestionnaire{PrimaryNationalJurisdiction: "GY"},
Mainnet: &models.NetworkDetails{CommonName: "trisa.example.com"},
},
assert: require.False,
networks: []string{"testnet", "all", "both", ""},
message: "registration form with mainnet network details should not be ready to submit",
},
{
r: &models.RegistrationForm{
VaspCategories: []string{"P2P", "other"},
Entity: &ivms101.LegalPerson{CountryOfRegistration: "GY"},
Contacts: &gds.Contacts{Technical: &gds.Contact{Email: "[email protected]"}},
Trixo: &gds.TRIXOQuestionnaire{PrimaryNationalJurisdiction: "GY"},
Mainnet: &models.NetworkDetails{CommonName: "trisa.example.com"},
Entity: &ivms101.LegalPerson{CountryOfRegistration: "GY"},
Contacts: &gds.Contacts{Technical: &gds.Contact{Email: "[email protected]"}},
Trixo: &gds.TRIXOQuestionnaire{PrimaryNationalJurisdiction: "GY"},
Mainnet: &models.NetworkDetails{CommonName: "trisa.example.com"},
},
assert: require.True,
networks: []string{"mainnet"},
message: "registration form with mainnet network details should be ready to submit",
},
{
r: &models.RegistrationForm{
VaspCategories: []string{"P2P", "other"},
Entity: &ivms101.LegalPerson{CountryOfRegistration: "GY"},
Contacts: &gds.Contacts{Technical: &gds.Contact{Email: "[email protected]"}},
Trixo: &gds.TRIXOQuestionnaire{PrimaryNationalJurisdiction: "GY"},
Testnet: &models.NetworkDetails{CommonName: "test.trisa.example.com"},
Mainnet: &models.NetworkDetails{CommonName: "trisa.example.com"},
Entity: &ivms101.LegalPerson{CountryOfRegistration: "GY"},
Contacts: &gds.Contacts{Technical: &gds.Contact{Email: "[email protected]"}},
Trixo: &gds.TRIXOQuestionnaire{PrimaryNationalJurisdiction: "GY"},
Testnet: &models.NetworkDetails{CommonName: "test.trisa.example.com"},
Mainnet: &models.NetworkDetails{CommonName: "trisa.example.com"},
},
assert: require.True,
networks: []string{"testnet", "mainnet", "all", "both", ""},
Expand Down

0 comments on commit d8e0f6e

Please sign in to comment.