Skip to content

Commit

Permalink
fix: add saml application
Browse files Browse the repository at this point in the history
  • Loading branch information
stebenz committed Jan 29, 2024
1 parent f692bba commit 720e986
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@ import (
"github.com/zitadel/terraform-provider-zitadel/zitadel/helper/test_utils"
)

const metadataXML = "<?xml version=\"1.0\"?>\n<md:EntityDescriptor xmlns:md=\"urn:oasis:names:tc:SAML:2.0:metadata\"\n validUntil=\"2024-01-26T17:48:38Z\"\n cacheDuration=\"PT604800S\"\n entityID=\"http://example.com/saml/metadata\">\n <md:SPSSODescriptor AuthnRequestsSigned=\"false\" WantAssertionsSigned=\"false\" protocolSupportEnumeration=\"urn:oasis:names:tc:SAML:2.0:protocol\">\n <md:NameIDFormat>urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified</md:NameIDFormat>\n <md:AssertionConsumerService Binding=\"urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST\"\n Location=\"http://example.com/saml/cas\"\n index=\"1\" />\n \n </md:SPSSODescriptor>\n</md:EntityDescriptor>"

func Create(t *testing.T, frame *test_utils.OrgTestFrame, projectID, name string) (string, string) {
return test_utils.CreateDefaultDependency(t, "zitadel_application_saml", application_saml.AppIDVar, func() (string, error) {
app, err := frame.AddSAMLApp(frame, &management.AddSAMLAppRequest{
ProjectId: projectID,
Name: name,
Metadata: &management.AddSAMLAppRequest_MetadataXml{MetadataXml: []byte(metadataXML)},
Metadata: &management.AddSAMLAppRequest_MetadataXml{MetadataXml: metadata(name)},
})
return app.GetAppId(), err
})
}

func metadata(name string) []byte {
return []byte("<?xml version=\"1.0\"?>\n<md:EntityDescriptor xmlns:md=\"urn:oasis:names:tc:SAML:2.0:metadata\"\n validUntil=\"2024-01-26T17:48:38Z\"\n cacheDuration=\"PT604800S\"\n entityID=\"" + name + "\">\n <md:SPSSODescriptor AuthnRequestsSigned=\"false\" WantAssertionsSigned=\"false\" protocolSupportEnumeration=\"urn:oasis:names:tc:SAML:2.0:protocol\">\n <md:NameIDFormat>urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified</md:NameIDFormat>\n <md:AssertionConsumerService Binding=\"urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST\"\n Location=\"http://example.com/saml/cas\"\n index=\"1\" />\n \n </md:SPSSODescriptor>\n</md:EntityDescriptor>")
}

0 comments on commit 720e986

Please sign in to comment.