mirror of
https://github.com/graphql-hive/console
synced 2026-04-21 14:37:17 +00:00
fix: disable stripe sync on integration tests (#7877)
This commit is contained in:
parent
27bbeb4f9b
commit
3500825b12
8 changed files with 22 additions and 9 deletions
|
|
@ -19,6 +19,7 @@ CLICKHOUSE_PASSWORD=wowverysecuremuchsecret
|
|||
CDN_AUTH_PRIVATE_KEY=6b4721a99bd2ef6c00ce4328f34d95d7
|
||||
EMAIL_PROVIDER=mock
|
||||
COMMERCE_ENDPOINT=http://commerce:3009
|
||||
COMMERCE_BILLING=0
|
||||
CLICKHOUSE_ASYNC_INSERT_BUSY_TIMEOUT_MS=500
|
||||
CLICKHOUSE_ASYNC_INSERT_MAX_DATA_SIZE=1000
|
||||
EXTERNAL_COMPOSITION_SECRET=secretsecret
|
||||
|
|
|
|||
|
|
@ -159,6 +159,7 @@ services:
|
|||
FEEDBACK_SLACK_TOKEN: ''
|
||||
FEEDBACK_SLACK_CHANNEL: '#hive'
|
||||
COMMERCE_ENDPOINT: '${COMMERCE_ENDPOINT}'
|
||||
COMMERCE_BILLING: '${COMMERCE_BILLING}'
|
||||
EMAIL_PROVIDER: '${EMAIL_PROVIDER}'
|
||||
LOG_LEVEL: debug
|
||||
# Auth
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ test('rate limit approaching and reached for organization', async () => {
|
|||
operations: 11,
|
||||
},
|
||||
ownerToken,
|
||||
);
|
||||
).then(r => r.expectNoGraphQLErrors());
|
||||
|
||||
const { collectLegacyOperations: collectOperations } = await createTargetAccessToken({});
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,9 @@ import { IdTranslator } from '../../shared/providers/id-translator';
|
|||
import { Logger } from '../../shared/providers/logger';
|
||||
import { Storage } from '../../shared/providers/storage';
|
||||
import {
|
||||
COMMERCE_CONFIG,
|
||||
COMMERCE_TRPC_CLIENT,
|
||||
type CommerceConfig,
|
||||
type CommerceTrpcClient,
|
||||
type CommerceTrpcClientInputs,
|
||||
} from './commerce-client';
|
||||
|
|
@ -24,6 +26,7 @@ export class BillingProvider {
|
|||
|
||||
constructor(
|
||||
@Inject(COMMERCE_TRPC_CLIENT) private client: CommerceTrpcClient,
|
||||
@Inject(COMMERCE_CONFIG) commerceConfig: CommerceConfig,
|
||||
logger: Logger,
|
||||
private auditLog: AuditLogRecorder,
|
||||
private storage: Storage,
|
||||
|
|
@ -32,7 +35,7 @@ export class BillingProvider {
|
|||
) {
|
||||
this.logger = logger.child({ source: 'CommerceProvider' });
|
||||
|
||||
this.enabled = !!client;
|
||||
this.enabled = !!client && commerceConfig.billingEnabled;
|
||||
}
|
||||
|
||||
async upgradeToPro(input: BillingInput['createSubscriptionForOrganization']) {
|
||||
|
|
@ -58,7 +61,7 @@ export class BillingProvider {
|
|||
}
|
||||
|
||||
syncOrganization(input: BillingInput['syncOrganizationToStripe']) {
|
||||
if (!this.client) {
|
||||
if (!this.client || !this.enabled) {
|
||||
throw new Error(`Billing service is not configured!`);
|
||||
}
|
||||
|
||||
|
|
@ -67,7 +70,7 @@ export class BillingProvider {
|
|||
|
||||
async getAvailablePrices() {
|
||||
this.logger.debug('Getting available prices');
|
||||
if (!this.client) {
|
||||
if (!this.client || !this.enabled) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
@ -86,7 +89,7 @@ export class BillingProvider {
|
|||
|
||||
getActiveSubscription(input: BillingInput['activeSubscription']) {
|
||||
this.logger.debug('Fetching active subscription (input=%o)', input);
|
||||
if (!this.client) {
|
||||
if (!this.client || !this.enabled) {
|
||||
throw new Error(`Billing service is not configured!`);
|
||||
}
|
||||
|
||||
|
|
@ -95,7 +98,7 @@ export class BillingProvider {
|
|||
|
||||
invoices(input: BillingInput['invoices']) {
|
||||
this.logger.debug('Fetching invoices (input=%o)', input);
|
||||
if (!this.client) {
|
||||
if (!this.client || !this.enabled) {
|
||||
throw new Error(`Billing service is not configured!`);
|
||||
}
|
||||
|
||||
|
|
@ -104,7 +107,7 @@ export class BillingProvider {
|
|||
|
||||
upcomingInvoice(input: BillingInput['upcomingInvoice']) {
|
||||
this.logger.debug('Fetching upcoming invoices (input=%o)', input);
|
||||
if (!this.client) {
|
||||
if (!this.client || !this.enabled) {
|
||||
throw new Error(`Billing service is not configured!`);
|
||||
}
|
||||
|
||||
|
|
@ -113,7 +116,7 @@ export class BillingProvider {
|
|||
|
||||
async downgradeToHobby(input: BillingInput['cancelSubscriptionForOrganization']) {
|
||||
this.logger.debug('Downgrading to Hobby (input=%o)', input);
|
||||
if (!this.client) {
|
||||
if (!this.client || !this.enabled) {
|
||||
throw new Error(`Billing service is not configured!`);
|
||||
}
|
||||
|
||||
|
|
@ -132,7 +135,7 @@ export class BillingProvider {
|
|||
async generateStripePortalLink(args: { organizationSlug: string }) {
|
||||
this.logger.debug('Generating Stripe portal link for id:' + args.organizationSlug);
|
||||
|
||||
if (!this.client) {
|
||||
if (!this.client || !this.enabled) {
|
||||
throw new Error(`Billing service is not configured!`);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ export type CommerceTrpcClient = CreateTRPCProxyClient<CommerceRouter> | null;
|
|||
export type CommerceTrpcClientInputs = inferRouterInputs<CommerceRouter>;
|
||||
export type CommerceConfig = {
|
||||
endpoint: string | null;
|
||||
billingEnabled: boolean;
|
||||
};
|
||||
|
||||
export const COMMERCE_TRPC_CLIENT = new InjectionToken<CommerceTrpcClient>('commerce-trpc-client');
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ TOKENS_ENDPOINT="http://localhost:6001"
|
|||
SCHEMA_ENDPOINT="http://localhost:6500"
|
||||
SCHEMA_POLICY_ENDPOINT="http://localhost:6600"
|
||||
COMMERCE_ENDPOINT="http://localhost:4013"
|
||||
COMMERCE_BILLING="0"
|
||||
|
||||
REDIS_HOST="localhost"
|
||||
REDIS_PORT="6379"
|
||||
|
|
|
|||
|
|
@ -53,6 +53,10 @@ const EnvironmentModel = zod.object({
|
|||
|
||||
const CommerceModel = zod.object({
|
||||
COMMERCE_ENDPOINT: emptyString(zod.string().url().optional()),
|
||||
COMMERCE_BILLING: zod
|
||||
.union([zod.literal('1'), zod.literal('0')])
|
||||
.default('1')
|
||||
.optional(),
|
||||
});
|
||||
|
||||
const SentryModel = zod.union([
|
||||
|
|
@ -401,6 +405,7 @@ export const env = {
|
|||
? {
|
||||
endpoint: commerce.COMMERCE_ENDPOINT,
|
||||
dateRetentionPurgeIntervalMinutes: 5,
|
||||
billing: commerce.COMMERCE_BILLING === '0' ? false : true,
|
||||
}
|
||||
: null,
|
||||
schemaPolicy: base.SCHEMA_POLICY_ENDPOINT
|
||||
|
|
|
|||
|
|
@ -270,6 +270,7 @@ export async function main() {
|
|||
},
|
||||
commerce: {
|
||||
endpoint: env.hiveServices.commerce ? env.hiveServices.commerce.endpoint : null,
|
||||
billingEnabled: env.hiveServices.commerce ? env.hiveServices.commerce.billing : false,
|
||||
},
|
||||
schemaService: {
|
||||
endpoint: env.hiveServices.schema.endpoint,
|
||||
|
|
|
|||
Loading…
Reference in a new issue