Sha256: 0dbe23656a5f9ed9ccc397be1624867b21205d21fb1ce26189194948a9ecfa20

Contents?: true

Size: 1.08 KB

Versions: 2

Compression:

Stored size: 1.08 KB

Contents

require "integration_spec_helper"

RSpec.describe NulogyMessageBusProducer::Subscriptions::RiskySubscriptionBlocker do
  it "blocks subscriptions with arguments" do
    query = <<~GRAPHQL
      foo {
        fieldWithArguments(first: "value")
      }
    GRAPHQL

    result = attempt_subscription(query)

    expect(result).to include_json(
      errors: [{
        message: "Arguments may not be used:\nfieldWithArguments"
      }]
    )
  end

  it "blocks subscriptions which would expand lists" do
    query = <<~GRAPHQL
      fooList {
        id
      }
    GRAPHQL

    result = attempt_subscription(query)

    expect(result).to include_json(
      errors: [{
        message: "Lists may not be queried:\nfooList"
      }]
    )
  end

  def attempt_subscription(query)
    execute_graphql(<<~GRAPHQL, NulogyMessageBusProducer::Specs::TestSchema)
      subscription {
        testCreated (
          subscriptionId: "#{SecureRandom.uuid}",
          subscriptionGroupId: "#{SecureRandom.uuid}",
          topicName: "some_topic"
        ) {
          #{query}
        }
      }
    GRAPHQL
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
nulogy_message_bus_producer-3.3.0 spec/integration/lib/nulogy_message_bus_producer/subscriptions/risky_subscription_blocker_spec.rb
nulogy_message_bus_producer-3.2.1 spec/integration/lib/nulogy_message_bus_producer/subscriptions/risky_subscription_blocker_spec.rb