Skip to content
Snippets Groups Projects
Commit da7f54f4 authored by Fabian Seidl's avatar Fabian Seidl
Browse files

added tests for log out, needs updates when session handling is there

parent 4d126fed
No related branches found
No related tags found
1 merge request!308Improve test coverage of rbac stuff
This commit is part of merge request !308. Comments created here will be created in the context of that merge request.
......@@ -2,7 +2,6 @@ package api
import (
"context"
"reflect"
"testing"
apb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/rbac"
......@@ -62,8 +61,18 @@ func TestLogout(t *testing.T) {
want *apb.LogoutResponse
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 {
t.Run(tt.name, func(t *testing.T) {
......@@ -72,8 +81,9 @@ func TestLogout(t *testing.T) {
t.Errorf("Logout() error = %v, wantErr %v", err, tt.wantErr)
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)
}
})
}
......
......@@ -2,7 +2,6 @@ package server
import (
"context"
"reflect"
"testing"
apb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/rbac"
......@@ -75,9 +74,21 @@ func TestAuth_Logout(t *testing.T) {
want *apb.LogoutResponse
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 {
t.Run(tt.name, func(t *testing.T) {
s := Auth{}
......@@ -86,8 +97,9 @@ func TestAuth_Logout(t *testing.T) {
t.Errorf("Auth.Logout() error = %v, wantErr %v", err, tt.wantErr)
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)
}
})
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment