Skip to content
This repository has been archived by the owner on Feb 27, 2023. It is now read-only.

Commit

Permalink
add comments documenting cram is used for jose-util testing
Browse files Browse the repository at this point in the history
Cherry-picked from #274
  • Loading branch information
zamicol authored and mbyczkowski committed Mar 8, 2020
1 parent 5c5751a commit 0af3954
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
*.pem
*.cov
jose-util/jose-util
jose-util.t.err
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@ script:
- go test ./cipher -v -covermode=count -coverprofile=cipher/profile.cov
- go test ./jwt -v -covermode=count -coverprofile=jwt/profile.cov
- go test ./json -v # no coverage for forked encoding/json package
- cd jose-util && go build && PATH=$PWD:$PATH cram -v jose-util.t
- cd jose-util && go build && PATH=$PWD:$PATH cram -v jose-util.t # cram tests jose-util
- cd ..

after_success:
- gocovmerge *.cov */*.cov > merged.coverprofile
- $HOME/gopath/bin/goveralls -coverprofile merged.coverprofile -service=travis-ci

8 changes: 8 additions & 0 deletions jose-util/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ Keys are specified via the `--key` flag. Supported key types are naked RSA/EC
keys and X.509 certificates with embedded RSA/EC keys. Keys must be in PEM
or DER formats.


## Testing

`cram` is used for testing. This can be installed with pip or `sudo apt install
python-cram` See the travis file for how this is used in testing. For example,
`go build && PATH=$PWD:$PATH cram -v jose-util.t`


## Examples

### Encrypt
Expand Down
13 changes: 8 additions & 5 deletions jose-util/jose-util.t
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
Set up test keys.
This is a cram test file. See the travis file for how this is used in testing.
For example, `go build && PATH=$PWD:$PATH cram -v jose-util.t`

Set up static test keys.

$ cat > rsa.pub <<EOF
> -----BEGIN PUBLIC KEY-----
Expand Down Expand Up @@ -61,28 +64,28 @@ Set up test keys.

Encrypt and then decrypt a test message (RSA).

$ echo "Lorem ipsum dolor sit amet" |
$ echo "Lorem ipsum dolor sit amet" |
> jose-util encrypt --alg RSA-OAEP --enc A128GCM --key rsa.pub |
> jose-util decrypt --key rsa.key
Lorem ipsum dolor sit amet

Encrypt and then decrypt a test message (EC).

$ echo "Lorem ipsum dolor sit amet" |
$ echo "Lorem ipsum dolor sit amet" |
> jose-util encrypt --alg ECDH-ES+A128KW --enc A128GCM --key ec.pub |
> jose-util decrypt --key ec.key
Lorem ipsum dolor sit amet

Sign and verify a test message (RSA).

$ echo "Lorem ipsum dolor sit amet" |
$ echo "Lorem ipsum dolor sit amet" |
> jose-util sign --alg PS256 --key rsa.key |
> jose-util verify --key rsa.pub
Lorem ipsum dolor sit amet

Sign and verify a test message (EC).

$ echo "Lorem ipsum dolor sit amet" |
$ echo "Lorem ipsum dolor sit amet" |
> jose-util sign --alg ES384 --key ec.key |
> jose-util verify --key ec.pub
Lorem ipsum dolor sit amet
Expand Down

0 comments on commit 0af3954

Please sign in to comment.