Skip to content

Commit

Permalink
Added more attributes and tests (#9, #14)
Browse files Browse the repository at this point in the history
  • Loading branch information
alxrem committed Apr 23, 2021
1 parent b30fedc commit 546c3e0
Show file tree
Hide file tree
Showing 34 changed files with 1,438 additions and 647 deletions.
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
## 0.10.0 (April 24, 2021)

ENHANCEMENTS:

* Added attributes `auth_token`, `default` and `verify_ssl` of `runscope_bucket`.
* Added attributes `stop_on_failure`, `parent_environment_id` and `client_certificate` of `runscope_environment`.
* Only changing of `bucket_id` and `test_id` forces new `runscope_environment`.
* Added attributes `skipped` and `form_parameter` of `runscope_step`.
* Require arguments `method` and `url` of `runscope_step`, and don't force new step when they are changed.
* Added attributes `created_at`, `created_by` and `trigger_url` of `runscope_test`.
* Changing of test arguments no more forces new test.
* Added attribute `exported_at` of `runscope_schedule`.
* Require argument `interval` of `runscope_schedule` is required and no more forces new schedule.
* Changing of `interval` and `note` no more forces new schedule.

BUG FIXES:

* Fixed issue with step updating (appeared in 0.9.1).

## 0.9.1 (April 10, 2021)

NOTES:
Expand Down
138 changes: 136 additions & 2 deletions contrib/runscope.http
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
### Create bucket
POST https://api.runscope.com/buckets?name=terraform-provider-staging&team_uuid={{ team_uuid }}
POST https://api.runscope.com/buckets?name=goland-bucket&team_uuid={{ team_uuid }}
Authorization: Bearer {{api_token}}

> {% client.global.set("bucket_id", response.body.data.key); %}

### Get bucket
GET https://api.runscope.com/buckets/{{bucket_id}}
Authorization: Bearer {{api_token}}

### List buckets
GET https://api.runscope.com/buckets
Authorization: Bearer {{api_token}}
Expand All @@ -13,10 +17,140 @@ POST https://api.runscope.com/buckets/{{bucket_id}}/tests
Authorization: Bearer {{api_token}}
Content-Type: application/json

{"name": "Sample Name","description": "My test description"}
{
"name": "goland-test"
}

> {% client.global.set("test_id", response.body.data.id); %}

### Get test
GET https://api.runscope.com/buckets/{{bucket_id}}/tests/{{test_id}}
Authorization: Bearer {{api_token}}

### Create test step
POST https://api.runscope.com/buckets/{{bucket_id}}/tests/{{test_id}}/steps
Authorization: Bearer {{api_token}}
Content-Type: application/json

{
"step_type": "request",
"method": "GET",
"url": "https://example.org"
}

> {% client.global.set("step_id", (response.body.data.length > 0) ? response.body.data[response.body.data.length-1].id : ""); %}

### Get test step
GET https://api.runscope.com/buckets/{{bucket_id}}/tests/{{test_id}}/steps/{{step_id}}
Authorization: Bearer {{api_token}}

### Update test step
PUT https://api.runscope.com/buckets/{{bucket_id}}/tests/{{test_id}}/steps/{{step_id}}
Authorization: Bearer {{api_token}}
Content-Type: application/json

{
"step_type": "request",
"method": "POST",
"url": "https://yourapihere.com/example/path",
"body": "a",
"form": {
"b": ["1"]
}
}

### Delete test step
DELETE https://api.runscope.com/buckets/{{bucket_id}}/tests/{{test_id}}/steps/{{step_id}}
Authorization: Bearer {{api_token}}

### Delete test
DELETE https://api.runscope.com/buckets/{{bucket_id}}/tests/{{test_id}}
Authorization: Bearer {{api_token}}

### Get test environment
GET https://api.runscope.com/buckets/{{bucket_id}}/tests/{{test_id}}/environments/{{environment_id}}
Authorization: Bearer {{api_token}}

### List shared environments
GET https://api.runscope.com/buckets/{{bucket_id}}/environments
Authorization: Bearer {{api_token}}

### Create shared environment
POST https://api.runscope.com/buckets/{{bucket_id}}/environments
Authorization: Bearer {{api_token}}
Content-Type: application/json

{
"name": "goland-shared-environment"
}

> {% client.global.set("environment_id", response.body.data.id); %}

### Create test environment
POST https://api.runscope.com/buckets/{{bucket_id}}/tests/{{test_id}}/environments
Authorization: Bearer {{api_token}}
Content-Type: application/json

{
"name": "goland-test-environment"
}

> {% client.global.set("environment_id", response.body.data.id); %}

### Update shared environment
PUT https://api.runscope.com/buckets/{{bucket_id}}/environments/{{environment_id}}
Authorization: Bearer {{api_token}}
Content-Type: application/json

{
"initial_variables": {
"a": "b"
}
}

### Update test environment
PUT https://api.runscope.com/buckets/{{bucket_id}}/tests/{{test_id}}/environments/{{environment_id}}
Authorization: Bearer {{api_token}}
Content-Type: application/json

{
"test_id": {{test1_id}}
}

### Get shared environment
GET https://api.runscope.com/buckets/{{bucket_id}}/environments/{{environment_id}}
Authorization: Bearer {{api_token}}

### Create test schedule
POST https://api.runscope.com/buckets/{{bucket_id}}/tests/{{test_id}}/schedules
Authorization: Bearer {{api_token}}
Content-Type: application/json

{
"environment_id": "{{environment_id}}",
"interval": "1d"
}

> {% client.global.set("schedule_id", response.body.data.id); %}

### Update test schedule
PUT https://api.runscope.com/buckets/{{bucket_id}}/tests/{{test_id}}/schedules/{{schedule_id}}
Authorization: Bearer {{api_token}}
Content-Type: application/json

{
"environment_id": "{{environment_id}}",
"interval": "1d"
}

### Delete schedule
DELETE https://api.runscope.com/buckets/{{bucket_id}}/tests/{{test_id}}/schedules/{{schedule_id}}
Authorization: Bearer {{api_token}}

### Delete shared environment
DELETE https://api.runscope.com/buckets/{{bucket_id}}/environments/{{environment_id}}
Authorization: Bearer {{api_token}}

### Delete test
DELETE https://api.runscope.com/buckets/{{bucket_id}}/tests/{{test_id}}
Authorization: Bearer {{api_token}}
Expand Down
4 changes: 4 additions & 0 deletions docs/data-sources/bucket.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,7 @@ The following attributes are exported:
* `id` - The unique key of the found bucket.
* `team_uuid` - The team unique identifier that owns the bucket.
* `name` - Type name of the bucket.
* `auth_token` - Bucket auth token if set.
* `default` - `true` if this bucket is the 'default' for a team.
* `verify_ssl` - `true` if this bucket is configured to verify ssl for requests made to it.
* `trigger_url` - URL to trigger a test run for all tests within a bucket.
4 changes: 4 additions & 0 deletions docs/resources/bucket.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ The following attributes are exported:
* `name` - The name of this bucket.
* `id` - The ID of this bucket.
* `team_uuid` - Unique identifier for the team this bucket belongs to.
* `auth_token` - Bucket auth token if set.
* `default` - `true` if this bucket is the 'default' for a team.
* `verify_ssl` - `true` if this bucket is configured to verify ssl for requests made to it.
* `trigger_url` - URL to trigger a test run for all tests within a bucket.

## Import

Expand Down
21 changes: 12 additions & 9 deletions docs/resources/environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

An [environment](https://www.runscope.com/docs/api/environments) resource.
An [environment](https://www.runscope.com/docs/api-testing/environments)
is is a group of configuration settings (initial variables, locations,
is a group of configuration settings (initial variables, locations,
notifications, integrations, etc.) used when running a test.
Every test has at least one environment, but you can create additional
environments as needed. For common settings (base URLs, API keys)
Expand Down Expand Up @@ -90,8 +90,13 @@ The following arguments are supported:
* `regions` - (Optional) A list of [Runscope regions](https://www.runscope.com/docs/regions) to execute test runs in when using this environment.
* `remote_agent` - (Optional) Block describing the properties of [Remote Agent](https://www.runscope.com/docs/api/agents) to execute test runs in when using this environment. May be declared multiple times.
Remote Agent documented below.
* `retry_on_failure` - (Optional) If this is set to true, an additional test run will be triggered immediately after a failed scheduled test run.
* `stop_on_failure` - (Optional) If this is set to true, test runs will stop executing after the first step that fails. All subsequent steps will be skipped.
* `verify_ssl` - (Optional) If this is set to false, tests using this environment won't verify SSL certificates.
* `webhooks` - (Optional) A list of URL's to send results to when test runs using this environment finish.
* `email` - (Optional) Block describing settings for sending email notifications upon completion of a test run using this environment. May be declared multiple times. Emails block is documented below
* `email` - (Optional) Block describing settings for sending email notifications upon completion of a test run using this environment. May be declared multiple times. Emails block is documented below.
* `parent_environment_id` - (Optional) The parent environment to inherit from, applies only to test-specific environments.
* `client_certificate` - (Optional) Client certificate text available to be used in request authentication. PEM-encoded.

Remote Agent (`remote_agent`) supports the following:

Expand All @@ -100,16 +105,14 @@ Remote Agent (`remote_agent`) supports the following:

Email (`email`) supports the following:

* `notify_all` - (Required) Send an email to all team members according to the `notify_on` rules.
* `notify_on` - (Required) Upon completion of a test run Runscope will send email notifications, allowed values: `all`, `failures`, `threshold` or `switch`
* `notify_threshold` (Required) An integer between 1 and 10 for use with the `notify_on settings`: only used when `threshold` and `switch` values are given
* `recipient` (Required) Block describing recipient, documented below. May be declared multiple times.
* `notify_all` - (Optional) Send an email to all team members according to the `notify_on` rules.
* `notify_on` - (Optional) Upon completion of a test run Runscope will send email notifications, allowed values: `all`, `failures`, `threshold` or `switch`
* `notify_threshold` (Optional) An integer between 1 and 10 for use with the `notify_on settings`: only used when `threshold` and `switch` values are given
* `recipient` (Optional) Block describing recipient, documented below. May be declared multiple times.

Recipient (`recipient`), See [team api](https://www.runscope.com/docs/api/teams), supports the following:

* `name` - (Optional) The name of the person.
* `id` - (Optional) The unique identifier for this person's account.
* `email` - (Optional) The email address for this account.
* `id` - (Required) The unique identifier for this person's account.

## Attributes Reference

Expand Down
16 changes: 8 additions & 8 deletions docs/resources/schedule.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ using a unique Test-specific or Shared [Environment](environment.html).

```hcl
resource "runscope_bucket" "bucket" {
name = "terraform-provider-test"
team_uuid = "d038db69-b5a9-45af-80d8-3be47c37e309"
name = "terraform-provider-test"
team_uuid = "d038db69-b5a9-45af-80d8-3be47c37e309"
}
resource "runscope_test" "test" {
Expand All @@ -30,11 +30,11 @@ resource "runscope_environment" "environment" {
}
resource "runscope_schedule" "daily" {
bucket_id = runscope_bucket.bucket.id
test_id = runscope_test.test.id
interval = "1d"
note = "This is a daily schedule"
environment_id = runscope_environment.environment.id
bucket_id = runscope_bucket.bucket.id
test_id = runscope_test.test.id
interval = "1d"
note = "This is a daily schedule"
environment_id = runscope_environment.environment.id
}
```

Expand All @@ -60,4 +60,4 @@ The following arguments are supported:

The following attributes are exported:

* `id` - The ID of the schedule.
* `id` - The ID of the schedule.
4 changes: 4 additions & 0 deletions docs/resources/test.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ The following attributes are exported:
* `id` - The unique identifier for the test.
* `name` - The name of this test.
* `description` - Human-readable description of the new test.
* `default_environment_id` - The default environment for the test.
* `created_at` - Date the test was created (in Epoch time).
* `created_by` - Details of the user who created this test.
* `trigger_url` - The trigger URL for this test.

## Import

Expand Down
21 changes: 21 additions & 0 deletions internal/provider/data_source_runscope_bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,23 @@ func dataSourceRunscopeBucket() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"auth_token": {
Type: schema.TypeString,
Computed: true,
Sensitive: true,
},
"default": {
Type: schema.TypeBool,
Computed: true,
},
"verify_ssl": {
Type: schema.TypeBool,
Computed: true,
},
"trigger_url": {
Type: schema.TypeString,
Computed: true,
},
},
}
}
Expand All @@ -40,6 +57,10 @@ func dataSourceRunscopeBucketRead(ctx context.Context, d *schema.ResourceData, m
d.SetId(bucket.Key)
d.Set("name", bucket.Name)
d.Set("team_uuid", bucket.Team.UUID)
d.Set("auth_token", bucket.AuthToken)
d.Set("default", bucket.Default)
d.Set("verify_ssl", bucket.VerifySSL)
d.Set("trigger_url", bucket.TriggerURL)

return nil
}
4 changes: 4 additions & 0 deletions internal/provider/data_source_runscope_bucket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ func TestAccDataSourceRunscopeBucket(t *testing.T) {
Config: fmt.Sprintf(testAccDataSourceRunscopeBucketConfig, bucketName, teamId),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("data.runscope_bucket.test", "name", bucketName),
resource.TestCheckResourceAttr("data.runscope_bucket.test", "team_uuid", teamId),
resource.TestCheckResourceAttrSet("data.runscope_bucket.test", "default"),
resource.TestCheckResourceAttrSet("data.runscope_bucket.test", "verify_ssl"),
resource.TestCheckResourceAttrSet("data.runscope_bucket.test", "trigger_url"),
),
},
},
Expand Down
37 changes: 0 additions & 37 deletions internal/provider/import_runscope_bucket_test.go

This file was deleted.

Loading

0 comments on commit 546c3e0

Please sign in to comment.