Sha256: c62c405863623f54bf97a62f686a8d7f86f0b6f051e4759e5bdd03ad3ff2ae2e

Contents?: true

Size: 1.73 KB

Versions: 9

Compression:

Stored size: 1.73 KB

Contents

require 'spec_helper'

describe M3u8::SessionKeyItem do
  it 'should initialize with hash' do
    hash = { method: 'AES-128', uri: 'http://test.key',
             iv: 'D512BBF', key_format: 'identity',
             key_format_versions: '1/3' }
    item = M3u8::SessionKeyItem.new(hash)
    expect(item.method).to eq 'AES-128'
    expect(item.uri).to eq 'http://test.key'
    expect(item.iv).to eq 'D512BBF'
    expect(item.key_format).to eq 'identity'
    expect(item.key_format_versions).to eq '1/3'
  end

  it 'should provide m3u8 format representation' do
    hash = { method: 'AES-128', uri: 'http://test.key',
             iv: 'D512BBF', key_format: 'identity',
             key_format_versions: '1/3' }
    item = M3u8::SessionKeyItem.new(hash)
    expected = %(#EXT-X-SESSION-KEY:METHOD=AES-128,URI="http://test.key",) +
               %(IV=D512BBF,KEYFORMAT="identity",KEYFORMATVERSIONS="1/3")
    expect(item.to_s).to eq expected

    hash = { method: 'AES-128', uri: 'http://test.key' }
    item = M3u8::SessionKeyItem.new(hash)
    expected = %(#EXT-X-SESSION-KEY:METHOD=AES-128,URI="http://test.key")
    expect(item.to_s).to eq expected

    hash = { method: 'NONE' }
    item = M3u8::SessionKeyItem.new(hash)
    expected = '#EXT-X-SESSION-KEY:METHOD=NONE'
    expect(item.to_s).to eq expected
  end

  it 'should parse m3u8 format into instance' do
    format = %(#EXT-X-SESSION-KEY:METHOD=AES-128,URI="http://test.key",) +
             %(IV=D512BBF,KEYFORMAT="identity",KEYFORMATVERSIONS="1/3")
    item = M3u8::KeyItem.parse format
    expect(item.method).to eq 'AES-128'
    expect(item.uri).to eq 'http://test.key'
    expect(item.iv).to eq 'D512BBF'
    expect(item.key_format).to eq 'identity'
    expect(item.key_format_versions).to eq '1/3'
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
m3u8-0.7.0 spec/lib/m3u8/session_key_item_spec.rb
m3u8-0.6.9 spec/lib/m3u8/session_key_item_spec.rb
m3u8-0.6.8 spec/lib/m3u8/session_key_item_spec.rb
m3u8-0.6.7 spec/lib/m3u8/session_key_item_spec.rb
m3u8-0.6.6 spec/lib/m3u8/session_key_item_spec.rb
m3u8-0.6.5 spec/lib/m3u8/session_key_item_spec.rb
m3u8-0.6.4 spec/lib/m3u8/session_key_item_spec.rb
m3u8-0.6.3 spec/lib/m3u8/session_key_item_spec.rb
m3u8-0.6.2 spec/lib/m3u8/session_key_item_spec.rb