Skip to content

Commit

Permalink
feat: support custom text color in issuance wizard headers
Browse files Browse the repository at this point in the history
  • Loading branch information
sietseringers authored and ivard committed May 31, 2021
1 parent b33a351 commit a121820
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions descriptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ type (
Logo *string `json:"logo,omitempty"` // SHA256 of the logo contents (which is the filename on disk)
LogoPath *string `json:"logoPath,omitempty"` // Full path to the logo set automatically during scheme parsing
Color *string `json:"color,omitempty"`
TextColor *string `json:"textColor,omitempty"`
Issues *CredentialTypeIdentifier `json:"issues,omitempty"`
AllowOtherRequestors bool `json:"allowOtherRequestors"`

Expand Down Expand Up @@ -362,6 +363,9 @@ func (wizard *IssueWizard) Validate(conf *Configuration) error {
if wizard.Color != nil && !regexp.MustCompile("^#[0-9A-F]{6}$").MatchString(*wizard.Color) {
return errors.New("invalid wizard color: must be of the form #RRGGBB")
}
if wizard.TextColor != nil && !regexp.MustCompile("^#[0-9A-F]{6}$").MatchString(*wizard.TextColor) {
return errors.New("invalid wizard text color: must be of the form #RRGGBB")
}

// validate that no possible content graph is too complex
allRelevantPaths := wizard.Contents.buildValidationPaths(conf, map[CredentialTypeIdentifier]struct{}{})
Expand Down
12 changes: 12 additions & 0 deletions irmago_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1074,6 +1074,18 @@ func TestWizardValidation(t *testing.T) {
validColor := "#123ABC"
wizard.Color = &validColor
require.NoError(t, wizard.Validate(conf))

wizard.TextColor = &invalidColor1
require.EqualError(t, wizard.Validate(conf), "invalid wizard text color: must be of the form #RRGGBB")

wizard.TextColor = &invalidColor2
require.EqualError(t, wizard.Validate(conf), "invalid wizard text color: must be of the form #RRGGBB")

wizard.TextColor = nil
require.NoError(t, wizard.Validate(conf))

wizard.TextColor = &validColor
require.NoError(t, wizard.Validate(conf))
}

func TestWizardIncorrectContentsOrder(t *testing.T) {
Expand Down

0 comments on commit a121820

Please sign in to comment.