Skip to content

Commit

Permalink
Merge pull request #101 from thekuwayama/ech_outer_extensions__10
Browse files Browse the repository at this point in the history
[ech_outer_extensions] 10. improvement: add multiple OuterExtensions testcase & clean testcase
  • Loading branch information
thekuwayama authored Apr 18, 2024
2 parents 4439b06 + f212511 commit 67dfaf0
Showing 1 changed file with 35 additions and 6 deletions.
41 changes: 35 additions & 6 deletions spec/extensions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -196,26 +196,55 @@
end

it 'should be equal remove_and_replace! with []' do
cloned = extensions.clone
expect(extensions.remove_and_replace!([]))
.to eq cloned
expected = extensions.clone
got = extensions.remove_and_replace!([])

expect(got.keys).to eq expected.keys
expect(got[ExtensionType::ECH_OUTER_EXTENSIONS]).to eq nil
expect(extensions.keys - got.keys).to eq []
end

it 'should be equal remove_and_replace! with [key_share]' do
expected = extensions.filter { |k, _| k != ExtensionType::KEY_SHARE }
expected[ExtensionType::ECH_OUTER_EXTENSIONS] = \
Extension::ECHOuterExtensions.new([ExtensionType::KEY_SHARE])
got = extensions.remove_and_replace!([ExtensionType::KEY_SHARE])

expect(got.keys).to eq expected.keys
expect(got[ExtensionType::ECH_OUTER_EXTENSIONS].outer_extensions)
.to eq expected[ExtensionType::ECH_OUTER_EXTENSIONS].outer_extensions
expect(extensions.keys - got.keys)
.to eq expected[ExtensionType::ECH_OUTER_EXTENSIONS].outer_extensions
end

it 'should be equal remove_and_replace! with' \
' [key_share,supported_versions]' do
outer_extensions = [
ExtensionType::KEY_SHARE,
ExtensionType::SUPPORTED_VERSIONS
]
expected = extensions.filter { |k, _| !outer_extensions.include?(k) }
expected[ExtensionType::ECH_OUTER_EXTENSIONS] = \
Extension::ECHOuterExtensions.new(
extensions.filter { |k, _| outer_extensions.include?(k) }.keys
)
got = extensions.remove_and_replace!(outer_extensions)

expect(got.keys).to eq expected.keys
expect(got[ExtensionType::ECH_OUTER_EXTENSIONS].outer_extensions)
.to eq expected[ExtensionType::ECH_OUTER_EXTENSIONS].outer_extensions
expect(extensions.keys - got.keys)
.to eq expected[ExtensionType::ECH_OUTER_EXTENSIONS].outer_extensions
end

it 'should be equal remove_and_replace! with no key_share extensions' \
' & [key_share]' do
cloned = no_key_share_exs.clone
expect(no_key_share_exs.remove_and_replace!([ExtensionType::KEY_SHARE]))
.to eq cloned
expected = no_key_share_exs.clone
got = no_key_share_exs.remove_and_replace!([ExtensionType::KEY_SHARE])

expect(got).to eq expected
expect(got[ExtensionType::ECH_OUTER_EXTENSIONS]).to eq nil
expect(no_key_share_exs.keys - got.keys).to eq []
end
end
end

0 comments on commit 67dfaf0

Please sign in to comment.