Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
keycloak-proxy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Janne Mareike Koschinski
keycloak-proxy
Commits
ac10b49a
Commit
ac10b49a
authored
Apr 26, 2017
by
Rohith Jayawardene
Committed by
Rohith
May 19, 2017
Browse files
Options
Downloads
Patches
Plain Diff
BenchMark Encoding (#219)
- adding benchmarks for encryptions
parent
e58ce30a
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Makefile
+1
-1
1 addition, 1 deletion
Makefile
utils_test.go
+48
-4
48 additions, 4 deletions
utils_test.go
with
49 additions
and
5 deletions
Makefile
+
1
−
1
View file @
ac10b49a
...
@@ -120,7 +120,7 @@ format:
...
@@ -120,7 +120,7 @@ format:
bench
:
bench
:
@
echo
"--> Running go bench"
@
echo
"--> Running go bench"
@
godep go
test
-v
-bench
=
.
@
godep go
test
-bench
=
.
coverage
:
coverage
:
@
echo
"--> Running go coverage"
@
echo
"--> Running go coverage"
...
...
This diff is collapsed.
Click to expand it.
utils_test.go
+
48
−
4
View file @
ac10b49a
...
@@ -129,6 +129,53 @@ func TestEncodeText(t *testing.T) {
...
@@ -129,6 +129,53 @@ func TestEncodeText(t *testing.T) {
assert
.
NoError
(
t
,
err
)
assert
.
NoError
(
t
,
err
)
}
}
var
(
fakePlainText
=
[]
byte
(
`nFlhnhwRzC9uJ9mjhR0PQezUpIiDlU9ASLqH1KIKFhBZZrMZfnAAdHdgKs2OJoni8cTSQ
JxkaNpboZ6hnrMytlw5kf0biF7dLTU885uHIGkUIRy75hx6BaTEEhbN36qVTxediEHd6xeBPS3qpJ7riO6J
EeaQr1rroDL0LvmDyB6Zds4LdVQEmtUueusc7jkBz7gJ12vnTHIxviZM5rzcq4tyCbZO7Kb37RqZg5kbYGK
PfErhUwUIin7jsNVE7coB`
)
fakeCipherText
=
[]
byte
(
"IF0cfjWXNO0cVZYmfHLv+8R4P4/7seNcIX8jfwy/x/vLPEb9nITdwY7d0zfiQaGTwTV9s5yGgxKT9Ktv6PAjbCR/7M1KjMmlIbKh/PYmEltFxJJTXC4CYrwTiFkfvhad3Zv7pcXk0yLNTX9+V0ZogT629fXdujRzyUdi71t/q1iEE2MM/4EqkBBHnBtW52Rb1Gad8dxAHXA77iWJB/GnUZoGS9eanjEDgU2oSQJicFoFCJ6FXpStUjLuTThB9XIvpClAqQ2P6t7bagN4Zg9XKo5NlftLPflj4alEhpOGcUgCNws85x/95AEUsSlK0pEG059CMIR9K8eRDCMCNqWtp10aHH+b7Jf3gGfWxLhGnD2EiG49Pzc="
)
fakeKey
=
[]
byte
(
"u3K0eKsmGl76jY1buzexwYoRRLLQrQck"
)
)
/*
func TestEncryptedText(t *testing.T) {
s, err := encodeText(string(fakePlainText), string(fakeKey))
require.NoError(t, err)
require.NotEmpty(t, s)
d, err := decodeText(s, string(fakeKey))
require.NoError(t, err)
require.NotEmpty(t, d)
assert.Equal(t, string(fakePlainText), d)
fmt.Printf("Encoded: '%s'\n", s)
fmt.Printf("Decoded: '%s'\n", d)
}
*/
func
BenchmarkEncryptDataBlock
(
b
*
testing
.
B
)
{
for
n
:=
0
;
n
<
b
.
N
;
n
++
{
encryptDataBlock
(
fakePlainText
,
fakeKey
)
}
}
func
BenchmarkEncodeText
(
b
*
testing
.
B
)
{
text
:=
string
(
fakePlainText
)
key
:=
string
(
fakeKey
)
for
n
:=
0
;
n
<
b
.
N
;
n
++
{
encodeText
(
text
,
key
)
}
}
func
BenchmarkDecodeText
(
b
*
testing
.
B
)
{
t
:=
string
(
fakeCipherText
)
k
:=
string
(
fakeKey
)
for
n
:=
0
;
n
<
b
.
N
;
n
++
{
if
_
,
err
:=
decodeText
(
t
,
k
);
err
!=
nil
{
b
.
FailNow
()
}
}
}
func
TestDecodeText
(
t
*
testing
.
T
)
{
func
TestDecodeText
(
t
*
testing
.
T
)
{
fakeKey
:=
"HYLNt2JSzD7Lpz0djTRudmlOpbwx1oHB"
fakeKey
:=
"HYLNt2JSzD7Lpz0djTRudmlOpbwx1oHB"
fakeText
:=
"12245325632323263762"
fakeText
:=
"12245325632323263762"
...
@@ -147,11 +194,8 @@ func TestDecodeText(t *testing.T) {
...
@@ -147,11 +194,8 @@ func TestDecodeText(t *testing.T) {
func
TestFindCookie
(
t
*
testing
.
T
)
{
func
TestFindCookie
(
t
*
testing
.
T
)
{
cookies
:=
[]
*
http
.
Cookie
{
cookies
:=
[]
*
http
.
Cookie
{
{
{
Name
:
"cookie_there"
},
Name
:
"cookie_there"
,
},
}
}
assert
.
NotNil
(
t
,
findCookie
(
"cookie_there"
,
cookies
))
assert
.
NotNil
(
t
,
findCookie
(
"cookie_there"
,
cookies
))
assert
.
Nil
(
t
,
findCookie
(
"not_there"
,
cookies
))
assert
.
Nil
(
t
,
findCookie
(
"not_there"
,
cookies
))
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment