-
Notifications
You must be signed in to change notification settings - Fork 7
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 #150 from Dash-Industry-Forum/feat/eccp
Enhanced Clear Key Content Protection with on-the-fly encryption
- Loading branch information
Showing
18 changed files
with
787 additions
and
72 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
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,66 @@ | ||
package app | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestParseLaURLBody(t *testing.T) { | ||
cases := []struct { | ||
name string | ||
body string | ||
expectedHexKeys []id16 | ||
}{ | ||
{ | ||
name: "dashif-example", | ||
body: `{"kids":["nrQFDeRLSAKTLifXUIPiZg"],"type":"temporary"}`, | ||
expectedHexKeys: []id16{MustKey16FromHex("9eb4050de44b4802932e27d75083e266")}, | ||
}, | ||
} | ||
for _, c := range cases { | ||
t.Run(c.name, func(t *testing.T) { | ||
hexKIDs, err := parseLaURLBody([]byte(c.body)) | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
require.Equal(t, c.expectedHexKeys, hexKIDs) | ||
}) | ||
} | ||
} | ||
|
||
func MustKey16FromHex(hexStr string) id16 { | ||
k, err := id16FromHex(hexStr) | ||
if err != nil { | ||
panic(err) | ||
} | ||
return k | ||
} | ||
|
||
func TestGenerateLAResponse(t *testing.T) { | ||
cases := []struct { | ||
name string | ||
key id16 | ||
keyID id16 | ||
expectedResp LaURLResponse | ||
}{ | ||
{ | ||
name: "dashif-example", | ||
key: MustKey16FromHex("9eb4050de44b4802932e27d75083e266"), | ||
keyID: MustKey16FromHex("9eb4050de44b4802932e27d75083e266"), | ||
expectedResp: LaURLResponse{Type: "temporary", | ||
Keys: []CCPKey{ | ||
{Kty: "oct", | ||
K: "nrQFDeRLSAKTLifXUIPiZg", | ||
Kid: "nrQFDeRLSAKTLifXUIPiZg"}, | ||
}, | ||
}, | ||
}, | ||
} | ||
for _, c := range cases { | ||
t.Run(c.name, func(t *testing.T) { | ||
resp := generateLaURLResponse([]keyAndID{{key: c.key, id: c.keyID}}) | ||
require.Equal(t, c.expectedResp, resp) | ||
}) | ||
} | ||
} |
Oops, something went wrong.