Use unmarshaling for AutoEncryptOpts in the unified spec test

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Unresolved
    • Priority: Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: Testing
    • None
    • Go Drivers
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?
    • None
    • None
    • None
    • None
    • None
    • None

      Context

      The entityOptions.AutoEncryptOpts should be updated to use unmarshaling to create a struct matching the unified spec test requirements.

      Definition of done

      AutoEncryptOpts should be defined unambigously:

      type awsKMSProvider struct {
      	AccessKeyID     string `bson:"accessKeyId"`
      	SecretAccessKey string `bson:"secretAccessKey"`
      	SessionToken    string `bson:"sessionToken,omitempty"`
      }
      
      type KMSProviders struct {
      	AWS *awsKMSProvider `bson:"aws"`
      	// etc
      }
      
      type autoEncryptOpts struct {
      	KMSProviders         KMSProviders   `bson:"kmsProviders,omitempty"`
      	SchemaMap            map[string]any `bson:"schemaMap,omitempty"`
      	KeyVaultNamespace    string         `bson:"keyVaultNamespace,omitempty"`
      	BypassAutoEncryption bool           `bson:"bypassAutoEncryption,omitempty"`
      	EncryptedFieldsMap   map[string]any `bson:"encryptedFieldsMap,omitempty"`
      	BypassQueryAnalysis  bool           `bson:"bypassQueryAnalysis,omitempty"`
      }
      
      type clientEntity struct {
      	AutoEncryptOpts *autoEncryptOpts `bson:"autoEncryptOpts"`
      }
      

      Then each KMS provider (e.g awsKMSPRovider) can implement bson.Unmarshaler rather than depending on bson.Raw elements patter:

      	elems, err := opts.Elements()
      	if err != nil {
      		return nil, err
      	}
      
      	for _, elem := range elems {
      		name := elem.Key()
      		opt := elem.Value()
                      // ...
              }
      

      See POC here: https://github.com/prestonvasquez/go-playground/blob/1cce584a1eb443e4eba30c52f6251d7787ab92bc/mgd_auto_encrypt_opts_test.go#L15

            Assignee:
            Unassigned
            Reporter:
            Preston Vasquez
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: