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

fix(v3proxy): add send_guid endpoint #1033

Merged
merged 2 commits into from
Jan 29, 2025
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
48 changes: 48 additions & 0 deletions servers/v3-proxy-api/src/routes/v3SendGuid.integration.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import request from 'supertest';
import { startServer } from '../server';
import { Server } from 'http';
import { Application } from 'express';
import { GraphQLClient } from 'graphql-request';

describe('v3/send_guid', () => {
let app: Application;
let server: Server;
let clientSpy;

beforeAll(async () => {
({ app, server } = await startServer(0));
// Response is unused so it doesn't matter what it returns
clientSpy = jest
.spyOn(GraphQLClient.prototype, 'request')
.mockResolvedValue(true);
});
afterAll(async () => {
clientSpy.mockRestore();
server.close();
jest.restoreAllMocks();
});
afterEach(() => jest.clearAllMocks());

it('Accepts actions without access token on POST', async () => {
const actions =
'%5B%7B%22action_identifier%22%3A%22referrer%22%2C%22page%22%3A%22installation%22%2C%22page_params%22%3A%22utm_source%3Dgoogle-play%26utm_medium%3Dorganic%22%2C%22section%22%3A%22core%22%2C%22time%22%3A1737985217%2C%22type_id%22%3A3%2C%22view%22%3A%22mobile%22%2C%22action%22%3A%22pv_wt%22%2C%22cxt_online%22%3A2%2C%22cxt_orient%22%3A1%2C%22sid%22%3A%221737985217%22%7D%5D';
const response = await request(app).post('/v3/send_guid').send({
consumer_key: 'test',
guid: 'test',
locale_lang: 'en-US',
actions,
});
const expected = {
status: 1,
action_results: [false],
action_errors: [
{
message: "Invalid Action: 'pv_wt'",
type: 'Bad request',
code: 130,
},
],
};
expect(response.body).toEqual(expected);
});
});
1 change: 1 addition & 0 deletions servers/v3-proxy-api/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export async function startServer(port: number): Promise<{
app.use('/v3/add', v3AddRouter);
app.use('/v3/fetch', v3FetchRouter);
app.use('/v3/send', v3SendRouter);
app.use('/v3/send_guid', v3SendRouter);

// NOTE: we on purpose do not setup the sentry middleware in this service since it is a proxy and we log our own errors.

Expand Down
Loading