(t *testing.T)
| 162 | } |
| 163 | |
| 164 | func TestKeyLocalAllow(t *testing.T) { |
| 165 | exec, _ := initEnv(types.GetDefaultCfgstring()) |
| 166 | cfg := exec.client.GetConfig() |
| 167 | err := isAllowLocalKey(cfg, []byte("token"), []byte("LODB-token-")) |
| 168 | assert.Equal(t, err, types.ErrLocalKeyLen) |
| 169 | err = isAllowLocalKey(cfg, []byte("token"), []byte("LODB_token-a")) |
| 170 | assert.Equal(t, err, types.ErrLocalPrefix) |
| 171 | err = isAllowLocalKey(cfg, []byte("token"), []byte("LODB-token-a")) |
| 172 | assert.Nil(t, err) |
| 173 | err = isAllowLocalKey(cfg, []byte(""), []byte("LODB--a")) |
| 174 | assert.Equal(t, err, types.ErrLocalPrefix) |
| 175 | err = isAllowLocalKey(cfg, []byte("exec"), []byte("LODB-execaa")) |
| 176 | assert.Equal(t, err, types.ErrLocalPrefix) |
| 177 | err = isAllowLocalKey(cfg, []byte("exec"), []byte("-exec------aa")) |
| 178 | assert.Equal(t, err, types.ErrLocalPrefix) |
| 179 | err = isAllowLocalKey(cfg, []byte("paracross"), []byte("LODB-user.p.para.paracross-xxxx")) |
| 180 | assert.Equal(t, err, types.ErrLocalPrefix) |
| 181 | err = isAllowLocalKey(cfg, []byte("user.p.para.paracross"), []byte("LODB-user.p.para.paracross-xxxx")) |
| 182 | assert.Nil(t, err) |
| 183 | err = isAllowLocalKey(cfg, []byte("user.p.para.user.wasm.abc"), []byte("LODB-user.p.para.user.wasm.abc-xxxx")) |
| 184 | assert.Nil(t, err) |
| 185 | err = isAllowLocalKey(cfg, []byte("user.p.para.paracross"), []byte("LODB-paracross-xxxx")) |
| 186 | assert.Nil(t, err) |
| 187 | } |
| 188 | |
| 189 | func init() { |
| 190 | types.AllowUserExec = append(types.AllowUserExec, []byte("demo"), []byte("demof")) |
nothing calls this directly
no test coverage detected