Skip to content

Commit bebb00b

Browse files
committed
feat: Added SHA256/384/512 hashing with Base64 output.
1 parent ea8449c commit bebb00b

File tree

101 files changed

+3972
-136
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+3972
-136
lines changed

acc-coverage.png

-5.34 KB
Loading

acc-coverage.svg

Lines changed: 275 additions & 119 deletions
Loading

bats/ds_hash_sha256.bats.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bats
2+
# https://bats-core.readthedocs.io/en/stable/writing-tests.html
3+
4+
@test "corefunc_hash_sha256: attrs" {
5+
run bash -c "tfschema data show -format=json corefunc_hash_sha256 | jq -Mrc '.attributes[]'"
6+
7+
[[ ${status} -eq 0 ]]
8+
[[ ${lines[0]} == '{"name":"input","type":"string","required":true,"optional":false,"computed":false,"sensitive":false}' ]]
9+
[[ ${lines[1]} == '{"name":"value","type":"string","required":false,"optional":false,"computed":true,"sensitive":false}' ]]
10+
}

bats/ds_hash_sha256_base64.bats.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bats
2+
# https://bats-core.readthedocs.io/en/stable/writing-tests.html
3+
4+
@test "corefunc_hash_sha256_base64: attrs" {
5+
run bash -c "tfschema data show -format=json corefunc_hash_sha256_base64 | jq -Mrc '.attributes[]'"
6+
7+
[[ ${status} -eq 0 ]]
8+
[[ ${lines[0]} == '{"name":"input","type":"string","required":true,"optional":false,"computed":false,"sensitive":false}' ]]
9+
[[ ${lines[1]} == '{"name":"value","type":"string","required":false,"optional":false,"computed":true,"sensitive":false}' ]]
10+
}

bats/ds_hash_sha384.bats.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bats
2+
# https://bats-core.readthedocs.io/en/stable/writing-tests.html
3+
4+
@test "corefunc_hash_sha384: attrs" {
5+
run bash -c "tfschema data show -format=json corefunc_hash_sha384 | jq -Mrc '.attributes[]'"
6+
7+
[[ ${status} -eq 0 ]]
8+
[[ ${lines[0]} == '{"name":"input","type":"string","required":true,"optional":false,"computed":false,"sensitive":false}' ]]
9+
[[ ${lines[1]} == '{"name":"value","type":"string","required":false,"optional":false,"computed":true,"sensitive":false}' ]]
10+
}

bats/ds_hash_sha384_base64.bats.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bats
2+
# https://bats-core.readthedocs.io/en/stable/writing-tests.html
3+
4+
@test "corefunc_hash_sha384_base64: attrs" {
5+
run bash -c "tfschema data show -format=json corefunc_hash_sha384_base64 | jq -Mrc '.attributes[]'"
6+
7+
[[ ${status} -eq 0 ]]
8+
[[ ${lines[0]} == '{"name":"input","type":"string","required":true,"optional":false,"computed":false,"sensitive":false}' ]]
9+
[[ ${lines[1]} == '{"name":"value","type":"string","required":false,"optional":false,"computed":true,"sensitive":false}' ]]
10+
}

bats/ds_hash_sha512.bats.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bats
2+
# https://bats-core.readthedocs.io/en/stable/writing-tests.html
3+
4+
@test "corefunc_hash_sha512: attrs" {
5+
run bash -c "tfschema data show -format=json corefunc_hash_sha512 | jq -Mrc '.attributes[]'"
6+
7+
[[ ${status} -eq 0 ]]
8+
[[ ${lines[0]} == '{"name":"input","type":"string","required":true,"optional":false,"computed":false,"sensitive":false}' ]]
9+
[[ ${lines[1]} == '{"name":"value","type":"string","required":false,"optional":false,"computed":true,"sensitive":false}' ]]
10+
}

bats/ds_hash_sha512_base64.bats.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bats
2+
# https://bats-core.readthedocs.io/en/stable/writing-tests.html
3+
4+
@test "corefunc_hash_sha512_base64: attrs" {
5+
run bash -c "tfschema data show -format=json corefunc_hash_sha512_base64 | jq -Mrc '.attributes[]'"
6+
7+
[[ ${status} -eq 0 ]]
8+
[[ ${lines[0]} == '{"name":"input","type":"string","required":true,"optional":false,"computed":false,"sensitive":false}' ]]
9+
[[ ${lines[1]} == '{"name":"value","type":"string","required":false,"optional":false,"computed":true,"sensitive":false}' ]]
10+
}

corefuncprovider/hash_md5_base64_data_source.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func (d *hashMd5Base64DataSource) Schema(
7878

7979
resp.Schema = schema.Schema{
8080
MarkdownDescription: strings.TrimSpace(dedent.Dedent(`
81-
Generates the MD5 hash of a string.
81+
Generates the MD5 hash of a string. Returns a Base64 value instead of a hexadecimal string.
8282
8383
Maps to the ` + linkPackage("HashMD5") + ` Go method, which can be used in ` + Terratest + `.
8484
`)),

corefuncprovider/hash_sha1_base64_data_source.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func (d *hashSha1Base64DataSource) Schema(
7878

7979
resp.Schema = schema.Schema{
8080
MarkdownDescription: strings.TrimSpace(dedent.Dedent(`
81-
Generates the SHA-1 hash of a string.
81+
Generates the SHA-1 hash of a string. Returns a Base64 value instead of a hexadecimal string.
8282
8383
Maps to the ` + linkPackage("Base64HashSHA1") + ` Go method, which can be used in ` + Terratest + `.
8484
`)),

0 commit comments

Comments
 (0)