Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
goSDN
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
danet
goSDN
Commits
2536f61e
Commit
2536f61e
authored
3 years ago
by
Fabian Seidl
Browse files
Options
Downloads
Patches
Plain Diff
added tests for log out, needs updates when session handling is there
parent
cfb77bfb
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
controller/api/auth_test.go
+15
-5
15 additions, 5 deletions
controller/api/auth_test.go
controller/northbound/server/auth_test.go
+17
-5
17 additions, 5 deletions
controller/northbound/server/auth_test.go
with
32 additions
and
10 deletions
controller/api/auth_test.go
+
15
−
5
View file @
2536f61e
...
@@ -2,7 +2,6 @@ package api
...
@@ -2,7 +2,6 @@ package api
import
(
import
(
"context"
"context"
"reflect"
"testing"
"testing"
apb
"code.fbi.h-da.de/danet/gosdn/api/go/gosdn/rbac"
apb
"code.fbi.h-da.de/danet/gosdn/api/go/gosdn/rbac"
...
@@ -62,8 +61,18 @@ func TestLogout(t *testing.T) {
...
@@ -62,8 +61,18 @@ func TestLogout(t *testing.T) {
want
*
apb
.
LogoutResponse
want
*
apb
.
LogoutResponse
wantErr
bool
wantErr
bool
}{
}{
// TODO: Add test cases.
{
// Not implemented yet!
name
:
"default log out"
,
args
:
args
{
ctx
:
context
.
TODO
(),
addr
:
testAPIEndpoint
,
username
:
"testAdmin"
,
},
want
:
&
apb
.
LogoutResponse
{
Status
:
apb
.
Status_STATUS_OK
,
},
wantErr
:
false
,
},
}
}
for
_
,
tt
:=
range
tests
{
for
_
,
tt
:=
range
tests
{
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
...
@@ -72,8 +81,9 @@ func TestLogout(t *testing.T) {
...
@@ -72,8 +81,9 @@ func TestLogout(t *testing.T) {
t
.
Errorf
(
"Logout() error = %v, wantErr %v"
,
err
,
tt
.
wantErr
)
t
.
Errorf
(
"Logout() error = %v, wantErr %v"
,
err
,
tt
.
wantErr
)
return
return
}
}
if
!
reflect
.
DeepEqual
(
got
,
tt
.
want
)
{
t
.
Errorf
(
"Logout() = %v, want %v"
,
got
,
tt
.
want
)
if
got
!=
nil
&&
got
.
Status
!=
tt
.
want
.
Status
{
t
.
Errorf
(
"Role.CreateRoles() = %v, want %v"
,
got
,
tt
.
want
)
}
}
})
})
}
}
...
...
This diff is collapsed.
Click to expand it.
controller/northbound/server/auth_test.go
+
17
−
5
View file @
2536f61e
...
@@ -2,7 +2,6 @@ package server
...
@@ -2,7 +2,6 @@ package server
import
(
import
(
"context"
"context"
"reflect"
"testing"
"testing"
apb
"code.fbi.h-da.de/danet/gosdn/api/go/gosdn/rbac"
apb
"code.fbi.h-da.de/danet/gosdn/api/go/gosdn/rbac"
...
@@ -75,9 +74,21 @@ func TestAuth_Logout(t *testing.T) {
...
@@ -75,9 +74,21 @@ func TestAuth_Logout(t *testing.T) {
want
*
apb
.
LogoutResponse
want
*
apb
.
LogoutResponse
wantErr
bool
wantErr
bool
}{
}{
// TODO: Add test cases.
{
// Implement after session hdanling was added
name
:
"default log out"
,
args
:
args
{
ctx
:
context
.
TODO
(),
request
:
&
apb
.
LogoutRequest
{
Username
:
"testAdmin"
,
},
},
want
:
&
apb
.
LogoutResponse
{
Status
:
apb
.
Status_STATUS_OK
,
},
wantErr
:
false
,
},
}
}
for
_
,
tt
:=
range
tests
{
for
_
,
tt
:=
range
tests
{
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
s
:=
Auth
{}
s
:=
Auth
{}
...
@@ -86,8 +97,9 @@ func TestAuth_Logout(t *testing.T) {
...
@@ -86,8 +97,9 @@ func TestAuth_Logout(t *testing.T) {
t
.
Errorf
(
"Auth.Logout() error = %v, wantErr %v"
,
err
,
tt
.
wantErr
)
t
.
Errorf
(
"Auth.Logout() error = %v, wantErr %v"
,
err
,
tt
.
wantErr
)
return
return
}
}
if
!
reflect
.
DeepEqual
(
got
,
tt
.
want
)
{
t
.
Errorf
(
"Auth.Logout() = %v, want %v"
,
got
,
tt
.
want
)
if
got
!=
nil
&&
got
.
Status
!=
tt
.
want
.
Status
{
t
.
Errorf
(
"Role.CreateRoles() = %v, want %v"
,
got
,
tt
.
want
)
}
}
})
})
}
}
...
...
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