-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit tests for remark/rehype plugins
See #17 Migrate unit tests for our custom remark and rehype plugins from the archived `gravitational/docs` repo. Convert these tests to Jest, which unlike the uvu testing tool we used for `gravitational/docs`, is still being maintained. Add a GitHub Actions workflow to run the tests on pull requests. This change does not add tests for `remark-includes`, which requires some changes to how the site processes link paths.
- Loading branch information
Showing
45 changed files
with
2,795 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
name: Test | ||
on: | ||
pull_request: | ||
|
||
jobs: | ||
run-tests: | ||
name: Run tests | ||
runs-on: ubuntu-22.04-2core-arm64 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- run: yarn && yarn test |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** @type {import('ts-jest').JestConfigWithTsJest} */ | ||
const jestConfig = { | ||
preset: "ts-jest/presets/default-esm", | ||
testEnvironment: "node", | ||
extensionsToTreatAsEsm: [".ts"], | ||
transform: { | ||
"^.+\\.[tj]s$": [ | ||
"ts-jest", | ||
{ | ||
useESM: true, | ||
tsconfig: "tsconfig.node.json", | ||
}, | ||
], | ||
}, | ||
transformIgnorePatterns: ["<rootDir>/node_modules/*"], | ||
}; | ||
export default jestConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
```code | ||
$ tsh request search --kind node | ||
Name Hostname Labels Resource ID | ||
------------------------------------ ----------- ------------ | ||
------------------------------------------------------ | ||
b1168402-9340-421a-a344-af66a6675738 iot test=test | ||
/teleport.example.com/node/b1168402-9340-421a-a344-af66a6675738 | ||
bbb56211-7b54-4f9e-bee9-b68ea156be5f node test=test | ||
/teleport.example.com/node/bbb56211-7b54-4f9e-bee9-b68ea156be5f | ||
To request access to these resources, run | ||
> tsh request create --resource | ||
> /teleport.example.com/node/b1168402-9340-421a-a344-af66a6675738 --resource | ||
> /teleport.example.com/node/bbb56211-7b54-4f9e-bee9-b68ea156be5f \ | ||
> --reason <request reason> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
```go | ||
// This is a comment about the code below, which contains a | ||
// <Var name="myvar" />. This comment also includes another | ||
// <Var name="othervar" />. This is the end of the comment. | ||
func myfunc(attr string) error { | ||
return nil | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
1. Create a `main.tf` file containing this minimal Terraform code: | ||
|
||
```hcl | ||
terraform { | ||
required_providers { | ||
teleport = { | ||
source = "terraform.releases.teleport.dev/gravitational/teleport" | ||
version = "~> (=teleport.major_version=).0" | ||
} | ||
} | ||
} | ||
provider "teleport" { | ||
addr = '<Var name="teleport.example.com:443" />' | ||
} | ||
``` | ||
|
||
1. Then, init your Terraform working directory to download the Teleport provider: | ||
|
||
```code | ||
$ terraform init | ||
Initializing the backend... | ||
Initializing provider plugins... | ||
- Finding terraform.releases.teleport.dev/gravitational/teleport versions matching ... | ||
``` | ||
|
||
1. Finally, run a Terraform plan: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Assign <Var name="proxy" initial="teleport.example.com:443" /> to the address of | ||
your Teleport Proxy Service. | ||
|
||
```hcl | ||
provider "teleport" { | ||
# Update addr to point to your Teleport Cloud tenant URL's host:port | ||
addr = "<Var name="proxy" />" | ||
identity_file_path = "terraform-identity" | ||
} | ||
``` | ||
|
18 changes: 18 additions & 0 deletions
18
server/fixtures/includes/includes-code-snippet-heredoc-error.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
## Header | ||
|
||
```code | ||
# Copy and Paste the below and run on the Teleport Auth server. | ||
$ cat > api-role.yaml <<ENDOFMESSAGE | ||
kind: role | ||
metadata: | ||
name: api-role | ||
spec: | ||
allow: | ||
rules: | ||
- resources: ['role'] | ||
verbs: ['read'] | ||
deny: | ||
node_labels: | ||
'*': '*' | ||
version: v3 | ||
``` |
24 changes: 24 additions & 0 deletions
24
server/fixtures/includes/includes-code-snippet-heredoc.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
## Header | ||
|
||
```code | ||
# Copy and Paste the below and run on the Teleport Auth server. | ||
$ cat > api-role.yaml <<ENDOFMESSAGE | ||
kind: role | ||
metadata: | ||
name: api-role | ||
spec: | ||
allow: | ||
rules: | ||
- resources: ['role'] | ||
verbs: ['read'] | ||
deny: | ||
node_labels: | ||
'*': '*' | ||
version: v3 | ||
ENDOFMESSAGE | ||
# Create role | ||
$ tctl create -f api-role.yaml | ||
# Add user and login via web proxy | ||
$ tctl users add api-user --roles=api-role | ||
``` |
9 changes: 9 additions & 0 deletions
9
server/fixtures/includes/includes-code-snippet-multiline-error.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
## Header | ||
|
||
```code | ||
$ curl \ | ||
--cacert /Users/alice/.tsh/keys/teleport.example.com/certs.pem \ | ||
--cert /Users/alice/.tsh/keys/teleport.example.com/alice-app/cluster-name/grafana-x509.pem \ | ||
--key /Users/alice/.tsh/keys/teleport.example.com/alice \ | ||
https://grafana.teleport.example.com:3080 \ | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
## Header | ||
|
||
```code | ||
$ curl \ | ||
--cacert /Users/alice/.tsh/keys/teleport.example.com/certs.pem \ | ||
--cert /Users/alice/.tsh/keys/teleport.example.com/alice-app/cluster-name/grafana-x509.pem \ | ||
--key /Users/alice/.tsh/keys/teleport.example.com/alice \ | ||
https://grafana.teleport.example.com:3080 | ||
``` |
24 changes: 24 additions & 0 deletions
24
server/fixtures/includes/includes-code-snippet-output-to-file-mode.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
## Header | ||
|
||
```code | ||
# Copy and Paste the below and run on the Teleport Auth server. | ||
$ cat > api-role.yaml << ENDOFMESSAGE > aws-issuer.yaml | ||
kind: role | ||
metadata: | ||
name: api-role | ||
spec: | ||
allow: | ||
rules: | ||
- resources: ['role'] | ||
verbs: ['read'] | ||
deny: | ||
node_labels: | ||
'*': '*' | ||
version: v3 | ||
ENDOFMESSAGE | ||
# Create role | ||
$ tctl create -f api-role.yaml | ||
# Add user and login via web proxy | ||
$ tctl users add api-user --roles=api-role | ||
``` |
11 changes: 11 additions & 0 deletions
11
server/fixtures/includes/includes-code-snippet-simplest.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
## Header | ||
|
||
```code | ||
$ tsh app config --format=uri | ||
# https://grafana-root.gravitational.io:3080 | ||
``` | ||
|
||
```bash | ||
$ tsh app config --format=uri | ||
# it's bash lang | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
## Header | ||
|
||
```code | ||
$ aws iam create-policy --policy-name<Var name="kube-iam-policy"/> | ||
# some comment | ||
"Policy": { | ||
"PolicyName": "<Var name="kube-iam-policy"/>", | ||
"PolicyId": "ANPAW2Y2Q2Y2Y2Y2Y2Y2Y", | ||
"Arn": "arn:aws:iam::aws:policy/"<Var name="kube-iam-policy"/> | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
## Header | ||
|
||
```var | ||
teleport: | ||
identitySecretName: "teleport-plugin-jira-identity" | ||
address: <Var name="teleport-address"/> | ||
# /etc/teleport.yaml | ||
auth_service: | ||
# ... | ||
ca_key_params: | ||
keyring: <Var name="keyring"/> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
## Header | ||
|
||
```code | ||
$ docker pull <Var name="folder" /> quay.io/gravitational/teleport:9 <Var name="domain name" isGlobal /> we recommend following our | ||
``` |
12 changes: 12 additions & 0 deletions
12
server/fixtures/includes/includes-var-in-multiline-command.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
## Header | ||
|
||
```code | ||
$ tctl create <<EOF | ||
kind: <Var name="role" /> | ||
version: v3 | ||
metadata: | ||
<Var name="field" />: <Var name="domain name" description="super domain name" isGlobal /> | ||
EOF | ||
# create the role | ||
$ tsh db ls | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```powershell | ||
certutil -dspublish -f <Var name="user-ca.cer" /> NTAuthCA | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<snippet> | ||
<command> | ||
<commandline data-content="$ "> | ||
tsh request search --kind node | ||
</commandline> | ||
</command> | ||
|
||
<codeline> | ||
Name Hostname Labels Resource ID | ||
</codeline> | ||
|
||
<codeline> | ||
\------------------------------------ ----------- ------------ | ||
</codeline> | ||
|
||
<codeline> | ||
\------------------------------------------------------ | ||
</codeline> | ||
|
||
<codeline> | ||
b1168402-9340-421a-a344-af66a6675738 iot test=test | ||
</codeline> | ||
|
||
<codeline> | ||
/teleport.example.com/node/b1168402-9340-421a-a344-af66a6675738 | ||
</codeline> | ||
|
||
<codeline> | ||
bbb56211-7b54-4f9e-bee9-b68ea156be5f node test=test | ||
</codeline> | ||
|
||
<codeline> | ||
/teleport.example.com/node/bbb56211-7b54-4f9e-bee9-b68ea156be5f | ||
</codeline> | ||
|
||
<codeline> | ||
|
||
</codeline> | ||
|
||
<br /> | ||
|
||
<codeline> | ||
To request access to these resources, run | ||
</codeline> | ||
|
||
<codeline> | ||
\> tsh request create --resource | ||
</codeline> | ||
|
||
<codeline> | ||
\> /teleport.example.com/node/b1168402-9340-421a-a344-af66a6675738 --resource | ||
</codeline> | ||
|
||
<codeline> | ||
\> /teleport.example.com/node/bbb56211-7b54-4f9e-bee9-b68ea156be5f \ | ||
</codeline> | ||
|
||
<codeline> | ||
\> --reason <request reason> | ||
</codeline> | ||
</snippet> |
Oops, something went wrong.