Fix UpCloud admin detection and add name resolver
account/list marks the contract's primary account "main" on the live API, not "mymain" as the published docs example shows, so matching the documented spelling reported every account as a non-admin, including the contract owner. Roles cannot stand in: a main account carries the same technical/billing values a sub-account can hold. Classify off "sub" instead, the one value the docs and the API agree on. The fixture copied the docs example, so the test passed on the same wrong assumption. Its bodies now mirror a live capture, anonymized: the main account carries no main_account or allow_gui, sub-accounts add them plus the access lists, and the primary account's type is "main". A table test pins both spellings. A review keys accounts on email plus external ID. Email came only from account/details, and any failure blanked it while still emitting the record, so a transient 5xx moved an account to a different key and surfaced it as one account removed and another added. Only the stable answers now degrade: UpCloud returns 403 ACCOUNT_FORBIDDEN, not 404, for an account outside the token's reach, and both keep the list-only fields. Anything else aborts the run. A blank username no longer discards every account already collected, matching the sibling drivers. Resolve the source name from GET /1.3/account so sources read "UpCloud <username>" rather than staying generic, and link the connector to its documentation page. Signed-off-by: Aurélien Sibiril <81782+aureliensibiril@users.noreply.github.com>
This commit is contained in:
@@ -31,24 +31,29 @@ import (
|
||||
|
||||
func upcloudRegistration() *Registration {
|
||||
return &Registration{
|
||||
Provider: coredata.ConnectorProviderUpCloud,
|
||||
DisplayName: "UpCloud",
|
||||
SupportsAPIKey: true,
|
||||
// UpCloud's newer API tokens (the "ucat_..." personal access tokens
|
||||
// created under People > API access) authenticate as a standard
|
||||
// Bearer token, so the default APIKeyConnection mode (Authorization:
|
||||
// Bearer <key>) applies; no Header/Scheme/BasicAuth override is
|
||||
// needed. There is no OAuth2 flow; account/list already returns the
|
||||
// main account plus every sub-account reachable with the token, so
|
||||
// there is nothing to pick or configure: no settings struct, no
|
||||
Provider: coredata.ConnectorProviderUpCloud,
|
||||
DisplayName: "UpCloud",
|
||||
DocumentationURL: accessReviewDocsURL("upcloud"),
|
||||
SupportsAPIKey: true,
|
||||
// UpCloud API tokens ("ucat_...", created under Account > API
|
||||
// tokens) authenticate as a standard Bearer token, so the default
|
||||
// APIKeyConnection mode applies; no Header/Scheme/BasicAuth
|
||||
// override is needed. There is no OAuth2 flow, and account/list
|
||||
// already returns the main account plus every sub-account the token
|
||||
// reaches, so there is nothing to pick: no settings struct, no
|
||||
// picker.
|
||||
//
|
||||
// ProbeURL lets the connection-status check confirm the token with
|
||||
// the same lightweight GET the driver uses; an invalid token returns
|
||||
// 401.
|
||||
// the same lightweight GET the driver uses; a bad token returns 401.
|
||||
// account/list is main-account-only, so it also rejects a
|
||||
// sub-account token, which authenticates but sees nothing.
|
||||
ProbeURL: "https://api.upcloud.com/1.3/account/list",
|
||||
NewDriver: func(_ context.Context, c *http.Client, _ *coredata.Connector, logger *log.Logger) (drivers.Driver, error) {
|
||||
return drivers.NewUpCloudDriver(c, logger), nil
|
||||
return drivers.NewUpCloudDriver(c, logger.Named("upcloud")), nil
|
||||
},
|
||||
// GET /1.3/account names the source after the token's own account.
|
||||
NewNameResolver: func(_ context.Context, c *http.Client, _ *coredata.Connector, _ *log.Logger) drivers.NameResolver {
|
||||
return drivers.NewUpCloudNameResolver(c)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user