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

test: Add tests for refresh_endpoint param in oauth connectors #6

Merged
merged 1 commit into from
Jan 16, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ export class DropboxImpl extends OAuthBaseConnector implements IConnector {
if (!params?.refresh) {
return false;
}
try {
new URL(params.refresh_endpoint);
} catch (err) {
return false;
}
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ export class GDriveImpl extends OAuthBaseConnector implements IConnector {
if (!params?.refresh) {
return false;
}
try {
new URL(params.refresh_endpoint);
} catch (err) {
return false;
}

return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ export class OneDriveImpl extends OAuthBaseConnector implements IConnector {
if (!params?.refresh) {
return false;
}
try {
new URL(params.refresh_endpoint);
} catch (err) {
return false;
}
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ export class SharepointImpl extends OAuthBaseConnector implements IConnector {
if (!params?.refresh) {
return false;
}
try {
new URL(params.refresh_endpoint);
} catch (err) {
return false;
}
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,31 @@ describe('Test validate dropbox params', () => {
).toBe(false);
});

dropboxTest('Incorrect - With wrong params - two valid', ({ sourceConnector }) => {
expect(
sourceConnector.areParametersValid({
token: 'test',
refresh: 'test',
}),
).toBe(false);
});

dropboxTest('Incorrect - With wrong params - invalid url', ({ sourceConnector }) => {
expect(
sourceConnector.areParametersValid({
token: 'test',
refresh: 'test',
refresh_endpoint: 'invalid_url',
}),
).toBe(false);
});

dropboxTest('Incorrect - With empty params', ({ sourceConnector }) => {
expect(
sourceConnector.areParametersValid({
token: '',
refresh: '',
refresh_endpoint: '',
}),
).toBe(false);
});
Expand All @@ -89,6 +109,7 @@ describe('Test validate dropbox params', () => {
sourceConnector.areParametersValid({
token: 'test',
refresh: 'test',
refresh_endpoint: 'https://stashify.cloud/api/external_auth/gdrive/refresh',
}),
).toBe(true);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,31 @@ describe('Test validate gdrive params', () => {
).toBe(false);
});

gDriveTest('Incorrect - With wrong params - two valid', ({ sourceConnector }) => {
expect(
sourceConnector.areParametersValid({
token: 'test',
refresh: 'test',
}),
).toBe(false);
});

gDriveTest('Incorrect - With wrong params - invalid url', ({ sourceConnector }) => {
expect(
sourceConnector.areParametersValid({
token: 'test',
refresh: 'test',
refresh_endpoint: 'invalid_url',
}),
).toBe(false);
});

gDriveTest('Incorrect - With empty params', ({ sourceConnector }) => {
expect(
sourceConnector.areParametersValid({
token: '',
refresh: '',
refresh_endpoint: '',
}),
).toBe(false);
});
Expand All @@ -98,6 +118,7 @@ describe('Test validate gdrive params', () => {
sourceConnector.areParametersValid({
token: 'test',
refresh: 'test',
refresh_endpoint: 'https://stashify.cloud/api/external_auth/gdrive/refresh',
}),
).toBe(true);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,31 @@ describe('Test validate gdrive params', () => {
).toBe(false);
});

oneDriveTest('Incorrect - With wrong params - invalid url', ({ sourceConnector }) => {
expect(
sourceConnector.areParametersValid({
token: 'test',
refresh: 'test',
refresh_endpoint: 'invalid_url',
}),
).toBe(false);
});

oneDriveTest('Incorrect - With wrong params - two valid', ({ sourceConnector }) => {
expect(
sourceConnector.areParametersValid({
token: 'test',
refresh: 'test',
}),
).toBe(false);
});

oneDriveTest('Incorrect - With empty params', ({ sourceConnector }) => {
expect(
sourceConnector.areParametersValid({
token: '',
refresh: '',
refresh_endpoint: '',
}),
).toBe(false);
});
Expand All @@ -98,6 +118,7 @@ describe('Test validate gdrive params', () => {
sourceConnector.areParametersValid({
token: 'test',
refresh: 'test',
refresh_endpoint: 'https://stashify.cloud/api/external_auth/gdrive/refresh',
}),
).toBe(true);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,31 @@ describe('Test validate sharepoint params', () => {
).toBe(false);
});

sharepointTest('Incorrect - With wrong params - two valid', ({ sourceConnector }) => {
expect(
sourceConnector.areParametersValid({
token: 'test',
refresh: 'test',
}),
).toBe(false);
});

sharepointTest('Incorrect - With wrong params - invalid url', ({ sourceConnector }) => {
expect(
sourceConnector.areParametersValid({
token: 'test',
refresh: 'test',
refresh_endpoint: 'invalid_url',
}),
).toBe(false);
});

sharepointTest('Incorrect - With empty params', ({ sourceConnector }) => {
expect(
sourceConnector.areParametersValid({
token: '',
refresh: '',
refresh_endpoint: '',
}),
).toBe(false);
});
Expand All @@ -98,6 +118,7 @@ describe('Test validate sharepoint params', () => {
sourceConnector.areParametersValid({
token: 'test',
refresh: 'test',
refresh_endpoint: 'https://stashify.cloud/api/external_auth/gdrive/refresh',
}),
).toBe(true);
});
Expand Down