• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

supabase / cli / 19625601168

24 Nov 2025 06:38AM UTC coverage: 55.069% (-0.04%) from 55.108%
19625601168

Pull #4477

github

web-flow
Merge c380f11c5 into 4a90b4fce
Pull Request #4477: feat: add `--name-id-format` flag to `sso add` and `sso update`

10 of 21 new or added lines in 4 files covered. (47.62%)

5 existing lines in 1 file now uncovered.

6540 of 11876 relevant lines covered (55.07%)

6.26 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

77.86
/internal/sso/internal/render/render.go
1
package render
2

3
import (
4
        "encoding/json"
5
        "fmt"
6
        "strings"
7

8
        "github.com/go-errors/errors"
9
        "github.com/go-xmlfmt/xmlfmt"
10
        "github.com/supabase/cli/internal/utils"
11
        "github.com/supabase/cli/pkg/api"
12
)
13

14
func formatProtocol(provider api.GetProviderResponse) string {
5✔
15
        protocol := "SAML 2.0"
5✔
16
        if provider.Saml == nil {
5✔
17
                protocol = "unknown"
×
18
        }
×
19

20
        return protocol
5✔
21
}
22

23
func formatMetadataSource(provider api.GetProviderResponse) string {
4✔
24
        source := "FILE"
4✔
25
        if provider.Saml != nil && provider.Saml.MetadataUrl != nil && *provider.Saml.MetadataUrl != "" {
8✔
26
                source = *provider.Saml.MetadataUrl
4✔
27
        }
4✔
28

29
        return source
4✔
30
}
31

32
func formatTimestamp(timestamp *string) string {
10✔
33
        if timestamp == nil {
10✔
34
                return ""
×
35
        }
×
36

37
        return utils.FormatTimestamp(*timestamp)
10✔
38
}
39

40
func formatDomains(provider api.GetProviderResponse) string {
5✔
41
        var domains []string
5✔
42

5✔
43
        if provider.Domains != nil {
10✔
44
                for _, domain := range *provider.Domains {
10✔
45
                        if domain.Domain != nil {
10✔
46
                                domains = append(domains, *domain.Domain)
5✔
47
                        }
5✔
48
                }
49
        }
50

51
        domainsString := "-"
5✔
52
        if len(domains) > 0 {
10✔
53
                domainsString = strings.Join(domains, ", ")
5✔
54
        }
5✔
55

56
        return domainsString
5✔
57
}
58

59
func formatEntityID(provider api.GetProviderResponse) string {
5✔
60
        entityID := "-"
5✔
61
        if provider.Saml != nil && provider.Saml.EntityId != "" {
10✔
62
                entityID = provider.Saml.EntityId
5✔
63
        }
5✔
64

65
        return entityID
5✔
66
}
67

68
func formatNameIDFormat(provider api.GetProviderResponse) string {
4✔
69
        nameIDFormat := "-"
4✔
70
        if provider.Saml != nil && provider.Saml.NameIdFormat != nil && *provider.Saml.NameIdFormat != "" {
4✔
NEW
71
                nameIDFormat = *provider.Saml.NameIdFormat
×
NEW
72
        }
×
73

74
        return nameIDFormat
4✔
75
}
76

77
func ListMarkdown(providers api.ListProvidersResponse) error {
1✔
78
        markdownTable := []string{
1✔
79
                "|TYPE|IDENTITY PROVIDER ID|DOMAINS|SAML 2.0 `EntityID`|CREATED AT (UTC)|UPDATED AT (UTC)|\n|-|-|-|-|-|-|\n",
1✔
80
        }
1✔
81

1✔
82
        for _, item := range providers.Items {
2✔
83
                markdownTable = append(markdownTable, fmt.Sprintf(
1✔
84
                        "|`%s`|`%s`|`%s`|`%s`|`%s`|`%s`|\n",
1✔
85
                        formatProtocol(item),
1✔
86
                        item.Id,
1✔
87
                        formatDomains(item),
1✔
88
                        formatEntityID(item),
1✔
89
                        formatTimestamp(item.CreatedAt),
1✔
90
                        formatTimestamp(item.UpdatedAt),
1✔
91
                ))
1✔
92
        }
1✔
93

94
        return utils.RenderTable(strings.Join(markdownTable, ""))
1✔
95
}
96

97
func SingleMarkdown(provider api.GetProviderResponse) error {
4✔
98
        markdownTable := []string{
4✔
99
                "|PROPERTY|VALUE|",
4✔
100
                "|-|-|",
4✔
101
        }
4✔
102

4✔
103
        markdownTable = append(markdownTable, fmt.Sprintf(
4✔
104
                "|IDENTITY PROVIDER ID|`%s`|",
4✔
105
                provider.Id,
4✔
106
        ))
4✔
107

4✔
108
        markdownTable = append(markdownTable, fmt.Sprintf(
4✔
109
                "|TYPE|`%s`|",
4✔
110
                formatProtocol(provider),
4✔
111
        ))
4✔
112

4✔
113
        markdownTable = append(markdownTable, fmt.Sprintf(
4✔
114
                "|DOMAINS|`%s`|",
4✔
115
                formatDomains(provider),
4✔
116
        ))
4✔
117

4✔
118
        if provider.Saml != nil {
8✔
119
                markdownTable = append(markdownTable, fmt.Sprintf(
4✔
120
                        "|SAML 2.0 METADATA|`%s`|",
4✔
121
                        formatMetadataSource(provider),
4✔
122
                ))
4✔
123

4✔
124
                markdownTable = append(markdownTable, fmt.Sprintf(
4✔
125
                        "|SAML 2.0 `EntityID`|`%s`|",
4✔
126
                        formatEntityID(provider),
4✔
127
                ))
4✔
128

4✔
129
                markdownTable = append(markdownTable, fmt.Sprintf(
4✔
130
                        "|NAMEID FORMAT|`%s`|",
4✔
131
                        formatNameIDFormat(provider),
4✔
132
                ))
4✔
133
        }
4✔
134

135
        markdownTable = append(markdownTable, fmt.Sprintf(
4✔
136
                "|CREATED AT (UTC)|`%s`|",
4✔
137
                formatTimestamp(provider.CreatedAt),
4✔
138
        ))
4✔
139

4✔
140
        markdownTable = append(markdownTable, fmt.Sprintf(
4✔
141
                "|UPDATED AT (UTC)|`%s`|",
4✔
142
                formatTimestamp(provider.CreatedAt),
4✔
143
        ))
4✔
144

4✔
145
        if provider.Saml != nil && provider.Saml.AttributeMapping != nil && len(provider.Saml.AttributeMapping.Keys) > 0 {
8✔
146
                attributeMapping, err := json.MarshalIndent(provider.Saml.AttributeMapping, "", "  ")
4✔
147
                if err != nil {
4✔
148
                        return errors.Errorf("failed to marshal attribute mapping: %w", err)
×
149
                }
×
150

151
                markdownTable = append(markdownTable, "", "## Attribute Mapping", "```json", string(attributeMapping), "```")
4✔
152
        }
153

154
        if provider.Saml != nil && provider.Saml.MetadataXml != nil && *provider.Saml.MetadataXml != "" {
8✔
155
                prettyXML := xmlfmt.FormatXML(*provider.Saml.MetadataXml, "  ", "  ")
4✔
156
                markdownTable = append(markdownTable, "", "## SAML 2.0 Metadata XML", "```xml", prettyXML, "```")
4✔
157
        }
4✔
158

159
        return utils.RenderTable(strings.Join(markdownTable, "\n"))
4✔
160
}
161

162
func InfoMarkdown(ref string) error {
×
163
        markdownTable := []string{
×
164
                "|PROPERTY|VALUE|",
×
165
                "|-|-|",
×
166
        }
×
167

×
168
        markdownTable = append(markdownTable, fmt.Sprintf(
×
169
                "|Single sign-on URL (ACS URL) |`%s`|",
×
170
                fmt.Sprintf("https://%s.supabase.co/auth/v1/sso/saml/acs", ref),
×
171
        ))
×
172

×
173
        markdownTable = append(markdownTable, fmt.Sprintf(
×
174
                "|Audience URI (SP Entity ID)|`%s`|",
×
175
                fmt.Sprintf("https://%s.supabase.co/auth/v1/sso/saml/metadata", ref),
×
176
        ))
×
177

×
178
        markdownTable = append(markdownTable, fmt.Sprintf(
×
179
                "|Default Relay State|`%s`|",
×
180
                fmt.Sprintf("https://%s.supabase.co", ref),
×
181
        ))
×
182

×
183
        return utils.RenderTable(strings.Join(markdownTable, "\n"))
×
184
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc