Skip to content

Commit

Permalink
fix bad merge
Browse files Browse the repository at this point in the history
  • Loading branch information
mattapperson committed Jul 13, 2018
1 parent 0e6987b commit 28d486d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { MemoryBeatsAdapter } from '../../../adapters/beats/memory_beats_adapter
import { TestingBackendFrameworkAdapter } from '../../../adapters/framework/testing_framework_adapter';
import { MemoryTagsAdapter } from '../../../adapters/tags/memory_tags_adapter';
import { MemoryTokensAdapter } from '../../../adapters/tokens/memory_tokens_adapter';
import { BeatEnrollmentStatus } from '../../../lib';

import { BeatTag, CMBeat } from '../../../../../common/domain_types';
import { TokenEnrollmentData } from '../../../adapters/tokens/adapter_types';
Expand Down Expand Up @@ -89,12 +90,13 @@ describe('Beats Domain Lib', () => {
);

expect(token).toEqual(validEnrollmentToken);
const { accessToken } = await beatsLib.enrollBeat(
const { accessToken, status } = await beatsLib.enrollBeat(
validEnrollmentToken,
beatId,
'192.168.1.1',
omit(beat, 'enrollment_token')
);
expect(status).toEqual(BeatEnrollmentStatus.Success);

expect(beatsDB.length).toEqual(1);
expect(beatsDB[0]).toHaveProperty('host_ip');
Expand Down
31 changes: 0 additions & 31 deletions x-pack/plugins/beats/server/lib/domains/beats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ export class CMBeatsDomain {
if (!isAccessTokenValid) {
return 'invalid-access-token';
}
const isBeatVerified = beat.hasOwnProperty('verified_on');
if (!isBeatVerified) {
return 'beat-not-verified';
}

await this.adapter.update({
...beat,
Expand Down Expand Up @@ -151,33 +147,6 @@ export class CMBeatsDomain {
return await this.adapter.getAll(user);
}

// TODO cleanup return value, should return a status enum
public async verifyBeats(user: FrameworkUser, beatIds: string[]) {
const beatsFromEs = await this.adapter.getWithIds(user, beatIds);

const nonExistentBeatIds = findNonExistentItems(beatsFromEs, beatIds);

const alreadyVerifiedBeatIds = beatsFromEs
.filter((beat: any) => beat.hasOwnProperty('verified_on'))
.map((beat: any) => beat.id);

const toBeVerifiedBeatIds = beatsFromEs
.filter((beat: any) => !beat.hasOwnProperty('verified_on'))
.map((beat: any) => beat.id);

const verifications = await this.adapter.verifyBeats(
user,
toBeVerifiedBeatIds
);

return {
alreadyVerifiedBeatIds,
nonExistentBeatIds,
toBeVerifiedBeatIds,
verifiedBeatIds: verifications.map((v: any) => v.id),
};
}

public async assignTagsToBeats(
user: FrameworkUser,
assignments: BeatsTagAssignment[]
Expand Down

0 comments on commit 28d486d

Please sign in to comment.