Commit 6ad21f06 authored by Sietse Ringers's avatar Sietse Ringers
Browse files

Rename AttributeDescription -> AttributeType


Co-authored-by: Tomas's avatarConfiks <confiks@scriptbase.org>
parent 658c3375
...@@ -55,15 +55,15 @@ type CredentialType struct { ...@@ -55,15 +55,15 @@ type CredentialType struct {
SchemeManagerID string `xml:"SchemeManager"` SchemeManagerID string `xml:"SchemeManager"`
IsSingleton bool `xml:"ShouldBeSingleton"` IsSingleton bool `xml:"ShouldBeSingleton"`
Description TranslatedString Description TranslatedString
Attributes []AttributeDescription `xml:"Attributes>Attribute"` Attributes []AttributeType `xml:"Attributes>Attribute"`
XMLVersion int `xml:"version,attr"` XMLVersion int `xml:"version,attr"`
XMLName xml.Name `xml:"IssueSpecification"` XMLName xml.Name `xml:"IssueSpecification"`
Valid bool `xml:"-"` Valid bool `xml:"-"`
} }
// AttributeDescription is a description of an attribute within a credential type. // AttributeType is a description of an attribute within a credential type.
type AttributeDescription struct { type AttributeType struct {
ID string `xml:"id,attr"` ID string `xml:"id,attr"`
Optional string `xml:"optional,attr" json:",omitempty"` Optional string `xml:"optional,attr" json:",omitempty"`
Index *int `xml:"index,attr" json:",omitempty"` Index *int `xml:"index,attr" json:",omitempty"`
...@@ -71,11 +71,11 @@ type AttributeDescription struct { ...@@ -71,11 +71,11 @@ type AttributeDescription struct {
Description TranslatedString Description TranslatedString
} }
func (ad AttributeDescription) GetAttributeTypeIdentifier(cred CredentialTypeIdentifier) AttributeTypeIdentifier { func (ad AttributeType) GetAttributeTypeIdentifier(cred CredentialTypeIdentifier) AttributeTypeIdentifier {
return NewAttributeTypeIdentifier(cred.String() + "." + ad.ID) return NewAttributeTypeIdentifier(cred.String() + "." + ad.ID)
} }
func (ad AttributeDescription) IsOptional() bool { func (ad AttributeType) IsOptional() bool {
return ad.Optional == "true" return ad.Optional == "true"
} }
...@@ -107,7 +107,7 @@ func (ct CredentialType) IndexOf(ai AttributeTypeIdentifier) (int, error) { ...@@ -107,7 +107,7 @@ func (ct CredentialType) IndexOf(ai AttributeTypeIdentifier) (int, error) {
return -1, errors.New("Attribute identifier not found") return -1, errors.New("Attribute identifier not found")
} }
func (ct CredentialType) AttributeDescription(ai AttributeTypeIdentifier) *AttributeDescription { func (ct CredentialType) AttributeType(ai AttributeTypeIdentifier) *AttributeType {
i, _ := ct.IndexOf(ai) i, _ := ct.IndexOf(ai)
if i == -1 { if i == -1 {
return nil return nil
......
...@@ -423,13 +423,13 @@ func TestIssueOptionalAttributeUpdateSchemeManager(t *testing.T) { ...@@ -423,13 +423,13 @@ func TestIssueOptionalAttributeUpdateSchemeManager(t *testing.T) {
schemeid := irma.NewSchemeManagerIdentifier("irma-demo") schemeid := irma.NewSchemeManagerIdentifier("irma-demo")
credid := irma.NewCredentialTypeIdentifier("irma-demo.RU.studentCard") credid := irma.NewCredentialTypeIdentifier("irma-demo.RU.studentCard")
attrid := irma.NewAttributeTypeIdentifier("irma-demo.RU.studentCard.level") attrid := irma.NewAttributeTypeIdentifier("irma-demo.RU.studentCard.level")
require.False(t, client.Configuration.CredentialTypes[credid].AttributeDescription(attrid).IsOptional()) require.False(t, client.Configuration.CredentialTypes[credid].AttributeType(attrid).IsOptional())
client.Configuration.SchemeManagers[schemeid].URL = "http://localhost:48681/irma_configuration_updated/irma-demo" client.Configuration.SchemeManagers[schemeid].URL = "http://localhost:48681/irma_configuration_updated/irma-demo"
issuanceRequest := getIssuanceRequest(true) issuanceRequest := getIssuanceRequest(true)
delete(issuanceRequest.Credentials[0].Attributes, "level") delete(issuanceRequest.Credentials[0].Attributes, "level")
client.Configuration.Download(issuanceRequest) client.Configuration.Download(issuanceRequest)
require.True(t, client.Configuration.CredentialTypes[credid].AttributeDescription(attrid).IsOptional()) require.True(t, client.Configuration.CredentialTypes[credid].AttributeType(attrid).IsOptional())
test.ClearTestStorage(t) test.ClearTestStorage(t)
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment