Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/spec/lib/rex/proto/steam/message_spec.rb
Views: 11789
# -*- coding: binary -*-1require 'spec_helper'23RSpec.describe Rex::Proto::Steam do4subject(:steam) do5mod = Module.new6mod.extend described_class7mod8end910describe '#encode_message' do11it 'properly encodes messages' do12message = steam.encode_message('T', 'Test')13expect(message).to eq("\xFF\xFF\xFF\xFF\x54Test")14end15end1617describe '#decode_message' do18it 'does not decode overly short messages' do19expect(steam.decode_message('foo')).to eq(nil)20end2122it 'does not decode unknown messages' do23expect(steam.decode_message("\xFF\xFF\xFF\x01blahblahblah")).to eq(nil)24end2526it 'properly decodes valid messages' do27type, message = steam.decode_message("\xFF\xFF\xFF\xFF\x54Test")28expect(type).to eq(0x54)29expect(message).to eq('Test')30end31end3233describe '#a2s_info_decode' do34it 'extracts a2s_info fields properly' do35expected_info = {36version: 17, name: "-=THE BATTLEGROUNDS *HARDCORE*=-", map: "aoc_battleground",37folder: "ageofchivalry", game_name: "Age of Chivalry", game_id: 17510,38players: "22/32", bots: 0, game_version: "1.0.0.6", type: "Dedicated",39environment: "Linux", visibility: "public", VAC: "secured"40}41actual_info = steam.a2s_info_decode(File.binread(File.join(File.dirname(__FILE__), 'steam_info.bin')))42expect(actual_info).to eq(expected_info)43end44end45end464748