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

No payload is not an authentic player #430

Merged
merged 2 commits into from
Jul 16, 2019
Merged
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
8 changes: 4 additions & 4 deletions src/master/master.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@ export const isActionFromAuthenticPlayer = ({
return true;
}

if (!action.payload) {
return true;
}

const hasCredentials = Object.keys(gameMetadata.players).some(key => {
return !!(
gameMetadata.players[key] && gameMetadata.players[key].credentials
Expand All @@ -81,6 +77,10 @@ export const isActionFromAuthenticPlayer = ({
return true;
}

if (!action.payload) {
return false;
}

if (!action.payload.credentials) {
return false;
}
Expand Down
32 changes: 16 additions & 16 deletions src/master/master.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -439,22 +439,6 @@ describe('isActionFromAuthenticPlayer', () => {
});
});

describe('when action contains no payload', () => {
beforeEach(() => {
action = {};
});

test('the action is authentic', async () => {
const result = isActionFromAuthenticPlayer({
action,
gameMetadata,
playerID,
});

expect(result).toBeTruthy();
});
});

describe('when game has no credentials', () => {
beforeEach(() => {
gameMetadata = {
Expand All @@ -476,6 +460,22 @@ describe('isActionFromAuthenticPlayer', () => {
});

describe('when game has credentials', () => {
describe('when action contains no payload', () => {
beforeEach(() => {
action = {};
});

test('the action is not authentic', async () => {
const result = isActionFromAuthenticPlayer({
action,
gameMetadata,
playerID,
});

expect(result).toBeFalsy();
});
});

describe('when action contains no credentials', () => {
beforeEach(() => {
action = {
Expand Down