At the moment our SDK does not handle HTTP 401 (Unauthorized) error when authenticating to VCD. As a result, the user may get the illusion that he authenticated correctly, but subsequent code would return errors that don't make sense (see example below). This bug also appears for all consumers of this SDK (including Terraform provider VCD). This has already confused quite a few users and we ought to fix it.
Before When specifying invalid credentials, the user may get totally odd errors, such as:
Error: could not find any extended Provider VDC with name ext-net-name: error retrieving query: API Error: 406: The request has invalid accept header: Invalid API version requested. Supported API versions are: [37.0.0-alpha, 36.3, 36.2, 36.1, 36.0, 35.2, 35.0, 34.0, 33.0 [D], 32.0 [D], 31.0 [D]] ([D] indicates deprecated versions)
│
│ with data.vcd_provider_vdc.nsxt-pvdc,
│ on Org-creation-Main.tf line 47, in data "vcd_provider_vdc" "nsxt-pvdc":
│ 47: data "vcd_provider_vdc" "nsxt-pvdc" {
│
╵
╷
│ Error: could not find external network V2 by name 'ext-net-name': could not find external network by name: error getting all pages for endpoint https://HOSTNAME/cloudapi/1.0.0/externalNetworks/: error in HTTP GET request: NOT_ACCEPTABLE - The request has invalid accept header: Invalid API version requested. Supported API versions are: [37.0.0-alpha, 36.3, 36.2, 36.1, 36.0, 35.2, 35.0, 34.0, 33.0 [D], 32.0 [D], 31.0 [D]] ([D] indicates deprecated versions)
│
│ with data.vcd_external_network_v2.nsxt-ext-net,
│ on Org-creation-Main.tf line 98, in data "vcd_external_network_v2" "nsxt-ext-net":
│ 98: data "vcd_external_network_v2" "nsxt-ext-net" {
After this fix - the user would immediately get such error and break further flow:
error authorizing: received response HTTP 401 (Unauthorized). Please check if your credentials are valid
Two new tests are added to validate this behavior:
At the moment our SDK does not handle HTTP 401 (Unauthorized) error when authenticating to VCD. As a result, the user may get the illusion that he authenticated correctly, but subsequent code would return errors that don't make sense (see example below). This bug also appears for all consumers of this SDK (including Terraform provider VCD). This has already confused quite a few users and we ought to fix it.
Before When specifying invalid credentials, the user may get totally odd errors, such as:
After this fix - the user would immediately get such error and break further flow:
Two new tests are added to validate this behavior:
TestVCDClient_AuthenticateInvalidPassword
TestVCDClient_AuthenticateInvalidToken