diff --git a/packages/artifact/__tests__/util.test.ts b/packages/artifact/__tests__/util.test.ts index cd43232c..76f760fa 100644 --- a/packages/artifact/__tests__/util.test.ts +++ b/packages/artifact/__tests__/util.test.ts @@ -6,7 +6,7 @@ describe('get-backend-ids-from-token', () => { jest .spyOn(config, 'getRuntimeToken') .mockReturnValue( - 'eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6IjRTenlCTkRYcHNTT3owbERZMHYzS1JWVFJndyJ9.eyJuYW1laWQiOiJkZGRkZGRkZC1kZGRkLWRkZGQtZGRkZC1kZGRkZGRkZGRkZGQiLCJzY3AiOiJBY3Rpb25zLk1hbmFnZU9yZ3M6IEFjdGlvbnMuUmVzdWx0czpjZTdmNTRjNy02MWM3LTRhYWUtODg3Zi0zMGRhNDc1ZjVmMWE6Y2EzOTUwODUtMDQwYS01MjZiLTJjZTgtYmRjODVmNjkyNzc0IiwiSWRlbnRpdHlUeXBlQ2xhaW0iOiJTeXN0ZW06U2VydmljZUlkZW50aXR5IiwiaHR0cDovL3NjaGVtYXMueG1sc29hcC5vcmcvd3MvMjAwNS8wNS9pZGVudGl0eS9jbGFpbXMvc2lkIjoiREREREREREQtRERERC1ERERELUREREQtREREREREREREREREIiwiaHR0cDovL3NjaGVtYXMubWljcm9zb2Z0LmNvbS93cy8yMDA4LzA2L2lkZW50aXR5L2NsYWltcy9wcmltYXJ5c2lkIjoiZGRkZGRkZGQtZGRkZC1kZGRkLWRkZGQtZGRkZGRkZGRkZGRkIiwiYXVpIjoiZDJiZDAxNzItMzYyOC00ODFhLTg2MGUtMjM4NTA3YjQwYmY1Iiwic2lkIjoiOWM0ZmVmZTUtMWYyNC00NzZmLWJiNjctZjg3YTk3ZDVkNGVmIiwiaXNzIjoidnN0b2tlbi5jb2RlZGV2LmxvY2FsaG9zdCIsImF1ZCI6InZzdG9rZW4uY29kZWRldi5sb2NhbGhvc3QiLCJuYmYiOjE2OTE1OTU2ODQsImV4cCI6MTY5MTY4MjY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1bFKtJ-OImQgXrMVdVxcWL5eC-ebqk-DU9R5MLMGywlx_V_aeRBSyhwZRwPxHKixd-_TT-0U4v0siWqzIg944H9-Z-9XiduTVmODIbkF44jKbua_ohSk1kN_CO5uiHTiAkQnnE94Y586eT9QPHUxCKzlUH0KTntc94lD4zPTO-ZTmH3BJY_bbCrEPNnSMuEoBibf3IIgPo9ap67y3NcJrck6-Y8G-MbsVkBivT6Ac41fvxeKD8GCl9P8Zo7KoMoVzUVK0clHPwqWAES5AnzF9gccT4k5-IH25nGdKVz3UJvZVkjjtlRYdQ6ZTWvjU1T6Sd2242yQ-2AzqLZsStWcZC7VRekCMZqDepLkvOrmRti0_vF1DF3D2flrmukMUyjZ2WvfzI4voDAnHituXQ_LlwIEkIqagwBJ-sfydxzw' + 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwic2NwIjoiQWN0aW9ucy5FeGFtcGxlIEFjdGlvbnMuQW5vdGhlckV4YW1wbGU6dGVzdCIsImlhdCI6MTUxNjIzOTAyMn0.K0IEoULZteGevF38G94xiaA8zcZ5UlKWfGfqE6q3dhw' + ) + + expect(util.getBackendIdsFromToken).toThrowError( + 'Failed to get backend IDs: The provided JWT token is invalid' + ) + }) + + it('should throw an error when the token has a malformed scope', () => { + jest + .spyOn(config, 'getRuntimeToken') + .mockReturnValue( + 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwic2NwIjoiQWN0aW9ucy5FeGFtcGxlIEFjdGlvbnMuQW5vdGhlckV4YW1wbGU6dGVzdCBBY3Rpb25zLlJlc3VsdHM6Y2U3ZjU0YzctNjFjNy00YWFlLTg4N2YtMzBkYTQ3NWY1ZjFhIiwiaWF0IjoxNTE2MjM5MDIyfQ.7D0_LRfRFRZFImHQ7GxH2S6ZyFjjZ5U0ujjGCfle1XE' ) expect(util.getBackendIdsFromToken).toThrowError(