-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from coryfklein/secret-type-field-addition
Secret type field addition
- Loading branch information
Showing
3 changed files
with
48 additions
and
5 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
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,31 @@ | ||
package skuber.json | ||
|
||
import org.specs2.mutable.Specification | ||
import skuber.{ObjectMeta, Secret} // for unit-style testing | ||
import format._ | ||
|
||
import play.api.libs.json._ | ||
|
||
/** | ||
* @author Cory Klein | ||
*/ | ||
class SecretSpec extends Specification { | ||
|
||
"A Secret containing a byte array can symmetrically be written to json and the same value read back in" >> { | ||
val dataBytes = "hello".getBytes | ||
val secret = Secret(metadata = ObjectMeta("mySecret"), data = Map("key" -> dataBytes)) | ||
val resultBytes = Json.fromJson[Secret](Json.toJson(secret)).get.data("key") | ||
dataBytes mustEqual resultBytes | ||
} | ||
"this can be done with an empty data map" >> { | ||
val mySecret = Secret(metadata = ObjectMeta("mySecret")) | ||
val json = Json.toJson(mySecret) | ||
val readSecret = Json.fromJson[Secret](Json.toJson(mySecret)).get | ||
mySecret mustEqual readSecret | ||
} | ||
"this can be done with the type member defined" >> { | ||
val mySecret = Secret(metadata = ObjectMeta("mySecret"), `type` = "myType") | ||
val readSecret = Json.fromJson[Secret](Json.toJson(mySecret)).get | ||
mySecret mustEqual readSecret | ||
} | ||
} |