Add Scaleway, Yousign, Railway and Crisp access-review connectors
Four API-key, single-tenant (Pattern 3) connectors:
- Scaleway: secret key in the X-Auth-Token header plus an Organization ID
setting; GET /iam/v1alpha1/users (owner/member, status, two-factor),
per-connection BuildProbeURL.
- Yousign: Bearer API key; GET /v3/users (admin/owner/member, is_active);
production host with a static probe.
- Railway: Bearer account token; GraphQL me{workspaces{members}} aggregated
and deduplicated across workspaces; custom probe, since Railway returns
HTTP 200 with an errors body on a rejected token.
- Crisp: plugin token as HTTP Basic (identifier:key) plus a Website ID
setting and the X-Crisp-Tier header; GET /v1/website/{id}/operators/list,
custom probe and name resolver.
Scaleway and Crisp carry a required extra setting, so the console add-source
dialog maps organizationId/websiteId onto their scalewayOrganizationId and
crispWebsiteId API-key inputs; without that mapping the value is silently
dropped and the create is rejected.
Cassette-backed driver tests plus unit tests for the cross-workspace
deduplication, the probe contracts and the role/MFA helpers.
Signed-off-by: Aurélien Sibiril <81782+aureliensibiril@users.noreply.github.com>
This commit is contained in:
94
pkg/accessreview/drivers/scaleway_test.go
Normal file
94
pkg/accessreview/drivers/scaleway_test.go
Normal file
@@ -0,0 +1,94 @@
|
||||
// Copyright (c) 2026 Probo Inc <hello@probo.com>.
|
||||
//
|
||||
// Permission to use, copy, modify, and/or distribute this software for any
|
||||
// purpose with or without fee is hereby granted, provided that the above
|
||||
// copyright notice and this permission notice appear in all copies.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
// PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
package drivers
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.probo.inc/probo/pkg/coredata"
|
||||
)
|
||||
|
||||
func TestScalewayDriver(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
rec := newRecorder(t, "testdata/scaleway", "SCALEWAY_API_KEY")
|
||||
// Scaleway authenticates via the X-Auth-Token header, not Authorization.
|
||||
client := newVCRClientWithHeader(rec, "X-Auth-Token", os.Getenv("SCALEWAY_API_KEY"))
|
||||
|
||||
driver := NewScalewayDriver(client, "11111111-2222-3333-4444-555555555555")
|
||||
records, err := driver.ListAccounts(context.Background())
|
||||
require.NoError(t, err)
|
||||
require.Len(t, records, 2)
|
||||
|
||||
owner := records[0]
|
||||
assert.Equal(t, "8a3f1b2c-9d4e-4a5f-8b6c-1d2e3f4a5b6c", owner.ExternalID)
|
||||
assert.Equal(t, "alice.martin@example.com", owner.Email)
|
||||
assert.Equal(t, "Alice Martin", owner.FullName)
|
||||
assert.Equal(t, []string{"Owner"}, owner.Roles)
|
||||
assert.True(t, owner.IsAdmin)
|
||||
require.NotNil(t, owner.Active)
|
||||
assert.True(t, *owner.Active)
|
||||
assert.Equal(t, coredata.MFAStatusEnabled, owner.MFAStatus)
|
||||
assert.NotNil(t, owner.CreatedAt)
|
||||
assert.NotNil(t, owner.LastLogin)
|
||||
assert.Equal(t, coredata.AccessReviewEntryAccountTypeUser, owner.AccountType)
|
||||
|
||||
// Owner is the only admin; an invitation-pending member is inactive with no
|
||||
// last-login timestamp.
|
||||
member := records[1]
|
||||
assert.Equal(t, "c7e2a9d4-5f6b-4c3a-9e8d-2b1c0a9f8e7d", member.ExternalID)
|
||||
assert.Equal(t, "bob.dupont@example.com", member.Email)
|
||||
assert.Equal(t, []string{"Member"}, member.Roles)
|
||||
assert.False(t, member.IsAdmin)
|
||||
require.NotNil(t, member.Active)
|
||||
assert.False(t, *member.Active)
|
||||
assert.Equal(t, coredata.MFAStatusDisabled, member.MFAStatus)
|
||||
assert.Nil(t, member.LastLogin)
|
||||
}
|
||||
|
||||
func TestScalewayMFAStatus(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
enabled := true
|
||||
disabled := false
|
||||
|
||||
// The always-present mfa boolean is the fallback; the newer
|
||||
// two_factor_enabled pointer wins when set.
|
||||
assert.Equal(t, coredata.MFAStatusEnabled, scalewayMFAStatus(scalewayUser{MFA: true}))
|
||||
assert.Equal(t, coredata.MFAStatusDisabled, scalewayMFAStatus(scalewayUser{MFA: false}))
|
||||
assert.Equal(t, coredata.MFAStatusEnabled, scalewayMFAStatus(scalewayUser{MFA: false, TwoFactorEnabled: &enabled}))
|
||||
assert.Equal(t, coredata.MFAStatusDisabled, scalewayMFAStatus(scalewayUser{MFA: true, TwoFactorEnabled: &disabled}))
|
||||
}
|
||||
|
||||
func TestScalewayActive(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
mustBool := func(t *testing.T, want bool, got *bool) {
|
||||
t.Helper()
|
||||
require.NotNil(t, got)
|
||||
assert.Equal(t, want, *got)
|
||||
}
|
||||
|
||||
mustBool(t, true, scalewayActive("activated", false))
|
||||
mustBool(t, false, scalewayActive("invitation_pending", false))
|
||||
// A locked account is inactive even when its status is "activated".
|
||||
mustBool(t, false, scalewayActive("activated", true))
|
||||
assert.Nil(t, scalewayActive("", false))
|
||||
assert.Nil(t, scalewayActive("unknown_status", false))
|
||||
}
|
||||
Reference in New Issue
Block a user