File: tc_tkey.rb

package info (click to toggle)
dnsruby 1.61.5-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,520 kB
  • sloc: ruby: 17,811; makefile: 3
file content (76 lines) | stat: -rw-r--r-- 2,462 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# --
# Copyright 2007 Nominet UK
# 
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# 
#     http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ++

require_relative 'spec_helper'

require "digest/md5"
class TestTKey < Minitest::Test
  def is_empty(string)
    return (string == "; no data" || string == "; rdlength = 0")
  end

  def test_tkey


    # ------------------------------------------------------------------------------
    #  Canned data.
    # ------------------------------------------------------------------------------

    zone	= "example.com"
    name	= "123456789-test"
    klass	= "IN"
    type	= Dnsruby::Types.TKEY
    algorithm   = "fake.algorithm.example.com"
    key         = "fake key"
    inception   = 100000 # use a strange fixed inception time to give a fixed
    #  checksum
    expiration  = inception + 24*60*60

    rr = nil

    # ------------------------------------------------------------------------------
    #  Packet creation.
    # ------------------------------------------------------------------------------

    rr = Dnsruby::RR.create(
      :name       => name,
      :type       => "TKEY",
      :ttl        => 0,
      :klass      => "ANY",
      :algorithm  => algorithm,
      :inception  => inception,
      :expiration => expiration,
      :mode       => 3, # GSSAPI
      :key        => "fake key",
      :other_data => ""
    )

    packet = Dnsruby::Message.new(name, Dnsruby::Types.TKEY, "IN")
    packet.add_answer(rr)

    z = (packet.zone)[0]

    assert(packet,                                'new() returned packet')  #2
    assert_equal(Dnsruby::OpCode.QUERY,       packet.header.opcode, 'header opcode correct')  #3
    assert_equal(name,                      z.zname.to_s,  'zname correct')          #4
    assert_equal(Dnsruby::Classes.IN,                       z.zclass, 'zclass correct')         #5
    assert_equal(Dnsruby::Types.TKEY,                     z.ztype,  'ztype correct')          #6

    # @TODO@ Test TKEY against server!

  end

  end