Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatible with mock server #261

Merged
merged 1 commit into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion redfish/provider/data_source_redfish_bios_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func testAccRedfishDataSourceBiosConfig(testingInfo TestingServerCredentials) st
redfish_server {
user = "%s"
password = "%s"
endpoint = "https://%s"
endpoint = "%s"
ssl_insecure = true
}
system_id = "System.Embedded.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func testAccRedfishDataSourceiDRACConfig(testingInfo TestingServerCredentials) s
redfish_server {
user = "%s"
password = "%s"
endpoint = "https://%s"
endpoint = "%s"
ssl_insecure = true
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func testAccRedfishDatasourceDirectoryServiceAuthProviderConfig(testingInfo Test
redfish_server {
user = "%s"
password = "%s"
endpoint = "https://%s"
endpoint = "%s"
ssl_insecure = true
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func testAccRedfishDataSourceFirmwareConfig(testingInfo TestingServerCredentials
redfish_server {
user = "%s"
password = "%s"
endpoint = "https://%s"
endpoint = "%s"
ssl_insecure = true
}
}
Expand Down
16 changes: 8 additions & 8 deletions redfish/provider/data_source_redfish_nic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func testAccRedfishDataSourceNICConfig(testingInfo TestingServerCredentials) str
redfish_server {
user = "%s"
password = "%s"
endpoint = "https://%s"
endpoint = "%s"
ssl_insecure = true
}
}`,
Expand All @@ -103,7 +103,7 @@ func testAccNICDatasourceWithSystemID(testingInfo TestingServerCredentials) stri
redfish_server {
user = "%s"
password = "%s"
endpoint = "https://%s"
endpoint = "%s"
ssl_insecure = true
}
nic_filter {
Expand All @@ -126,7 +126,7 @@ func testAccNICDatasourceWithInvalidSystemID(testingInfo TestingServerCredential
redfish_server {
user = "%s"
password = "%s"
endpoint = "https://%s"
endpoint = "%s"
ssl_insecure = true
}
nic_filter {
Expand All @@ -149,7 +149,7 @@ func testAccNICDatasourceWithAdapterID(testingInfo TestingServerCredentials) str
redfish_server {
user = "%s"
password = "%s"
endpoint = "https://%s"
endpoint = "%s"
ssl_insecure = true
}
nic_filter {
Expand Down Expand Up @@ -177,7 +177,7 @@ func testAccNICDatasourceWithInvalidAdapterID(testingInfo TestingServerCredentia
redfish_server {
user = "%s"
password = "%s"
endpoint = "https://%s"
endpoint = "%s"
ssl_insecure = true
}
nic_filter {
Expand Down Expand Up @@ -205,7 +205,7 @@ func testAccNICDatasourceWithConfiguredFilter(testingInfo TestingServerCredentia
redfish_server {
user = "%s"
password = "%s"
endpoint = "https://%s"
endpoint = "%s"
ssl_insecure = true
}

Expand Down Expand Up @@ -236,7 +236,7 @@ func testAccNICDatasourceWithInvalidPortID(testingInfo TestingServerCredentials)
redfish_server {
user = "%s"
password = "%s"
endpoint = "https://%s"
endpoint = "%s"
ssl_insecure = true
}

Expand Down Expand Up @@ -266,7 +266,7 @@ func testAccNICDatasourceWithTwoAdapterIDs(testingInfo TestingServerCredentials)
redfish_server {
user = "%s"
password = "%s"
endpoint = "https://%s"
endpoint = "%s"
ssl_insecure = true
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func testAccRedfishDataSourceStorageControllerConfig(testingInfo TestingServerCr
redfish_server {
user = "%s"
password = "%s"
endpoint = "https://%s"
endpoint = "%s"
ssl_insecure = true
}
}`,
Expand All @@ -116,7 +116,7 @@ func testAccStorageControllerDatasourceWithEmptySystemFilter(testingInfo Testing
redfish_server {
user = "%s"
password = "%s"
endpoint = "https://%s"
endpoint = "%s"
ssl_insecure = true
}
storage_controller_filter {
Expand All @@ -135,7 +135,7 @@ func testAccStorageControllerDatasourceWithSystemID(testingInfo TestingServerCre
redfish_server {
user = "%s"
password = "%s"
endpoint = "https://%s"
endpoint = "%s"
ssl_insecure = true
}
storage_controller_filter {
Expand All @@ -158,7 +158,7 @@ func testAccStorageControllerDatasourceWithStorageID(testingInfo TestingServerCr
redfish_server {
user = "%s"
password = "%s"
endpoint = "https://%s"
endpoint = "%s"
ssl_insecure = true
}
storage_controller_filter {
Expand Down Expand Up @@ -186,7 +186,7 @@ func testAccStorageControllerDatasourceWithControllerID(testingInfo TestingServe
redfish_server {
user = "%s"
password = "%s"
endpoint = "https://%s"
endpoint = "%s"
ssl_insecure = true
}
storage_controller_filter {
Expand Down Expand Up @@ -215,7 +215,7 @@ func testAccStorageControllerDatasourceWithMultipleStorageIDs(testingInfo Testin
redfish_server {
user = "%s"
password = "%s"
endpoint = "https://%s"
endpoint = "%s"
ssl_insecure = true
}
storage_controller_filter {
Expand Down Expand Up @@ -248,7 +248,7 @@ func testAccStorageControllerDatasourceWithInvalidSystemID(testingInfo TestingSe
redfish_server {
user = "%s"
password = "%s"
endpoint = "https://%s"
endpoint = "%s"
ssl_insecure = true
}
storage_controller_filter {
Expand Down Expand Up @@ -277,7 +277,7 @@ func testAccStorageControllerDatasourceWithInvalidStorageID(testingInfo TestingS
redfish_server {
user = "%s"
password = "%s"
endpoint = "https://%s"
endpoint = "%s"
ssl_insecure = true
}
storage_controller_filter {
Expand Down Expand Up @@ -306,7 +306,7 @@ func testAccStorageControllerDatasourceWithInvalidControllerID(testingInfo Testi
redfish_server {
user = "%s"
password = "%s"
endpoint = "https://%s"
endpoint = "%s"
ssl_insecure = true
}
storage_controller_filter {
Expand Down
8 changes: 4 additions & 4 deletions redfish/provider/data_source_redfish_storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func testAccRedfishDataSourceStorageConfig(testingInfo TestingServerCredentials)
redfish_server {
user = "%s"
password = "%s"
endpoint = "https://%s"
endpoint = "%s"
ssl_insecure = true
}
}
Expand All @@ -71,7 +71,7 @@ func testAccStorageDatasourceWithControllerID(testingInfo TestingServerCredentia
redfish_server {
user = "%s"
password = "%s"
endpoint = "https://%s"
endpoint = "%s"
ssl_insecure = true
}
controller_ids = ["AHCI.Embedded.2-1"]
Expand All @@ -89,7 +89,7 @@ func testAccStorageDatasourceWithControllerName(testingInfo TestingServerCredent
redfish_server {
user = "%s"
password = "%s"
endpoint = "https://%s"
endpoint = "%s"
ssl_insecure = true
}
controller_names = ["PERC H730P Mini"]
Expand All @@ -107,7 +107,7 @@ func testAccStorageDatasourceWithBothConfig(testingInfo TestingServerCredentials
redfish_server {
user = "%s"
password = "%s"
endpoint = "https://%s"
endpoint = "%s"
ssl_insecure = true
}
system_id = "System.Embedded.1"
Expand Down
4 changes: 2 additions & 2 deletions redfish/provider/data_source_redfish_system_boot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func testAccRedfishDatasourceSystemBootConfig(testingInfo TestingServerCredentia
redfish_server {
user = "%s"
password = "%s"
endpoint = "https://%s"
endpoint = "%s"
ssl_insecure = true
}
}
Expand All @@ -78,7 +78,7 @@ func testAccRedfishDatasourceSystemBootConfigBasic(testingInfo TestingServerCred
redfish_server {
user = "%s"
password = "%s"
endpoint = "https://%s"
endpoint = "%s"
ssl_insecure = true
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func testAccRedfishDatasourceVirtualMediaConfig(testingInfo TestingServerCredent
redfish_server {
user = "%s"
password = "%s"
endpoint = "https://%s"
endpoint = "%s"
ssl_insecure = true
}
}
Expand Down
18 changes: 16 additions & 2 deletions redfish/provider/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,16 @@ func init() {
PasswordNIC: os.Getenv("TF_TESTING_PASSWORD_NIC"),
Insecure: false,
}
if creds.Endpoint2 == "" {
os.Setenv("TF_TESTING_ENDPOINT2", creds.Endpoint)
creds.Endpoint2 = creds.Endpoint
}
if creds.EndpointNIC == "" {
os.Setenv("TF_TESTING_ENDPOINT_NIC", creds.Endpoint)
creds.EndpointNIC = creds.Endpoint
}
if creds.PasswordNIC == "" {
os.Setenv("TF_TESTING_PASSWORD_NIC", creds.Password)
creds.PasswordNIC = creds.Password
}
// virtual media environment variable
Expand All @@ -97,8 +103,16 @@ func testAccPreCheck(t *testing.T) {
t.Fatal("TF_TESTING_ENDPOINT must be set for acceptance tests")
}

if v := os.Getenv("TF_TESTING_ENDPOINT2"); v == "" {
t.Fatal("TF_TESTING_ENDPOINT2 must be set for acceptance tests")
if v := os.Getenv("TF_TESTING_ENDPOINT"); !strings.HasPrefix(v, "https://") && !strings.HasPrefix(v, "http://") {
t.Fatal("TF_TESTING_ENDPOINT must start with `https://` for acceptance tests or `http://` for unit tests")
}

if v := os.Getenv("TF_TESTING_ENDPOINT2"); !strings.HasPrefix(v, "https://") && !strings.HasPrefix(v, "http://") {
t.Fatal("TF_TESTING_ENDPOINT2 must start with `https://` for acceptance tests or `http://` for unit tests")
}

if v := os.Getenv("TF_TESTING_ENDPOINT_NIC"); !strings.HasPrefix(v, "https://") && !strings.HasPrefix(v, "http://") {
t.Fatal("TF_TESTING_ENDPOINT_NIC must start with `https://` for acceptance tests or `http://` for unit tests")
}
}

Expand Down
2 changes: 1 addition & 1 deletion redfish/provider/redfish_sweeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestMain(m *testing.M) {
}

func getSweeperClient(region string) (*gofish.Service, error) {
endpoint := "https://" + creds.Endpoint
endpoint := creds.Endpoint
clientConfig := gofish.ClientConfig{
Endpoint: endpoint,
Username: creds.Username,
Expand Down
2 changes: 1 addition & 1 deletion redfish/provider/resource_certificate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func testAccRedfishResourceCustomCertificate(testingInfo TestingServerCredential
redfish_server {
user = "%s"
password = "%s"
endpoint = "https://%s"
endpoint = "%s"
ssl_insecure = true
}

Expand Down
12 changes: 6 additions & 6 deletions redfish/provider/resource_redfish_bios_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func TestAccRedfishBios_Import(t *testing.T) {
creds),
ResourceName: "redfish_bios.bios",
ImportState: true,
ImportStateId: "{\"username\":\"" + creds.Username + "\",\"password\":\"" + creds.Password + "\",\"endpoint\":\"https://" + creds.Endpoint + "\",\"ssl_insecure\":true}",
ImportStateId: "{\"username\":\"" + creds.Username + "\",\"password\":\"" + creds.Password + "\",\"endpoint\":\"" + creds.Endpoint + "\",\"ssl_insecure\":true}",
ExpectError: nil,
},
},
Expand All @@ -105,7 +105,7 @@ func TestAccRedfishBios_ImportSystemID(t *testing.T) {
creds),
ResourceName: "redfish_bios.bios",
ImportState: true,
ImportStateId: "{\"username\":\"" + creds.Username + "\",\"password\":\"" + creds.Password + "\",\"endpoint\":\"https://" + creds.Endpoint + "\",\"ssl_insecure\":true,\"system_id\":\"System.Embedded.1\"}",
ImportStateId: "{\"username\":\"" + creds.Username + "\",\"password\":\"" + creds.Password + "\",\"endpoint\":\"" + creds.Endpoint + "\",\"ssl_insecure\":true,\"system_id\":\"System.Embedded.1\"}",
ExpectError: nil,
},
},
Expand All @@ -120,7 +120,7 @@ func testAccRedfishResourceBiosConfigOn(testingInfo TestingServerCredentials) st
redfish_server {
user = "%s"
password = "%s"
endpoint = "https://%s"
endpoint = "%s"
ssl_insecure = true
}

Expand All @@ -145,7 +145,7 @@ func testAccRedfishResourceBiosConfigOff(testingInfo TestingServerCredentials) s
redfish_server {
user = "%s"
password = "%s"
endpoint = "https://%s"
endpoint = "%s"
ssl_insecure = true
}

Expand All @@ -172,7 +172,7 @@ func testAccRedfishResourceBiosConfigInvalidSettingsApplyTime(testingInfo Testin
redfish_server {
user = "%s"
password = "%s"
endpoint = "https://%s"
endpoint = "%s"
ssl_insecure = true
}

Expand All @@ -195,7 +195,7 @@ func testAccRedfishResourceBiosConfigInvalidAttributes(testingInfo TestingServer
redfish_server {
user = "%s"
password = "%s"
endpoint = "https://%s"
endpoint = "%s"
ssl_insecure = true
}

Expand Down
2 changes: 1 addition & 1 deletion redfish/provider/resource_redfish_boot_order.go
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ func (r *BootOrderResource) updateBootOptions(service *gofish.Service, d *models
}
for _, ele := range serverBootOptions {
payload.BootOptionEnabled = ele.BootOptionEnabled.ValueBool()
finalURL := fmt.Sprintf(url + "/" + ele.BootOptionReference.ValueString())
finalURL := fmt.Sprintf("%s/%s", url, ele.BootOptionReference.ValueString())
resp, err = service.GetClient().Patch(finalURL, payload)
if err != nil {
diags.AddError("Unable to update boot option data", err.Error())
Expand Down
Loading
Loading