-
Notifications
You must be signed in to change notification settings - Fork 574
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2539 from snyk/feat/unmanaged-security-url
feat: support unmanaged snyk security url
- Loading branch information
Showing
9 changed files
with
103 additions
and
17 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { Ecosystem } from './types'; | ||
|
||
export function isUnmanagedEcosystem(ecosystem: Ecosystem): boolean { | ||
return ecosystem === 'cpp'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { isUnmanagedEcosystem } from '../../../../../src/lib/ecosystems/common'; | ||
|
||
describe('isUnmanagedEcosystem fn', () => { | ||
it.each` | ||
actual | expected | ||
${'cpp'} | ${true} | ||
${'docker'} | ${false} | ||
${'code'} | ${false} | ||
`( | ||
'should validate that given $actual as input, is considered or not an unmanaged ecosystem', | ||
({ actual, expected }) => { | ||
expect(isUnmanagedEcosystem(actual)).toEqual(expected); | ||
}, | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { hasFeatureFlag } from '../../../../../src/lib/feature-flags'; | ||
import * as request from '../../../../../src/lib/request'; | ||
|
||
describe('hasFeatureFlag fn', () => { | ||
it.each` | ||
hasFlag | expected | ||
${true} | ${true} | ||
${false} | ${false} | ||
`( | ||
'should validate that given an org with feature flag $hasFlag as input, hasFeatureFlag returns $expected', | ||
async ({ hasFlag, expected }) => { | ||
jest | ||
.spyOn(request, 'makeRequest') | ||
.mockResolvedValue({ body: { code: 200, ok: hasFlag } } as any); | ||
|
||
const result = await hasFeatureFlag('test-ff', { path: 'test-path' }); | ||
expect(result).toEqual(expected); | ||
}, | ||
); | ||
|
||
it('should throw error if there are authentication/authorization failures', async () => { | ||
jest.spyOn(request, 'makeRequest').mockResolvedValue({ | ||
body: { code: 401, error: 'Unauthorized', ok: false }, | ||
} as any); | ||
|
||
await expect( | ||
hasFeatureFlag('test-ff', { path: 'test-path' }), | ||
).rejects.toThrowError('Unauthorized'); | ||
|
||
jest.spyOn(request, 'makeRequest').mockResolvedValue({ | ||
body: { code: 403, error: 'Forbidden', ok: false }, | ||
} as any); | ||
await expect( | ||
hasFeatureFlag('test-ff', { path: 'test-path' }), | ||
).rejects.toThrowError('Forbidden'); | ||
}); | ||
}); |