TclGPG  Check-in [e0cfba5122]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Added option -keys to the import routine.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:e0cfba5122cb7457d9a6b0357139940f9f4ff1ac
User & Date: sgolovan 2015-12-30 11:41:52
Context
2015-12-31
20:12
Explicitly unset the GPG_AGENT_INFO environment variable because it interferes with tests. check-in: 6361d617e5 user: sergei tags: trunk
2015-12-30
11:41
Added option -keys to the import routine. check-in: e0cfba5122 user: sgolovan tags: trunk
09:14
Added incomplete (but usable) support for importing and deleting GPG keys. Bumped the package version to 1.1. check-in: 7786c1df95 user: sgolovan tags: trunk
Changes

Changes to ChangeLog.

     1      1   2015-12-30  Sergei Golovan  <sgolovan@nes.ru>
     2      2   
     3      3   	* tclgpg.tcl, tclgpg.test: Added incomplete (but usable) support for
     4      4   	  importing and deleting GPG keys.
     5      5   
     6      6   	* configure.in: Bumped the package version to 1.1.
            7  +
            8  +	* tclgpg.tcl, tclgpg.test: Added option -keys to the import routine.
     7      9   
     8     10   2015-12-27  Sergei Golovan  <sgolovan@nes.ru>
     9     11   
    10     12   	* tclgpg.tcl: Return the 'bad passphrase' error for the case of
    11     13   	  failure after incorrectly entered passphrase via the pinentry.
    12     14   
    13     15   	* tclgpg.test: Added a test which ensures that the recipient for

Changes to tclgpg.tcl.

   656    656   
   657    657   proc ::gpg::Import {token args} {
   658    658       variable $token
   659    659       upvar 0 $token state
   660    660   
   661    661       set commands {}
   662    662       set opts {}
          663  +    set arg {}
   663    664   
   664    665       foreach {key val} $args {
   665    666           switch -- $key {
   666    667               -keyserver {
   667    668                   set opts [list --keyserver $val]
   668    669               }
   669    670               -key {
   670         -                set arg $val
          671  +                lappend arg $val
          672  +                set operation --recv-keys
          673  +            }
          674  +            -keys {
          675  +                foreach v $val {
          676  +                    lappend arg $v
          677  +                }
   671    678                   set operation --recv-keys
   672    679               }
   673    680               -uri {
   674         -                set arg $val
          681  +                set arg [list $val]
   675    682                   set operation --fetch-keys
   676    683               }
   677    684               -data {
   678         -                set arg $val
          685  +                set input $val
   679    686                   set operation --import
   680    687               }
   681    688               -command {
   682    689                   set commands [list $val]
   683    690               }
   684    691               default {
   685    692                   return -code error \
   686    693                          [format "unknown option \"%s\":\
   687    694                                   must be %s" $key [JoinOptions {-keyserver
   688    695                                                                  -key
          696  +                                                               -keys
   689    697                                                                  -uri
   690    698                                                                  -data
   691    699                                                                  -command}]]
   692    700               }
   693    701           }
   694    702       }
   695    703   
   696    704       if {![info exists operation]} {
   697         -        return -code error "one of -key, -uri, or -data options must\
          705  +        return -code error "one of -key, -keys, -uri, or -data options must\
   698    706                               be specified"
   699    707       }
   700    708   
   701    709       if {$operation eq "--import"} {
   702    710           set gpgChannels [ExecGPG $token import --batch --import]
   703         -        return [UseGPG $token import $commands $gpgChannels $arg]
          711  +        return [UseGPG $token import $commands $gpgChannels $input]
   704    712       } else {
   705    713           set gpgChannels [eval ExecGPG $token fetch --batch $opts $operation \
   706         -                              -- [list $arg]]
          714  +                              -- $arg]
   707    715           return [UseGPG $token fetch $commands $gpgChannels]
   708    716       }
   709    717   }
   710    718   
   711    719   # ::gpg::Delete --
   712    720   #
   713    721   #       Delete key from the keyring.

Changes to tclgpg.test.

    13     13   
    14     14   set auto_path [linsert $auto_path 0 [file dirname [info script]]]
    15     15   
    16     16   set env(GNUPGHOME) [file join [file dirname [info script]] gnupg]
    17     17   catch {file attributes $env(GNUPGHOME) -permissions 0700}
    18     18   
    19     19   package forget gpg
    20         -package require -exact gpg 1.0
           20  +package require -exact gpg 1.1
    21     21   
    22     22   test new-1.1 {Create context} -body {
    23     23       set c [::gpg::new]
    24     24       list [string equal [info procs $c] $c] \
    25     25                     [string equal [info vars $c] $c]
    26     26   } -result {1 1} -cleanup {$c free}
    27     27   
................................................................................
   596    596   
   597    597   test import-1.1 {Import with unknown option} -body {
   598    598       set c [::gpg::new]
   599    599       $c import -email user@host
   600    600   } -cleanup {
   601    601       $c free
   602    602   } -returnCodes error \
   603         --result {unknown option "-email": must be -keyserver, -key, -uri, -data, or -command}
          603  +-result {unknown option "-email": must be -keyserver, -key, -keys, -uri, -data, or -command}
   604    604   
   605    605   test import-1.2 {Import without required option} -body {
   606    606       set c [::gpg::new]
   607    607       $c import -keyserver pgp.mit.edu
   608    608   } -cleanup {
   609    609       $c free
   610         -} -returnCodes error -result {one of -key, -uri, or -data options must be specified}
          610  +} -returnCodes error -result {one of -key, -keys, -uri, or -data options must be specified}
   611    611   
   612    612   test import-1.3 {Import invalid data using -data} -body {
   613    613       set c [::gpg::new]
   614    614       $c import -data "garbage"
   615    615   } -cleanup {
   616    616       $c free
   617    617   } -returnCodes error -result {Invalid data to import}