Add Render access review driver support
Register Render as an API-key connector provider and add an access
review driver that fetches workspace members from the Render API
(GET /v1/owners/{ownerId}/members).
Render exposes no partner OAuth program, so the connector authenticates
with a read-scoped API key (Authorization: Bearer) plus the customer's
Workspace ID. The flat members endpoint reports an explicit account
status and MFA flag, surfaced as the Active and MFAStatus fields; the
stable "usr-" id becomes ExternalID. There is no picker -- the
workspace is captured up front via ExtraSettings -- so
SetOrganizationSettings is omitted.
Signed-off-by: Aurélien Sibiril <81782+aureliensibiril@users.noreply.github.com>
This commit is contained in:
@@ -255,6 +255,76 @@ func TestQoveryNameResolver(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestRenderNameResolver(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
t.Run("empty owner id returns nothing without HTTP call", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
client := &http.Client{Transport: roundTripperFunc(func(*http.Request) (*http.Response, error) {
|
||||
t.Fatalf("resolver should not make an HTTP call for an empty owner id")
|
||||
return nil, nil
|
||||
})}
|
||||
|
||||
got, err := NewRenderNameResolver(client, "").ResolveInstanceName(context.Background())
|
||||
require.NoError(t, err)
|
||||
assert.Empty(t, got)
|
||||
})
|
||||
|
||||
cases := []struct {
|
||||
name string
|
||||
status int
|
||||
body string
|
||||
want string
|
||||
}{
|
||||
{
|
||||
name: "200 returns name",
|
||||
status: http.StatusOK,
|
||||
body: `{"id":"tea-test","name":"Acme Workspace","email":"ops@example.com","type":"team"}`,
|
||||
want: "Acme Workspace",
|
||||
},
|
||||
{
|
||||
name: "401 is terminal (no error, no name)",
|
||||
status: http.StatusUnauthorized,
|
||||
body: `{"message":"unauthorized"}`,
|
||||
want: "",
|
||||
},
|
||||
{
|
||||
name: "404 is terminal (no error, no name)",
|
||||
status: http.StatusNotFound,
|
||||
body: `{"message":"not found"}`,
|
||||
want: "",
|
||||
},
|
||||
{
|
||||
name: "500 is terminal (no error, no name)",
|
||||
status: http.StatusInternalServerError,
|
||||
body: `{"message":"boom"}`,
|
||||
want: "",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
assert.Equal(t, http.MethodGet, r.Method)
|
||||
assert.Equal(t, "/v1/owners/tea-test", r.URL.Path)
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(tc.status)
|
||||
_, _ = w.Write([]byte(tc.body))
|
||||
}))
|
||||
defer srv.Close()
|
||||
|
||||
client := &http.Client{Transport: &hostRewriter{target: srv.URL}}
|
||||
|
||||
got, err := NewRenderNameResolver(client, "tea-test").ResolveInstanceName(context.Background())
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, tc.want, got)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestTailscaleNameResolver(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user