Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include session in request for NakamaGrpcClient.sessionLogout #110

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions nakama/lib/src/nakama_client/nakama_grpc_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,13 @@ class NakamaGrpcClient extends NakamaBaseClient {

@override
Future<void> sessionLogout({required model.Session session}) async {
await _client.sessionLogout(api.SessionLogoutRequest(
refreshToken: session.refreshToken,
token: session.token,
));
await _client.sessionLogout(
api.SessionLogoutRequest(
refreshToken: session.refreshToken,
token: session.token,
),
options: _getSessionCallOptions(session),
);
}

@override
Expand Down
36 changes: 36 additions & 0 deletions nakama/test/grpc/session_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import 'package:faker/faker.dart';
import 'package:grpc/grpc.dart';
import 'package:nakama/nakama.dart';
import 'package:test/test.dart';

import '../config.dart';

void main() {
group('[gRPC] Test Session', () {
late final NakamaBaseClient client;

setUpAll(() async {
client = NakamaGrpcClient.init(
host: kTestHost,
ssl: false,
serverKey: kTestServerKey,
);
});

test('logging out of session works', () async {
final session =
await client.authenticateDevice(deviceId: faker.guid.guid());

await client.sessionLogout(session: session);

await expectLater(
client.sessionLogout(session: session),
throwsA(
isA<GrpcError>()
.having((e) => e.code, 'code', 16)
.having((e) => e.codeName, 'codeName', 'UNAUTHENTICATED'),
),
);
});
});
}
34 changes: 34 additions & 0 deletions nakama/test/rest/session_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import 'package:dio/dio.dart';
import 'package:faker/faker.dart';
import 'package:nakama/nakama.dart';
import 'package:test/test.dart';

import '../config.dart';

void main() {
group('[REST] Test Session', () {
late final NakamaRestApiClient client;

setUpAll(() async {
client = NakamaRestApiClient.init(
host: kTestHost,
ssl: false,
serverKey: kTestServerKey,
);
});

test('logging out of session works', () async {
final session =
await client.authenticateDevice(deviceId: faker.guid.guid());

await client.sessionLogout(session: session);

await expectLater(
client.sessionLogout(session: session),
throwsA(
isA<DioException>(),
),
);
});
});
}